-
Notifications
You must be signed in to change notification settings - Fork 1
/
thresh.m
146 lines (122 loc) · 2.06 KB
/
thresh.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
clc;
clear all;
close all;
im=imread('aqdef2.jpg');
subplot(3,3,1);
imshow(im);
title('original image');
im=rgb2gray(im);
im=double(im);
subplot(3,3,2);
imshow(im);
title('gray scale image');
[row col]=size(im);
max_im=max(max(im));
h=zeros(1,max_im 1);
!1st block
for n=1:1:60
for m=1:1:60
a(n,m)=im(n,m);
end
end
a=a 1;
for n=1:1:60
for m=1:1:60
t=a(n,m);
h(t)=h(t) 1;
end
end
subplot(3,3,3);
bar(h)
[X,Y]=ginput(1);
for n=1:1:60
for m=1:1:60
if a(n,m)<X
a(n,m)=0;
else
a(n,m)=255;
end
end
end
subplot(3,3,4);
imshow(uint8(a))
title('1st block image');
!2nd block
for n=1:1:60
for m=61:1:60
b(n,m-60)=im(n,m)
end
end
b=b 1;
for n=1:1:60
for m=1:1:60
t=b(n,m);
h(t)=h(t) 1;
end
end
figure(2)
bar(h)
[X,Y]=ginput(1);
for n=1:1:60
if b(n,m)<X
b(n,m)=0;
else
b(n,m)=255;
end
end
imshow(uint8(b))
!3rd block
for n=61:1:120
for m=1:1:60
c(n-60,m)=im(n,m);
end
end
c=c 1;
for n=1:1:60
for m=1:1:60
t=c(n,m);
h(t)=h(t) 1;
end
end
figure(3)
bar(h)
[X,Y]=ginput(1);
for n=1:1:60
for m=1:1:60
if c(n,m)< X
c(n,m)=0;
else
c(n,m)=255;
end
end
end
imshow(uint8(c))
!final block
for n=1:1:row
for m=61:1:col
d(n-60,m-60)=im(n,m);
end
end
d=d 1;
for n=1:1:60
for m=1:1:60
t=d(n,m);
h(t)=h(t) 1;
end
end
figure(4);
bar(h);
[X,Y]=ginput(1);
for n=1:1:60
for m=1:1:60
if d(n,m)<X
d(n,m)=0;
else
d(n,m)=255;
end
end
end
imshow(uint8(d))
s=[a b;c d];
figure(5);
imshow(uint(s))