-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetSub.m
More file actions
executable file
·84 lines (67 loc) · 1.17 KB
/
getSub.m
File metadata and controls
executable file
·84 lines (67 loc) · 1.17 KB
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
function subPixIntensity = getSub(I,x,y);
% a --- d
% | |
% | |
% | |
% b --- c
% a = [floor(x) floor(y)];
% b = [floor(x) ceil(y) ];
% c = [ceil(x) ceil(y) ];
% d = [ceil(x) floor(y)];
[w,h]=size(I);
%disp(w);
% if (x < 1 )
% x = 1;
% subPixIntensity = NaN;
% return;
% elseif (x>w-1)
% x = w-1;
% subPixIntensity = NaN;
% return;
% end
%
% if (y < 1 )
% y = 1;
% subPixIntensity = NaN;
% return;
% elseif (y>h-1)
% y = h-1;
% subPixIntensity = NaN;
% return;
% end
if (x < 1 )
x = 1;
subPixIntensity = 0;
return;
elseif (x>w-1)
x = w-1;
subPixIntensity = 0;
return;
end
if (y < 1 )
y = 1;
subPixIntensity = 0;
return;
elseif (y>h-1)
y = h-1;
subPixIntensity = 0;
return;
end
fx = floor(x);
fy = floor(y);
cx = ceil(x);
cy = ceil(y);
b = I(fx,fy);
a = I(fx,cy);
d = I(cx ,cy);
c = I(cx ,fy);
dx = x - fx;
dy = y - fy;
diffX = 1 - dx;
diffY = 1 - dy;
subPixIntensity = diffY*(diffX*b + dx*c) + dy*(diffX*a + dx*d);
% b --- c
% | |
% | |
% | |
% a --- d