-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.m
56 lines (43 loc) · 1.09 KB
/
script.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
% ----------
% Author: Wei Tan
% E-mail: twtanwei1992@163.com
% Wei Tan, Huixin Zhou, Shenghui Rong, Kun Qian, and Yue Yu, "Fusion of
% multi-focus images via a Gaussian curvature filter and synthetic focusing
% degree criterion", Applied Optics, 2018, Vol. 57, No.35, pp. 10092-10101.
% This code is only used for research.
% Please cite this publication if you use this code.
clc;
clear all;
close all;
path(path,'CF')
I1 = imread('lab1.tif');
I1 = im2double(I1);
I2 = imread('lab2.tif');
I2 = im2double(I2);
[m,n] = size(I1);
S1 = FeatExt(I1);
S2 = FeatExt(I2);
VOI1 = VOIA(S1,1);
VOI2 = VOIA(S2,1);
SF1 = SpatialFrequencyA(S1,1);
SF2 = SpatialFrequencyA(S2,1);
D1 = zeros(m,n);
for i = 1:m
for j = 1:n
if (SF1(i,j)>SF2(i,j) && VOI1(i,j)>VOI2(i,j))
D1(i,j) = 1;
else
D1(i,j) = 0;
end
end
end
OM = OptFusMat(D1);
win_size = 10;
W = guided_filter(OM,I1,0.1,win_size);
F = zeros(m,n);
for i = 1:m
for j = 1:n
F(i,j) = W(i,j)*I1(i,j)+(1-W(i,j))*I2(i,j);
end
end
figure,imshow(F);