-
Notifications
You must be signed in to change notification settings - Fork 0
/
gotoLevelA.m
34 lines (31 loc) · 1.19 KB
/
gotoLevelA.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
function [intensity, zxy, winSize] = gotoLevelA(windowSize, topLeftCoordinateX, topLeftCoordinateY, height, width, saltAndPepperImg, x, y)
if(topLeftCoordinateY <= height && topLeftCoordinateX <= width)
buffer = zeros(1, windowSize * windowSize);
position = 1;
for j = 0 : windowSize - 1
for i = 0 : windowSize - 1
if(topLeftCoordinateY + j <= height && topLeftCoordinateX + i <= width)
buffer(position) = saltAndPepperImg(topLeftCoordinateY + j, topLeftCoordinateX + i);
else
buffer(position) = saltAndPepperImg(topLeftCoordinateY, topLeftCoordinateX);
end
position = position + 1;
end
end
buffer = unique(buffer);
Zmax = max(buffer);
Zmin = min(buffer);
Zmed = median(buffer);
A1 = Zmed - Zmin;
A2 = Zmed - Zmax;
Zxy = saltAndPepperImg(y, x);
if A1 > 0 && A2 < 0
intensity = gotoLevelB(Zxy, Zmax, Zmin, Zmed);
else
windowSize = windowSize + 2;
intensity = false;
end
zxy = Zxy;
winSize = windowSize;
end
end