提升小波变换的程序演示
本文分别从数列和图像的角度来演示小波处理、逆处理的结果。
1、数列演示
clc
clearvars;
% 示例使用:
% 给定一个序列
% x = [10, 15, 20, 25, 30, 35, 40, 45];
x = randi([0,255],1,10);% 执行提升小波变换
[s, d] = lifting_scheme(x);% s=mod(s,256);
% d=mod(d,256);% 执行逆提升小波变换
x_reconstructed = inverse_lifting_scheme(s, d);
% x_reconstructed=mod(x_reconstructed,256);% 输出原序列和重建序列
disp('原序列:');
disp(x);
disp('构建的s:');
disp(s);disp('构建的d:');
disp(d);
disp('重建序列:');
disp(x_reconstructed);disp('原始序列和重建序列:');
if isequal(x,x_reconstructed) disp('相等');
elsedisp('不相等');
endfunction [s, d] = lifting_scheme(x)
% 提升小波分解
% 输入序列 x 应为偶数长度
% 输出 s 为近似系数序列,d 为细节系数序列% 分裂步骤
e = x(1:2:end);
o = x(2:2:end);% 预测步骤
d = o - floor((e + circshift(e, -1)) / 2);% 更新步骤
s = e + floor((circshift(d, 1) + d) / 4);
endfunction [x] = inverse_lifting_sc