Thresholding

 avatar
unknown
matlab
5 months ago
315 B
4
Indexable
I = imread("cameraman.tif");
[m,n] = size(I);

J = zeros(m,n);


T = 150; 

for i = 1:m
    for j = 1:n
        if( I(i,j) <  T)
            J(i,j) = 0; %black
        else
            J(i,j) = 255; %white
        end;
    end;
end;

figure, subplot (1,2,1), imshow(I);
subplot(1,2,2), imshow(J);
Editor is loading...
Leave a Comment