码迷,mamicode.com
首页 > 其他好文 > 详细

IMAGE FUSION USING LAPLACIAN PYRAMID

时间:2014-12-11 22:05:17      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   for   

拉普拉斯金字塔也可以用于融合图像,具体运行结果和图像如下:

原图像:

bubuko.com,布布扣  bubuko.com,布布扣

融合后图像:

bubuko.com,布布扣

代码如下:

%清屏
clear all; 
close all; 
clc;

%读取图像及尺寸
fimg=double(imread(1807i_12.bmp));
simg=double(imread(1807v_12.bmp));
[fm,fn]=size(fimg);[sm,sn]=size(simg);

%高斯滤波器
w=1/8*[0,1,0;1,4,1;0,1,0];

fimgn{1}=fimg;
%滤波,下采样
for i=2:5                  
   fimgn{i}=imfilter(fimgn{i-1},w,replicate);
   fimgn{i}=fimgn{i}(1:2:size(fimgn{i},1)-1,1:2:size(fimgn{i},2)-1); %i-1级近似
%    figure;
%    imshow(uint8(fimgn{i}));
%    imwrite(uint8(fimgn{i}),strcat(fimg_,num2str(i-1),.bmp));
end
for i=5:-1:2        %调整图像大小
   fimgn{i-1}=fimgn{i-1}(1:2*size(fimgn{i},1),1:2*size(fimgn{i},2)); 
end

simgn{1}=simg;
%滤波,下采样
for i=2:5                  
   simgn{i}=imfilter(simgn{i-1},w,replicate);
   simgn{i}=simgn{i}(1:2:size(simgn{i},1)-1,1:2:size(simgn{i},2)-1); %i-1级近似
%    figure;
%    imshow(uint8(simgn{i}));
%    imwrite(uint8(simgn{i}),strcat(simg_,num2str(i-1),.bmp));
end
for i=5:-1:2        %调整图像大小
   simgn{i-1}=simgn{i-1}(1:2*size(simgn{i},1),1:2*size(simgn{i},2)); 
end

for i=1:5
    averimgn{i}=(1/2)*(fimgn{i}+simgn{i});
%     figure;
%     imshow(uint8(averimgn{i}));
%     imwrite(uint8(averimgn{i}),strcat(averimg_,num2str(i-1),.bmp));
end

 for i=1:4          %获得残差图像,i级预测残差
    averimgn{i}=averimgn{i}-pyexpand(averimgn{i+1},w);    
 end
 
 for i=4:-1:1        %残差图像重构原图像
    averimgn{i}=averimgn{i}+pyexpand(averimgn{i+1},w);
%     figure;
%     imshow(uint8(averimgn{i}));
%     imwrite(uint8(averimgn{i}),strcat(averimg_,num2str(i-1),.bmp));
 end
 
 figure;
 imshow(uint8(averimgn{1}));
 imwrite(uint8(averimgn{1}),strcat(averimg.jpg));

 

IMAGE FUSION USING LAPLACIAN PYRAMID

标签:style   blog   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/boycebai/p/4158472.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!