-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvotemex.m
More file actions
61 lines (53 loc) · 1.68 KB
/
Copy pathvotemex.m
File metadata and controls
61 lines (53 loc) · 1.68 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
function res = votemex(img, ann, bnn)
[M,N,~] = size(ann);
[X,Y,~] = size(bnn);
Nt = M*N;
Ns = X*Y;
res = ones(M+6,N+6,3);
for x = 1:M+6
for y = 1:N+6
S2 = zeros(1,1,3);
m = 0;
for i = 0:6
for j = 0:6
if x-i > 0 && y-j > 0 && x-i <= M && y-j <= N
c1_x = x-i;
c1_y = y-j;
c2_x = ann(c1_x,c1_y,1);
c2_y = ann(c1_x,c1_y,2);
x2 = c2_x + i;
y2 = c2_y + j;
S2 = S2 + img(x2,y2,:);
m = m + 1;
end
end
end
S1 = zeros(1,1,3);
n = 0;
for i = 0:6
for j = 0:6
if x-i > 0 && y-j > 0 && x-i <= M && y-j <= N
[index_x,index_y] = find(bnn(:,:,1) == x-i & bnn(:,:,2) == y-j);
len = length(index_x);
if len == 1
index_x = index_x + i;
index_y = index_y + j;
S1 = S1 + img(index_x,index_y,:);
n = n+1;
elseif len > 1
index_x = index_x + i;
index_y = index_y + j;
for k = 1:len
S1 = S1 + img(index_x(k),index_y(k),:);
end
n = n + len;
end
end
end
end
C1 = Nt/(n*Nt+m*Ns);
C2 = Ns/(n*Nt+m*Ns);
res(x,y,:) = C1*S1 + C2*S2;
end
end
end