把红外光和可见光两个图像通过M通道过采样滤波器组分解为低频子带和高频子带 再通过双边滤波器进行融合 matlab
时间: 2024-06-04 16:11:56 浏览: 143
代码如下:
% 读取红外光和可见光图像
irImage = imread('ir_image.jpg');
visImage = imread('vis_image.jpg');
% 定义M通道过采样滤波器组
M = 3;
filterBank = cell(M, 1);
for i = 1:M
filterBank{i} = fspecial('gaussian', [5 5], i);
end
% 将红外光和可见光图像分解为低频子带和高频子带
irPyramid = cell(M, 1);
visPyramid = cell(M, 1);
for i = 1:M
irPyramid{i} = imfilter(imresize(irImage, 1/i), filterBank{i}, 'replicate');
visPyramid{i} = imfilter(imresize(visImage, 1/i), filterBank{i}, 'replicate');
end
% 定义双边滤波器参数
sigmaRange = [0.1 0.1 0.1]; % 色彩空间的标准差
sigmaSpatial = [5 5 5]; % 空间域的标准差
% 融合低频子带
fusedLow = cell(M, 1);
for i = 1:M
fusedLow{i} = bfltmerge(visPyramid{i}, irPyramid{i}, sigmaRange, sigmaSpatial);
end
% 融合高频子带
fusedHigh = cell(M, 1);
for i = 1:M
highVis = visPyramid{i} - imresize(imfilter(imresize(visPyramid{i}, i), filterBank{i}, 'replicate'), size(visPyramid{i}));
highIr = irPyramid{i} - imresize(imfilter(imresize(irPyramid{i}, i), filterBank{i}, 'replicate'), size(irPyramid{i}));
highFused = bfltmerge(highVis, highIr, sigmaRange, sigmaSpatial);
fusedHigh{i} = highFused + imresize(imfilter(imresize(fusedLow{i}, i), filterBank{i}, 'replicate'), size(highFused));
end
% 重建融合后的图像
fusedImage = fusedHigh{M};
for i = M-1:-1:1
fusedImage = imresize(fusedImage, size(fusedHigh{i})) + fusedHigh{i};
end
% 显示结果
figure;
subplot(2, 2, 1);
imshow(irImage);
title('红外光图像');
subplot(2, 2, 2);
imshow(visImage);
title('可见光图像');
subplot(2, 2, 3);
imshow(fusedImage);
title('融合后图像');
阅读全文