小波变换(matlab)
%小波变换和重构的matlab代码
clear;
close all;
img = rgb2gray(imread(‘E:\算法源码\代码实现\Peppers.jpg’));
figure(7);
imshow(img);
% 对图像进行2层的小波分解
N = 2; % 设置分解层数
[c,s] = wavedec2(img,N,‘db1’);
% 提取1层低频分量
A = uint8(appcoef2(c,s,‘db1’,1));
figure(4);
imshow(A);
%提取1层高频分量
D1 = uint8(detcoef2(‘h’,c,s,1));
figure(5);
imshow(D1);
% 对各层的近似图像进行重构
a0 = uint8(wrcoef2(‘all’,c,s,‘db1’,0));
figure(11);
imshow(a0);%对第0层重构即显示原图
a1 = uint8(wrcoef2(‘all’,c,s,‘db1’,1));
figure(1);
imshow(a1);
a2 = uint8(wrcoef2(‘all’,c,s,‘db1’,2));
figure(2);
imshow(a2);
a3 = uint8(wrcoef2(‘all’,c,s,‘db1’,3));
figure(3);
imshow(a3);