decompressing an compressed image

6 ビュー (過去 30 日間)
Pat
Pat 2012 年 4 月 26 日
編集済み: Walter Roberson 2019 年 8 月 26 日
I have a code for compression please telll how to decompress an image from that compressd image
y=imread('dock.jpg');
y=rgb2gray(y);y=double(y)
threshold=0.125
y=imresize(y,[256 256 ])
low=min(min(y)); high=max(max(y)); % NEEDED LATER FOR DISPLAYING
figure,
imagesc(y), colormap(gray), axis off
title('original image')
w=wavmat;
ty = w'*y*w; % THE WAVELET TRANSFORMATION
tty=ty; % A TRICK TO ELIMNATE THE OVERALL
tty(1,1)=0; % AVERAGE FROM CONSIDERATION WHEN
dead=max(max(abs(tty)))*threshold/100; % DECIDING JUST HOW TO THRESHOLD
clear tty;
dy=ty;
index=find(abs(dy)<=dead);
dy(index)=zeros(size(index)); % SETTING LOTS OF ELEMENTS TO ZERO
cy = full(w*sparse(dy)*w'); % THE INVERSE WAVELET TRANSFORMATION
density = nnz(dy); % ENTRIES USED OUT OF 256^2 = 65536
disp(['Wavelet transformed and doctored matrix uses '])
disp([ num2str(density) ' entries out of 256^2 = 65536,'])
disp(['thus is ' num2str(100*density/65536) '% dense, and we get a '])
disp(['compression ratio of ' num2str(65536/nnz(dy)) ' to 1']) % "COMPRESSION RATIO" = 65536/DENSITY
figure,
imagesc(cy,[low high]), colormap(gray), axis off
title('compressed image')
  2 件のコメント
Jan
Jan 2012 年 4 月 26 日
It would be helpful for all readers, if you post the relevant code only.
shital shinde
shital shinde 2019 年 8 月 26 日
yes. I also need the implimentation of inverse DCT. Its very helpful.

サインインしてコメントする。

回答 (1 件)

Wayne King
Wayne King 2012 年 4 月 26 日
I'm not sure what you mean here by decompress, but what you have implemented is lossy compression so you cannot "invert" your process to come up with the exact original image. In other words, you cannot take your cy and reproduce y such that the norm of their difference is zero.
When you execute:
dy(index)=zeros(size(index))
You have set the wavelet coefficients below a certain level to 0. You no longer know what the value of those coefficients was, so when you invert the wavelet transform, you cannot match your original image.
Now, you could use ty (the wavelet transform of y) and invert that, but that is not a compressed image.
  4 件のコメント
Jan
Jan 2012 年 4 月 26 日
@Pat: It is not helpful if you ask the same questions repeatedly instead of replying to the questions for clarifications. See: http://www.mathworks.com/matlabcentral/answers/36383-compressing-a-image
and http://www.mathworks.com/matlabcentral/answers/32129-compression-and-decompresion
Jan
Jan 2012 年 4 月 26 日
@Walter: Human tend to prefer images with less than the full entropy. Therefore lossless compressions are possible, if the rounding error are neglected, for a large set of usual pictures. But if a "sufficiently large set" includes random and max-entropy pictures, any 1:1+e compression must be lossless, as you have explained.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeContinuous Wavelet Transforms についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by