-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGray_Level_Slicing.m
41 lines (36 loc) · 1.04 KB
/
Gray_Level_Slicing.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
clc;
clear all;
close all;
img = imread('C:\Users\NAKUL DEB NATH\Desktop\CSE4182-Digital Image Processing Lab\Images\Gray_level_Slicing1.png');
img = rgb2gray(img);
without_background = uint8(img);
with_background = uint8(img);
[n,m] = size(without_background);
l = 256;
for i=1:n
for j=1:m
%With out BackGround
if(without_background(i,j)>120 & without_background(i,j)<220)
without_background(i,j) = l-1;
else
without_background(i,j) = 0;
end
%With BackGround
if(with_background(i,j)>120 & with_background(i,j)<220)
with_background(i,j) = l-1;
end
end
end
figure,imshow(img);title('Original Image');
figure;
imshow(without_background); title('Gray Level Slicing Without BackGround');
for i=1:n
for j=1:m
%With BackGround
if(without_background(i,j)>120 & without_background(i,j)<220)
without_background(i,j) = l-1;
end
end
end
figure;
imshow(with_background); title('Gray Level Slicing With BackGround');