压缩感知——沃尔什-哈达玛(WHT)变换与逆变换的Matlab代码实现

最后更新于:2022-04-01 14:29:44

沃尔什-哈达玛变换(Walsh-Hadmard Transform,WHT),是一种典型的非正弦函数变换,采用正交直角函数作为基函数,具有与傅里叶函数类似的性质,图像数据越是均匀分布,经过沃尔什-哈达玛变换后的数据越是集中于矩阵的边角上,因此沃尔什变换具有能量集中的性质,可以用于压缩图像信息。 Matlab中的Hadamard函数: 格式:H=hadamard( n ) ,返回一个 n * n的hadamard矩阵。 ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_57061791be1a2.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_57061791d2ed3.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_57061791e7388.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_57061792074e2.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_570617921c5b7.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_570617922df2c.jpg) ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_5706179241612.jpg) 下面对lena图像进行沃尔什-哈达玛变换与逆变换的Matlab实现: ~~~ clc; clear all; im_l=imread('C:\Users\DELL\Desktop\lena.jpg'); im_l1=im2double(im_l); im_l2=rgb2gray(im_l1); %对图像进行哈达玛变换 H=hadamard(512);%产生512X512的Hadamard矩阵 haImg=H*im_l2*H; haImg2=haImg/512; %对图像进行哈达玛逆变换 hhaImg=H'*haImg2*H'; hhaImg2=hhaImg/512; haImg1=im2uint8(haImg); hhaImg1=im2uint8(hhaImg2); subplot(2,2,1); imshow(im_l); title('原图'); subplot(2,2,2); imshow(im_l2); title('灰度图'); subplot(2,2,3); imshow(haImg2); title('图像的二维离散Hadamard变换'); subplot(2,2,4); imshow(hhaImg1); title('图像的二维离散Hadamard逆变换'); ~~~ ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-07_5706179256f45.jpg)
';