close all;
clear all;
clc;
%%% Fusion Method Parameters.
cov_wsize=5;
%%% Bilateral Filter Parameters.
sigmas=1.8; %%% Spatial (Geometric) Sigma. 1.8
sigmar=25; %%% Range (Photometric/Radiometric) Sigma.25 256/10
ksize=11; %%% Kernal Size (should be odd).
arr=['A';'B'];
for m=1:2
string=arr(m);
% inp_image=strcat('images\med256',string,'.jpg');
inp_image=strcat('images\office256',string,'.tif');
% inp_image=strcat('images\gun',string,'.gif');
x{m}=imread(inp_image);
if(size(x{m},3)==3)
x{m}=rgb2gray(x{m});
end
end
[M,N]=size(x{m});
%%% Cross Bilateral Filter.
tic
cbf_out{1}=cross_bilateral_filt2Df(x{1},x{2},sigmas,sigmar,ksize);
detail{1}=double(x{1})-cbf_out{1};
cbf_out{2}= cross_bilateral_filt2Df(x{2},x{1},sigmas,sigmar,ksize);
detail{2}=double(x{2})-cbf_out{2};
%%% Fusion Rule (IEEE Conf 2011).
xfused=cbf_ieeeconf2011f(x,detail,cov_wsize);
toc
xfused8=uint8(xfused);
if(strncmp(inp_image,'gun',3))
figure,imagesc(x{1}),colormap gray
figure,imagesc(x{2}),colormap gray
figure,imagesc(xfused8),colormap gray
else
figure,subplot(131);imshow(x{1});title('图1')
subplot(132);imshow(x{2});title('图2')
subplot(133),imshow(xfused8) ;title('融合后')
end
% axis([140 239 70 169]) %%% Office.
fusion_perform_fn(xfused8,x);