Matlab中的图像处理:图像压缩Hadamard Transorm

时间:2018-01-23 04:54:07

标签: image matlab

嗨我想用变量N实现基于块的Hadamard变换进行图像压缩:块数和可变消除百分比 这在我的代码中,但它没有正常工作:

img=imread('cameraman.tif');
N = input('Please Inter Size Of Block: ');
E = input('Please Inter Elimination of Coefficient Percentage:');
E=100-E;
E=round(100/E);
S=round(N/E);
m=log2(N);
I = im2double(img);
T = (1/(2^m))*hadamard(N);
wht = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[N N],wht);
mask = [ones(S,S) , zeros(S,N-S); zeros((N-S),N)];
B2 = blockproc(B,[N N],@(block_struct) mask .* block_struct.data);
invwht = @(block_struct) T' * block_struct.data * T;
I2 = blockproc(B2,[N N],invwht);
imshow(I)
figure
imshow(I2)

0 个答案:

没有答案