Anda di halaman 1dari 1

clear all;

clc;
close all;
%% inisialisation
filename = 'coins.png';
I=imread(filename);
imshow(I);
title('Original Image','fontsize',14);
%%
%% Finding Global Threshold value (T)
figure, imhist(I);
[row,col]=size(I);
T=mean2(I);
err=T;
while err~=0
R1=I(I>=T);
R2=I(I<T);
miu1=mean2(R1);
miu2=mean2(R2);
temp=T;
T=(miu1+miu2)/2;
err=T-temp;
end
%%
%% Begin global thresholding

for jj=1:row
for kk=1:col
if I(jj,kk)>=100
I(jj,kk)=0;
else
I(jj,kk)=255;
end
end
end
figure, imshow(I);
title('Thresholded Image'
%% end
% originale by jans hendry
% UGM indonesia
I(jj,kk)>=100
I(jj,kk)=0;
I(jj,kk)=255;
figure, imshow(I);
'Thresholded Image','fontsize',14);
% originale by jans hendry

Anda mungkin juga menyukai