Image 图像压缩MATLAB代码输出像素化图像?

Image 图像压缩MATLAB代码输出像素化图像?,image,matlab,compression,Image,Matlab,Compression,如果有人能指出我代码中的错误,我将不胜感激。我试图通过读取图像,执行DCT,量化,然后去量化,再执行逆DCT,对图像进行编码和解码。运行此代码后,输出图像I2有点像素化。我不知道如何修理它。输出应该与原始图像有点相似,但在经过压缩后会略微模糊。请帮忙!我的代码如下:- I = imread('cameraman.tif'); I = im2double(I); T = dctmtx(8); % dct matrix %Performing DCT on blocks of 8 by 8 dc

如果有人能指出我代码中的错误,我将不胜感激。我试图通过读取图像,执行DCT,量化,然后去量化,再执行逆DCT,对图像进行编码和解码。运行此代码后,输出图像I2有点像素化。我不知道如何修理它。输出应该与原始图像有点相似,但在经过压缩后会略微模糊。请帮忙!我的代码如下:-

I = imread('cameraman.tif');
 I = im2double(I);
T = dctmtx(8); % dct matrix

%Performing DCT on blocks of 8 by 8
dct = @(block_struct) T * block_struct.data * T';
B = blockproc(I,[8 8],dct);

B = ceil(B); 

% A Standard Quantization Matrix
q_mtx =     [16 11 10 16 24 40 51 61; 
            12 12 14 19 26 58 60 55;
            14 13 16 24 40 57 69 56; 
            14 17 22 29 51 87 80 62;
            18 22 37 56 68 109 103 77;
            24 35 55 64 81 104 113 92;
            49 64 78 87 103 121 120 101;
            72 92 95 98 112 100 103 99];

 %PErforming Quantization by Dividing with q_mtx on blocks of 8 by 8
 c = @(block_struct) (block_struct.data) ./ q_mtx;        
 B2 = blockproc(B,[8 8],c);
%    B2 = ceil(B2)

%Performing Inverse Quantization By Multiplying with q_mtx on Blocks of 8
%by 8
B3 = blockproc(B2,[8 8],@(block_struct) q_mtx .* block_struct.data);

%Performing Inverse DCT on Blocks of 8 by 8
invdct = @(block_struct) T' * block_struct.data * T;
% B3 = ceil(B3);
I2 = blockproc(B3,[8 8],invdct);
imshow(I), figure, imshow(I2)