Wednesday, November 18, 2009

Intensity level slicing with Background and without Background

Note:-Write this code in Matlab

CODE

%Intensity level slicing with background%

clear all ;
clc;
p=imread('lily.tif');
z=double(p);
[row,col]=size(z);
for i=1:1:row
for j=1:1:col
if((z(i,j)>50)) && (z(i,j)<150)
z(i,j)=255;
else
z(i,j)=p(i,j);
end
end
end
figure(1); %-----------Original Image-------------%
imshow(p);
figure(2); %-----------Gray Level Slicing With Background-------------%
imshow(uint8(z));



Intensity Level slicing without background


CODE

%Intensity level slicing without background%

clear all;
clc;
p=imread('lily.tif');
z=double(p);
[row,col]=size(z)
for i=1:1:row
for j=1:1:col
if((z(i,j)>50)) && (z(i,j)<150)
z(i,j)=255;
else
z(i,j)=0;
end
end
end
figure(1); %-----------Original Image-------------%
imshow(p);
figure(2); %-----------Gray Level Slicing Without Background-------------%
imshow(uint8(z));

3 comments:

  1. thank you so much for this code......... keep it up......

    ReplyDelete
  2. Wow!!!!! This code helped me . Zillion and million thanks. Keep posting and share your valuable knowledge

    ReplyDelete