基于DCT的JPEG图像压缩编码算法的MATLAB实现
- 格式:pdf
- 大小:197.65 KB
- 文档页数:4
function jpeg %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% THIS WORK IS SUBMITTED BY:%%%% OHAD GAL%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%close all;% ==================% section 1.2 + 1.3% ==================% the following use of the function:%% plot_bases( base_size,resolution,plot_type )%% will plot the 64 wanted bases. I will use "zero-padding" forincreased resolution% NOTE THAT THESE ARE THE SAME BASES !% for reference I plot the following 3 graphs:% a) 3D plot with basic resolution (64 plots of 8x8 pixels) using "surf" function% b) 3D plot with x20 resolution (64 plots of 160x160 pixels) using "mesh" function% c) 2D plot with x10 resolution (64 plots of 80x80 pixels) using "mesh" function% d) 2D plot with x10 resolution (64 plots of 80x80 pixels) using "imshow" function%% NOTE: matrix size of pictures (b),(c) and (d), can support higher frequency = higher bases% but I am not asked to draw these (higher bases) in this section ! % the zero padding is used ONLY for resolution increase !%% get all base pictures (3D surface figure)plot_bases( 8,1,'surf3d' );% get all base pictures (3D surface figure), x20 resolutionplot_bases( 8,20,'mesh3d' );% get all base pictures (2D mesh figure), x10 resolutionplot_bases( 8,10,'mesh2d' );% get all base pictures (2D mesh figure), x10 resolutionplot_bases( 8,10,'gray2d' );% ==================% section 1.4 + 1.5% ==================% for each picture {'0'..'9'} perform a 2 dimensional dct on 8x8 blocks.% save the dct inside a cell of the size: 10 cells of 128x128 matrix% show for each picture, it's dct 8x8 block transform.for idx = 0:9% load a pictureswitch idxcase {0,1}, input_image_128x128 =im2double( imread( sprintf( '%d.tif',idx ),'tiff' ) );otherwise, input_image_128x128 =im2double( imread( sprintf( '%d.tif',idx),'jpeg' ) );end% perform DCT in 2 dimension over blocks of 8x8 in the given picture dct_8x8_image_of_128x128{idx+1} =image_8x8_block_dct( input_image_128x128 );if (mod(idx,2)==0)figure;endsubplot(2,2,mod(idx,2)*2+1);imshow(input_image_128x128);title( sprintf('image #%d',idx) );subplot(2,2,mod(idx,2)*2+2);imshow(dct_8x8_image_of_128x128{idx+1});title( sprintf('8x8 DCT of image #%d',idx) );end% ==================% section 1.6% ==================% do statistics on the cell array of the dct transforms% create a matrix of 8x8 that will describe the value of each "dct-base"% over the transform of the 10 given pictures. since some of the values are% negative, and we are interested in the energy of the coefficients, we will% add the abs()^2 values into the matrix.% this is consistent with the definition of the "Parseval relation" in Fourier Coefficients% initialize the "average" matrixmean_matrix_8x8 = zeros( 8,8 );% loop over all the picturesfor idx = 1:10% in each picture loop over 8x8 elements (128x128 = 256 * 8x8 elements)for m = 0:15for n = 0:15mean_matrix_8x8 = mean_matrix_8x8 + ...abs( dct_8x8_image_of_128x128{idx}(m*8+[1:8],n*8+[1:8]) ).^2;endendend% transpose the matrix since the order of the matrix is elements along the columns,% while in the subplot function the order is of elements along the rows mean_matrix_8x8_transposed = mean_matrix_8x8';% make the mean matrix (8x8) into a vector (64x1)mean_vector = mean_matrix_8x8_transposed(:);% sort the vector (from small to big)[sorted_mean_vector,original_indices] = sort( mean_vector );% reverse order (from big to small)sorted_mean_vector = sorted_mean_vector(end:-1:1);original_indices = original_indices(end:-1:1);% plot the corresponding matrix as asked in section 1.6figure;for idx = 1:64subplot(8,8,original_indices(idx));axis off;h = text(0,0,sprintf('%4d',idx));set(h,'FontWeight','bold');text(0,0,sprintf('\n_{%1.1fdb}',20*log10(sorted_mean_vector(idx)) ));end% add a title to the figuresubplot(8,8,4);h = title( 'Power of DCT coefficients (section 1.6)' );set( h,'FontWeight','bold' );% ==================% section 1.8% ==================% picture 8 is chosen% In this section I will calculate the SNR of a compressed image againts% the level of compression. the SNR calculation is defined in the header% of the function: <<calc_snr>> which is given below.%% if we decide to take 10 coefficients with the most energy, we will% zeros to the other coefficients and remain with a vector 64 elements long% (or a matrix of 8x8)% load the original imageoriginal_image = im2double( imread( '8.tif','jpeg' ) );% I will use this matrix to choose only the wanted number ofcoefficients% the matrix is initialized to zeros -> don't choose any coefficient at allcoef_selection_matrix = zeros(8,8);% compressed picture set (to show the degrading)compressed_set = [1 3 5 10 15 20 30 40];% this loop will choose each time, the "next-most-energetic"coefficient,% to be added to the compressed image -> and thus to improove the SNRfor number_of_coefficient = 1:64% find the most energetic coefficient from the mean_matrix[y,x] = find(mean_matrix_8x8==max(max(mean_matrix_8x8)));% select if for the compressed imagecoef_selection_matrix(y,x) = 1;% replicate the selection matrix for all the parts of the dct transform% (remember that the DCT transform creates a set of 8x8 matrices, where% in each matrix I need to choose the coefficients defined by the % <<coef_selection_matrix>> matrix )selection_matrix = repmat( coef_selection_matrix,16,16 );% set it as zero in the mean_matrix, so that in the next loop, we will% choose the "next-most-energetic" coefficientmean_matrix_8x8(y,x) = 0;% choose the most energetic coefficients from the original image% (total of <<number_of_coefficient>> coefficients for this run in the loop)compressed_image = image_8x8_block_dct(original_image) .*selection_matrix;% restore the compressed image from the given set of coeficientsrestored_image = image_8x8_block_inv_dct( compressed_image );% calculate the snr of this image (based on the original image)SNR(number_of_coefficient) =calc_snr( original_image,restored_image );if ~isempty(find(number_of_coefficient==compressed_set))if (number_of_coefficient==1)figure;subplot(3,3,1);imshow( original_image );title( 'original image' );endsubplot(3,3,find(number_of_coefficient==compressed_set)+1);imshow( restored_image );title( sprintf('restored image with %dcoeffs',number_of_coefficient) );endend% plot the SNR graphfigure;plot( [1:64],20*log10(SNR) );xlabel( 'numer of coefficients taken for compression' );ylabel( 'SNR [db] ( 20*log10(.) )' );title( 'SNR graph for picture number 8, section 1.8' );grid on; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%% --------------------------------------------------------------------------------%% I N N E R F U N C T I O N I M P L E M E N T A T I O N%% --------------------------------------------------------------------------------%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%% ---------------------------------------------------------------------------------% pdip_dct2 - implementation of a 2 Dimensional DCT%% assumption: input matrix is a square matrix !% ---------------------------------------------------------------------------------function out = pdip_dct2( in )% get input matrix sizeN = size(in,1);% build the matrixn = 0:N-1;for k = 0:N-1if (k>0)C(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N)*sqrt(2);elseC(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N);endendout = C*in*(C');% ---------------------------------------------------------------------------------% pdip_inv_dct2 - implementation of an inverse 2 Dimensional DCT%% assumption: input matrix is a square matrix !% ---------------------------------------------------------------------------------function out = pdip_inv_dct2( in )% get input matrix sizeN = size(in,1);% build the matrixn = 0:N-1;for k = 0:N-1if (k>0)C(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N)*sqrt(2);elseC(k+1,n+1) = cos(pi*(2*n+1)*k/2/N)/sqrt(N);endendout = (C')*in*C;% ---------------------------------------------------------------------------------% plot_bases - use the inverse DCT in 2 dimensions to plot the base pictures%% Note: we can get resolution be zero pading of the input matrix% that is by calling: in = zeros(base_size*resolution)% where: resolution is an integer > 1% So I will use zero pading for resolution (same as in the fourier theory)% instead of linear interpolation.% ---------------------------------------------------------------------------------function plot_bases( base_size,resolution,plot_type )figure;for k = 1:base_sizefor l = 1:base_sizein = zeros(base_size*resolution);in(k,l) = 1; % "ask" for the "base-harmonic (k,l)"subplot( base_size,base_size,(k-1)*base_size+l );switch lower(plot_type)case'surf3d', surf( pdip_inv_dct2( in ) );case'mesh3d', mesh( pdip_inv_dct2( in ) );case'mesh2d', mesh( pdip_inv_dct2( in ) ); view(0,90);case'gray2d', imshow( 256*pdip_inv_dct2( in ) );endaxis off;end% add a title to the figuresubplot(base_size,base_size,round(base_size/2));h = title( 'Bases of the DCT transform (section 1.3)' );set( h,'FontWeight','bold' );% ---------------------------------------------------------------------------------% image_8x8_block_dct - perform a block DCT for an image% ---------------------------------------------------------------------------------function transform_image = image_8x8_block_dct( input_image )transform_image = zeros( size( input_image,1 ),size( input_image,2 ) ); for m = 0:15for n = 0:15transform_image( m*8+[1:8],n*8+[1:8] ) = ...pdip_dct2( input_image( m*8+[1:8],n*8+[1:8] ) );endend% ---------------------------------------------------------------------------------% image_8x8_block_inv_dct - perform a block inverse DCT for an image% ---------------------------------------------------------------------------------function restored_image = image_8x8_block_inv_dct( transform_image ) restored_image =zeros( size( transform_image,1 ),size( transform_image,2 ) );for m = 0:15for n = 0:15restored_image( m*8+[1:8],n*8+[1:8] ) = ...pdip_inv_dct2( transform_image( m*8+[1:8],n*8+[1:8] ) );endend% ---------------------------------------------------------------------------------% calc_snr - calculates the snr of a figure being compressed%% assumption: SNR calculation is done in the following manner:% the deviation from the original image is considered% to be the noise therefore:%% noise = original_image - compressed_image%% the SNR is defined as:%% SNR = energy_of_image/energy_of_noise%% which yields:% SNR = energy_of_image/((original_image-compressed_image)^2)% ---------------------------------------------------------------------------------function SNR = calc_snr( original_image,noisy_image )original_image_energy = sum( original_image(:).^2 );noise_energy = sum( (original_image(:)-noisy_image(:)).^2 );SNR = original_image_energy/noise_energy;以下是1-9号原图像,放到matlab的.m文件目录里,重命名9个图像名为1、2、3、4、5、6、7、8、9。
实验一 图像DCT 变换一、实验目的1.了解DCT 处理图像的基本知识;2.掌握用matlab 将对图像进行DCT 变换。
二、实验内容1.对图像进行DCT 处理;2.显示变换后的图像的三维的频谱; 3.对matlab 代码进行一定的文字说明;三、实验原理离散余弦变换(Discrete Cosine Transform ,DCT )是一种实数域变换,其变换核为实数余弦函数。
对一幅图像进行离散余弦变换后,许多有关图像的重要可视信息都集中在DCT 变换的一小部分系数中。
因此,离散余弦变换(DCT )是有损图像压缩JPEG 的核心,同时也是所谓“变换域信息隐藏算法”的主要“变换域(DCT 域)”之一。
因为图像处理运用二维离散余弦变换,所以直接介绍二维DCT 变换。
一个矩阵的二维DCT 定义如下:首先将输入图像分解为8*8或16*16块,然后再对每个图像块进行二维DCT 变换,接着再对DCT 系数进行量化、编码和传输;接收者通过对量化的DCT 系数进行解码,并对每个图像块进行的二维DCT 反变换。
最后将操作完成后所有的块拼接起来构成一幅单一的图像。
对于一般的图像而言,大多数DCT 系数值都接近于0,所以去掉这些系数不会对重建图像的质量产生较大影响。
因此,利用DCT 进行图像压缩确实可以节约大量的存储空间。
在实验中,先将输入的原始图像分为8*8块,然后再对每个块进行二维DCT 变换。
MATLAB 图像处理上具箱中提供的二维DCT 变换及DCT 反变换函数如下。
基于DCT 的JPEG 图像压缩编码理论算法过程框图如下:上图是基于DCT 变换的图像压缩编码的压缩过程,解压缩与上图的过程相反。
四、实验代码及结果close all;原始图像数据分成8*8的小块DCT 变换 量化器量化表熵编码器 码表压缩数据I=imread('222.jpg'); %读入原图像文件I=rgb2gray(I);%将原图像转换成灰色图像I1=dct2(I);%对原图像进行二维DCT变换fs=fftshift(I1);%将直流分量移到频谱中心subplot(121);imshow(I);title('灰色图像');%显示灰色图像subplot(122);imshow(log(abs(I1)),[]),colorbar;title('图像经DCT变换后能量分布情况') %显示经过dct变换后能量分布;figure(2);mesh(fs);title('三维频谱');%显示三维频谱五、实验结果分析图像经DCT变换后能量主要分布在左上角,右下角能量分布较低。
基于二维DCT的图像压缩编码及其实现作者:李春霞来源:《现代电子技术》2008年第16期摘要:DCT变换是图像压缩的一项重要技术,如何准确、快速进行图像压缩一直是国内外研究的热点。
主要介绍基于DCT变换的图像压缩编码算法,给出具体的实现方法和步骤,并用Matlab进行了算法仿真。
实验结果表明,该算法实现简单,在很大压缩范围内,都能得到很好的重建图像质量,满足不同场合要求不同图像质量的实际需要。
这里利用Matlab做仿真实验,方法简单、速度快且误差小,大大提高了图像压缩的效率和精度。
关键词:图像压缩;DCT变换;Matlab仿真;峰值信噪比中图分类号:TP391 文献标识码:B 文章编号:1004373X(2008)1615703Image Compression Coding and Implementation Based on 2DDCTLI Chunxia(College of Electric and Information Engineering,Shaanxi University of Science & Technology,Xi′an,710021,China)Abstract:The DCT transform is an important technique in the field of image compression.How to compress the image accurately and fast has been a research focus both at home and abroad all the time.This paper mainly introduces the algorithm of the image compress coding based on DCT,and shows details of realization.Then the algorithm is simulated by Matlab.Simulation experiments show that the algorithm is simple to realize.The reconstructed images are of good quality satisfying the demands of different image quality on various occasions under the circumstances of very large compression range.The innovation spot of this paper is that the method doing experiments with Matlab is simple,rapid and with little error.It can improve the efficiency and precision of the image compression greatly.Keywords:image compression;DCT transform;Matlab simulation;peak signal to noise ratio在信息世界迅猛发展的今天,图像传输已成为一项重要内容,而传输信息量的大小是影响传输速度的重要因素之一。
MATLAB中的图像压缩和编码方法图像压缩和编码是数字图像处理的重要领域,在各种图像应用中起着至关重要的作用。
在本文中,我们将探讨MATLAB中的图像压缩和编码方法,包括无损压缩和有损压缩,并介绍其中的一些经典算法和技术。
一、图像压缩和编码概述图像压缩是指通过一定的算法和技术来减少图像数据的存储量或传输带宽,以达到节约存储空间和提高传输效率的目的。
而图像编码则是将原始图像数据转换为一系列二进制编码的过程,以便存储或传输。
图像压缩和编码通常可以分为无损压缩和有损压缩两种方法。
无损压缩是指压缩后的数据可以完全还原为原始图像数据,不会引入任何失真或变化。
常见的无损压缩算法有Run-Length Encoding (RLE)、Lempel-Ziv-Welch (LZW)、Huffman编码等。
这些算法通常针对图像中的冗余数据进行编码,如重复的像素值或相似的图像区域。
有损压缩则是在保证一定程度的视觉质量下,通过舍弃或近似原始图像数据来减小存储或传输的数据量。
常见的有损压缩算法有JPEG、JPEG2000、GIF等。
这些算法通过离散余弦变换(DCT)、小波变换或颜色量化等方法,将图像数据转换为频域或颜色空间的系数,并通过量化、编码和压缩等步骤来减小数据量。
二、无损压缩方法1. Run-Length Encoding (RLE)RLE是一种简单高效的无损压缩算法,通过计算连续重复像素值的数量来减小数据量。
在MATLAB中,可以使用`rle`函数实现RLE编码和解码。
例如,对于一幅图像,可以将连续的像素值(如白色)编码为重复的个数,然后在解码时根据重复的个数恢复原始像素值。
2. Lempel-Ziv-Welch (LZW)LZW是一种字典压缩算法,通过将图像中连续的像素序列映射为一个短代码来减小数据量。
在MATLAB中,可以使用`lzwencode`和`lzwdecode`函数实现LZW 编码和解码。
例如,对于一段连续的像素序列,可以将其映射为一个短代码,然后在解码时根据代码恢复原始像素序列。
实验作业7分别用区域编码和阈值编码方法实现图像压缩,用8×8DCT变换,保留50%的大系数,并对解码图像进行比较。
要求:DCT要自己实现,不能用matlab中的DCT函数区域编码程序代码:clear;I=imread('d:\3.jpg');I=double(rgb2gray(I));figure(1);imshow(uint8(I));title('原图像');Y=zeros(8,8);for i=1:8for j=1:8if i==1Y(i,j)=sqrt(1/8);elseY(i,j)=sqrt(2/8)*cos((pi*(2*(j-1)+1)*(i-1))/16);endendends=blkproc(I,[8 8],'P1*x*P2',Y,Y'); figure(2);imshow(uint8(s));for j=1:8for i=1:8if j<=8-i+1a(i,j)=1;elsea(i,j)=0;end;end;end;s=blkproc(s,[8 8],'P1.*x',a); figure(3);imshow(uint8(s));s=blkproc(s,[8 8],'P1*x*P2',Y',Y); figure(4);imshow(uint8(s));title('经过压缩处理的图像')运行结果:阈值编码程序代码clear;I=imread('d:\3.jpg'); I=rgb2gray(I); imshow(uint8(I)); title('原图像'); I=double(I); for i=1:8 for j=1:8 if (i==1)Y(i,j)=sqrt(1/8); elseY(i,j)=sqrt(2/8)*cos((i-1)*(2*j-1)*pi/(2*8)); end; end; end; s=blkproc(I,[8 8],'P1*x*P2',Y,Y'); a=ones(8,8); b=reshape(Y,1,64); midvalue=median(b); for i=1:8 for j=1:8if(abs(Y(i,j))<midvalue) a(i,j)=0; end; end; end;s=blkproc(s,[8 8],'P1.*x',a); s=blkproc(s,[8 8],'P1*x*P2',Y',Y); figure(2); imshow(uint8(s));title('被与之编码方式压缩的图像');运行结果:心得体会:由于第八章内容上课听的不是很明白,所以作业题拿到之后不知道怎么做,重新把第八章看了一遍,可是很多地方看了好久好多次还是不明白其原理,就像这次所涉及的DCT (虽然会做作业,但是实在是不理解),区域编码,门限编码,都是不明白什么意思!后来网上搜罗资料,看了颇久,请教了同学,才慢慢知道是什么一回事,做这题目的时候,遇到过不知道怎么分块的问题,后来也是同学告诉有个blkproc 的函数可以用,才使到程序精简化。
如何使用Matlab进行图像压缩和图像恢复技术实现图像压缩和图像恢复技术在数字图像处理领域中起着至关重要的作用。
随着数字图像的广泛应用,图像压缩已经成为了一种必要的手段。
而图像恢复技术则可以使压缩后的图像更好地还原,提高图像质量。
本文将介绍如何使用Matlab进行图像压缩和图像恢复技术的实现。
首先,我们需要了解图像压缩的基本原理。
图像压缩通常包括有损压缩和无损压缩两种方式。
有损压缩是指在压缩图像的过程中会有一定的信息损失,而无损压缩则是保证图像质量不受损失的压缩方式。
在Matlab中,我们可以使用多种算法实现图像压缩。
其中,最常用的算法是基于离散余弦变换(DCT)的JPEG压缩算法。
JPEG算法的基本思想是将图像分成若干个8x8的小块,然后对每个小块进行DCT变换,再对变换后的系数进行量化,最后采用熵编码的方式进行压缩。
具体操作如下:1. 将彩色图像转换为灰度图像:在Matlab中,可以使用rgb2gray函数将彩色图像转换为灰度图像。
2. 将图像分成若干个8x8的小块:可以使用im2col函数将图像转换为列,然后使用reshape函数将列重新组合成8x8的小块。
3. 对每个小块进行DCT变换:可以使用dct2函数对每个小块进行DCT变换。
4. 对变换后的系数进行量化:将变换后的系数除以一个预定义的量化矩阵,然后四舍五入取整。
5. 采用熵编码进行压缩:根据量化后的系数,使用Huffman编码或算术编码等方法进行压缩。
在实际应用中,我们还可以对JPEG算法进行一些改进,以提高压缩效果。
例如,可以根据图像内容的特点对量化矩阵进行优化,可以使用小波变换代替DCT变换等。
接下来,我们将介绍如何使用Matlab进行图像的恢复。
图像恢复通常包括去噪和超分辨率重建两个步骤。
对于图像去噪,Matlab提供了多种滤波器和去噪算法,例如中值滤波、均值滤波、小波去噪等。
我们可以使用这些工具对图像进行去噪处理。
对于图像的超分辨率重建,Matlab中有多种算法可供选择,例如插值法、边缘增强法、小波插值法等。
在Matlab中进行图像压缩与图像解密的方法与技巧Matlab是一种强大的工具,被广泛用于图像处理和计算机视觉领域。
在本文中,我们将讨论如何利用Matlab进行图像压缩与图像解密,并探讨一些相应的方法和技巧。
首先,让我们来了解一下图像压缩的基本概念和原理。
图像压缩是通过减少图像占用的存储空间或传输带宽来减小图像文件的大小。
压缩分为有损压缩和无损压缩两种类型。
有损压缩会丢失一些图像信息,以达到压缩的目的,而无损压缩则尽量保留所有图像信息。
在Matlab中,我们可以使用多种方法进行图像压缩。
常见的方法之一是使用离散余弦变换(Discrete Cosine Transform,DCT)。
DCT将图像分解为一系列互不相关的频率成分,然后根据其重要性对这些成分进行量化和编码。
通过调整量化步长可以控制压缩比率和图像质量。
除了DCT,还有其他一些常用的压缩方法,如小波变换(Wavelet Transform),它可以提供更好的局部逼近能力,适用于不同尺度和方向的图像特征。
Matlab中有许多内置函数可以实现小波变换,例如waverec和wavedec函数。
另一个常用的图像压缩方法是基于向量量化(Vector Quantization,VQ)的编码。
VQ将图像划分为不重叠的块,并使用聚类算法将每个块映射到具有较少位数的代表向量。
然后,通过编码代表向量和其在图像中的位置来表示整个图像。
这种方法对于有损压缩非常有效,但在无损压缩方面效果较差。
一旦我们对图像进行了压缩,接下来我们需要了解如何进行图像解密。
在Matlab中,解密可以通过逆向操作来实现。
对于DCT压缩,我们可以通过应用逆离散余弦变换(Inverse Discrete Cosine Transform,IDCT)来恢复原始图像。
同样,对于小波变换压缩,我们可以使用逆小波变换(Inverse Wavelet Transform)来还原图像。
需要注意的是,如果进行了有损压缩,解密后的图像与原始图像之间很可能有一些质量损失。