如何在matlab中获得图像的Hadamard变换

时间:2015-04-23 23:07:07

标签: matlab

我有一个128x128的grascale图像,我希望找到具有Normal Hadamard,顺序和二元排序的Hadamard变换。

imdata = imread('origim.png'); %Load image
new = rgb2gray(imdata); %Convert to 2D Grayscale

N = 128;
H = hadamard(N);                      % Hadamard matrix
y = fwht(new,N,'sequency') %Perform Fast-walsh-hadamard-transform with order 128
imshow(y); %Display image transform

我可能做错了,但如果我正确理解matlab walch变换,那么y应该是变换后的图像。当我尝试运行它时,我收到y = fwht(new,N,'sequency')

的错误

1 个答案:

答案 0 :(得分:0)

在处理之前将图像转换为double。然后在y = fwht(new,N,'sequency')的末尾加上分号(;)。然后你会得到转换后的形象。 试试下面的代码。

imdata = imread('peppers.png'); %Load image
new = rgb2gray(imdata); %Convert to 2D Grayscale
neww = im2double(new);
N = 128;
H = hadamard(N);                      % Hadamard matrix
y = fwht(neww,N,'sequency'); %Perform Fast-walsh-hadamard-transform with order 128
imshow(y); %Display image transform