-
Notifications
You must be signed in to change notification settings - Fork 15
/
analysis_Qabf.m
103 lines (85 loc) · 2.79 KB
/
analysis_Qabf.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
% Objective Image Fusion Performance Measure
% C.S.Xydeas and V.Petrovic
% Electronics Letters
% edit by Richang Hong; May 27 07
function output = analysis_Qabf(pA, pB, pF)
% strA and strB is the source images and strF is the fusion result
% model parameters
L=1; Tg=0.9994;kg=-15;Dg=0.5;Ta=0.9879;ka=-22;Da=0.8;
% Sobel Operator
h1=[1 2 1;0 0 0;-1 -2 -1]; h2=[0 1 2;-1 0 1;-2 -1 0]; h3=[-1 0 1;-2 0 2;-1 0 1];
% if y is the response to h1 and x is the response to h3;
% then the intensity is sqrt(x^2+y^2) and orientation is arctan(y/x);
% pA = imread(strA); pA = double(pA);
% pB = imread(strB); pB = double(pB);
% pF = imread(strF); pF = double(pF);
SAx = conv2(pA,h3,'same'); SAy = conv2(pA,h1,'same');
gA = sqrt(SAx.^2 + SAy.^2);
[M,N] = size(SAx); aA = zeros(M,N);
for i=1:M
for j=1:N
if ( SAx(i,j) == 0 ) aA(i,j) = pi/2;
else
aA(i,j) = atan(SAy(i,j)/SAx(i,j));
end
end
end
SBx = conv2(pB,h3,'same'); SBy = conv2(pB,h1,'same');
gB = sqrt(SBx.^2 + SBy.^2);
[M,N] = size(SBx); aB = zeros(M,N);
for i=1:M
for j=1:N
if ( SBx(i,j) == 0 ) aB(i,j) = pi/2;
else
aB(i,j) = atan(SBy(i,j)/SBx(i,j));
end
end
end
SFx = conv2(pF,h3,'same'); SFy = conv2(pF,h1,'same');
gF = sqrt(SFx.^2 + SFy.^2);
[M,N] = size(SAx); aF = zeros(M,N);
for i=1:M
for j=1:N
if ( SFx(i,j) == 0 ) aF(i,j) = pi/2;
else
aF(i,j) = atan(SFy(i,j)/SFx(i,j));
end
end
end
% the relative strength and orientation value of GAF,GBF and AAF,ABF;
GAF = zeros(M,N); AAF = zeros(M,N); QgAF = zeros(M,N); QaAF = zeros(M,N); QAF = zeros(M,N);
for i=1:M
for j=1:N
if ( gA(i,j) > gF(i,j)) GAF(i,j) = gF(i,j)/gA(i,j);
else
if ( gA(i,j) == gF(i,j) ) GAF(i,j) = gF(i,j);
else
GAF(i,j) = gA(i,j) / gF(i,j);
end
end
AAF(i,j) = 1 - abs(aA(i,j)-aF(i,j))/(pi/2);
QgAF(i,j) = Tg / (1 + exp(kg*( GAF(i,j) - Dg )));
QaAF(i,j) = Ta / (1 + exp(ka*( AAF(i,j) - Da )));
QAF(i,j) = QgAF(i,j) * QaAF(i,j);
end
end
GBF = zeros(M,N); ABF = zeros(M,N); QgBF = zeros(M,N); QaBF = zeros(M,N); QBF = zeros(M,N);
for i=1:M
for j=1:N
if ( gB(i,j) > gF(i,j)) GBF(i,j) = gF(i,j)/gB(i,j);
else
if ( gB(i,j) == gF(i,j) ) GBF(i,j) = gF(i,j);
else
GBF(i,j) = gB(i,j) / gF(i,j);
end
end
ABF(i,j) = 1 - abs(aB(i,j)-aF(i,j))/(pi/2);
QgBF(i,j) = Tg / (1 + exp(kg*( GBF(i,j) - Dg )));
QaBF(i,j) = Ta / (1 + exp(ka*( ABF(i,j) - Da )));
QBF(i,j) = QgBF(i,j) * QaBF(i,j);
end
end
% compute the QABF
deno = sum(sum( gA + gB ));
nume = sum(sum( QAF.*gA + QBF.*gB ));
output = nume / deno;