-
Notifications
You must be signed in to change notification settings - Fork 15
/
UIConM.m
68 lines (65 loc) · 1.84 KB
/
UIConM.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
function uiconm = UIConM(img)
R = double(img(:,:,1));
G = double(img(:,:,2));
B = double(img(:,:,3));
patchsz = 5;
[m, n] = size(R);
% resize the input image to match the patch size
if mod(m, patchsz) ~= 0 || mod(n, patchsz) ~= 0
R = imresize(R, [m - mod(m, patchsz) + patchsz, ...
n - mod(n, patchsz) + patchsz]);
G = imresize(G, [m - mod(m, patchsz) + patchsz, ...
n - mod(n, patchsz) + patchsz]);
B = imresize(B, [m - mod(m, patchsz) + patchsz, ...
n - mod(n, patchsz) + patchsz]);
end
[m, n] = size(R);
k1 = m / patchsz;
k2 = n / patchsz;
AMEER = 0;
for i = 1 : patchsz : m
for j = 1 : patchsz : n
sz = patchsz - 1;
im = R(i:i+sz,j:j+sz);
Max = max(max(im));
Min = min(min(im));
if ( (Max ~= 0 || Min ~= 0) && Max ~= Min )
AMEER = AMEER + ...
log( (Max - Min) / (Max + Min) ) * ...
( (Max - Min) / (Max + Min) );
end
end
end
AMEER = 1 / (k1 * k2) * abs(AMEER);
AMEEG = 0;
for i = 1 : patchsz : m
for j = 1 : patchsz : n
sz = patchsz - 1;
im = G(i:i+sz,j:j+sz);
Max = max(max(im));
Min = min(min(im));
if ( (Max ~= 0 || Min ~= 0) && Max ~= Min )
AMEEG = AMEEG + ...
log( (Max - Min) / (Max + Min) ) * ...
( (Max - Min) / (Max + Min) );
end
end
end
AMEEG = 1 / (k1 * k2) * abs(AMEEG);
AMEEB = 0;
for i = 1 : patchsz : m
for j = 1 : patchsz : n
sz = patchsz - 1;
im = B(i:i+sz,j:j+sz);
Max = max(max(im));
Min = min(min(im));
if ( (Max ~= 0 || Min ~= 0) && Max ~= Min )
AMEEB = AMEEB + ...
log( (Max - Min) / (Max + Min) ) * ...
( (Max - Min) / (Max + Min) );
end
end
end
AMEEB = 1 / (k1 * k2) * abs(AMEEB);
uiconm = AMEER + AMEEG + AMEEB;
end