图像拉普拉斯金字塔(laplacian pyramid)并从金字塔重建原图 matlab程序实现

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/majinlei121/article/details/50706125
<span style="font-size:18px;">clear
inputPath ='D:\数字图像处理\研究方向\Filter Smooth\images\';
filename = [inputPath 'pai.png'];
I = im2double(imread(filename));
if size(I,3)==3
    I=rgb2gray(I);
end

nlev=4;
sigma=1;
sigma_r=0.1;

f = [.05, .25, .4, .25, .05];
f = f'*f;

%构建拉普拉斯金字塔
pyr = cell(nlev,1);
J = I;
for l = 1:nlev-1   
    J_gauss = imfilter(J,f,'replicate');
    J_gauss_down = J_gauss(1:2:size(J_gauss,1)-1,1:2:size(J_gauss,2)-1); %downsample 
    J_gauss_high = imresize(J_gauss_down,[size(J_gauss,1) size(J_gauss,2)],'bilinear');
    pyr{l} = J-J_gauss_high;
    J=J_gauss_down;
end
pyr{nlev}=J_gauss_down;

% for i=1:length(pyr)
%     figure;imshow(mat2gray(pyr{i}));
% end

%从金字塔重建图像
out = pyr{nlev};
for l = nlev-1 : -1 : 1
    out = pyr{l} + imresize(out,[size(pyr{l},1) size(pyr{l},2)],'bilinear');
end

figure;imshow([mat2gray(out),I]);title('重建之后图像,原图');
% figure;imshow(I);</span>

下面是运行效果:


展开阅读全文

没有更多推荐了,返回首页