Professional Documents
Culture Documents
Global Thresholding Assignment Using Matlab
Global Thresholding Assignment Using Matlab
Image Processing
ENG/13/017 S.L.D De Silva
Function to threshold
function y=threshFunc(I,T)
I=im2double(I);%convert to double
%thresholding
G=I>T;
Y=G.*255;
end
Image 1
Image 2
Tprev =
60
Tprev =
68.1877
Tprev =
76.5002
Tprev =
82.7507
Tprev =
85.9530
t =
86.7824
Analysis
dT
2
2
2
1
0.1
0.001
T
10
80
120
80
80
80
t
86.7824
86.7824
87.3131
86.9843
86.9843
86.9843
Image 3
Image 4
Image 5
%find threshold value
T=60; dt=2;
t1=thresholdingglobal(img,T,dT)
Tprev =
Image 6
60
Tprev =
56.4950
Tprev =
53.7533
t1 =
52.1780
Analysis
dt
T
t1
2
60
52.1780
1
60
51.4424
0.001
60
50.6445
0.001
100
50.6445
0.001
150
50.6445
0.001
10
50.6445
It seems that this function tends to give the mean value of the distribution of the
histogram which is 50.6445. The accuracy of the mean depends on the dt value
precision.
th1=threshFunc(img,t1);
L=imshow(th1); % Image 7
Image 7