compression and decompresion

I have a code foe compressing a image
a is input image
singvals=20 ;
%a=imread('15.jpg');
dvalue=double(a);
[u,s,v] = svds(dvalue, singvals);
if isa(a,'uint8')
im = uint8(u * s * transpose(v));
% end
elseif isa(a,'uint16')
im = uint16(u * s * transpose(v));
%end
elseif isa(a,'double')
im = (u * s * transpose(v));
else im = (u * s * transpose(v));
end
please tell how todecompress an image
please help

回答 (3 件)

Jan
Jan 2012 年 3 月 13 日

0 投票

This method of compressing works by deleting of "unnecessary" details. If these details are deleted, you cannot reconstruct them afterwards. Therefore there is no way to "decompress" the result to reconstruct the original.

6 件のコメント

Image Analyst
Image Analyst 2012 年 3 月 13 日
Sounds like you're saying that you can't have lossless image compression. But I know you know that's not true because you know that PNG and a flavor of JPEG2000 are both lossless compression.
Pat
Pat 2012 年 3 月 14 日
ok ten can u suggest some idea what should be done to decompres the image,is the ant method to compress and decmpress the image other than jpeg,spiht.
Jan
Jan 2012 年 3 月 14 日
@Image Analyst: Of course there are lossless image compressions. But this is not the case for "[u,s,v] = svds(dvalue, 20)". This calculates the 20 largest singular values only, and further informations about details are lost. So what I said is: This is a lossy compression.
@Pat: I do not understand your question. Are you asking for another method which compresses an image without loosing information? The reasons, why you want to avoid JPEG compression will be important for a suggestion of other compression methods. See: http://en.wikipedia.org/wiki/Image_compression
Pat
Pat 2012 年 3 月 15 日
Jan is it possible to compress and decpmpress a image ,in which the compression consists of lesser lines say around 10,can i get codes for ebcot compression and decompression
Walter Roberson
Walter Roberson 2012 年 3 月 15 日
ebcot is part of JPEG 2000, which has an unclear legal status that cannot be investigated without agreeing to the license terms. If the agreement said that you owed them 95% of your first decade of post-graduate salary, you would not be able to find out out without signing the agreement before being allowed to read it.
Jan
Jan 2012 年 3 月 16 日
@Pat: Why do you want to avoid JPEG?

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

Walter Roberson
Walter Roberson 2012 年 3 月 15 日

0 投票

The array "im" that is calculated by the routine is the (lossy) decompressed image.

8 件のコメント

Pat
Pat 2012 年 3 月 16 日
But walter im is compressed image is it so?
when i compare a and im ,the im is compressed
Jan
Jan 2012 年 3 月 16 日
Dear Pat, perhaps it gets clearer when I use a simpler example: Imagine that the image has a single pixel only, which has the value 123.456 . Now the SVDS does something like rounding (just a metapher!). Thenm you get the new value 123. There is no way to reconstruct the fractional part of the value such that 123 is the compressed *and* the decompressed value at the same time.
It would be helpful, if you react to my questions in the comment above: Why do you want to avoid JPEG?
What does this mean: "The compression consists of lesser lines"? Is "lesser" the same as "less" and what are "lines" here?
Pat
Pat 2012 年 3 月 16 日
JAn jped compression is good but i need as the coding must consistsonly 10 lines for compression and decompression
lines refer to number number of coding lines
Walter Roberson
Walter Roberson 2012 年 3 月 16 日
Why do you have a 10 line limit? And is that 10 lines each for compression and decompression or 10 lines total between the two? Does it include empty lines and comment lines? Is there a particular formatting required, or could a single line be 50000 characters of statements strung together with semi-colons?
Pat
Pat 2012 年 3 月 17 日
walter 10 lines each for compression and decompression excluding comment lines,and empty lines,no formatting required
Walter Roberson
Walter Roberson 2012 年 3 月 18 日
Why do you have a 10 line limit? Why do you not just take any of the compression routines from the MATLAB File Exchange and reformat it to consist of only a single line of code? For example, the following single line is a valid .m file complete with function nesting:
function testlines;q = 1;function nested; disp(q); end; q = 7; nested; end
The practical line limit is somewhere around 40000 characters (some versions of MATLAB have had problems with lines that are longer than that.)
Jan
Jan 2012 年 3 月 18 日
The maximum line length in M-code and inside EVAL commands was discussed here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/288439
Walter Roberson
Walter Roberson 2012 年 3 月 18 日
Ah, so post 6.5, the shortest line that had problems was my test on 2008b Linux-64 with +0 repmat 40050 times, which would be 80000 characters. I knew I remembered "40000" in there somewhere!

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

Jan
Jan 2012 年 3 月 18 日

0 投票

A short JPEG compression:
img = rand(100, 100, 3);
imwrite(img, 'File.jpg'); % Compressed image
decompressed = imread('File.jpg');
What's wrong with using imwrite as compressor? svds is neither "more direct" or "more trivial".

カテゴリ

質問済み:

Pat
2012 年 3 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by