-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculateN4.m
71 lines (59 loc) · 870 Bytes
/
calculateN4.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
function val = calculateN4(I,P)
[height,width] = size(I);
Up=[P(1) P(2)+1];
Down=[P(1)+1 P(2)];
Left=[P(1)-1 P(2)];
Right=[P(1) P(2)-1];
if (Up(1) < 1)
Up(1) =1;
end
if (Up(1) > height)
Up(1) = height;
end
if (Up(2) < 1)
Up(2) =1;
end
if (Up(2) > width)
Up(2) = width;
end
%----
if (Down(1) < 1)
Down(1) =1;
end
if (Down(1) > height)
Down(1) = height;
end
if (Down(2) < 1)
Down(2) =1;
end
if (Down(2) > width)
Down(2) = width;
end
%----
if (Left(1) < 1)
Left(1) =1;
end
if (Left(1) > height)
Left(1) = height;
end
if (Left(2) < 1)
Left(2) =1;
end
if (Left(2) > width)
Left(2) = width;
end
%----
if (Right(1) < 1)
Right(1) =1;
end
if (Right(1) > height)
Right(1) = height;
end
if (Right(2) < 1)
Right(2) =1;
end
if (Right(2) > width)
Right(2) = width;
end
val = [Up ;Down ;Left ;Right];
end