Thresholding operation is the simplest method of image segmentation.
Thresholding can be used to convert gray scale image to a binary images
g(m,n)= 0 for f(m,n) <T
255 otherwise
MATLAB CODE:
a=imread(‘cameraman.tif’);
figure
imshow(a);
[m n]=size(a);
th=input(‘enter the threshold parameter’); % Enter the value lies between 0 to 255
for i=1:m
for j=1:n
if a(i,j)<th
b(i,j)=0;
else
b(i,j)=255;
end
end
end
figure
imshow(b);
Thresholding can be used to convert gray scale image to a binary images
g(m,n)= 0 for f(m,n) <T
255 otherwise
MATLAB CODE:
a=imread(‘cameraman.tif’);
figure
imshow(a);
[m n]=size(a);
th=input(‘enter the threshold parameter’); % Enter the value lies between 0 to 255
for i=1:m
for j=1:n
if a(i,j)<th
b(i,j)=0;
else
b(i,j)=255;
end
end
end
figure
imshow(b);
Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com