image compression using jpeg

  1. does doing dct followed by quantization and idct decompress the image?
  2. does run length encoding(rle) help to compress?
  3. when we save a file as jpeg and open it does it perform both dct and idct or only dct?
  4. how can i check if my image is compressed since both the original and output image are 256x256?
  5. in order to write a program to perform jpeg compression and display the compressed image do i have to use zig zag scanning and rle?

 Accepted Answer

Walter Roberson
Walter Roberson on 8 Feb 2014
1. No.
2. Often enough to be useful, but not always.
3. You have not specified what "it" is.
4. In that situation there is no compression.
5. No. If you use lossless jpeg then the algorithm does not use those steps.
Compression involves processing data and creating an output that takes less storage than the original data. Decompression involves taking that lower-storage version and expanding it back to something (close to) the original data. The step you have missed in several of your questions is the "creating an output that takes less storage than the original data". Calculating dct and quantizing it probably does not take less storage -- but you can then take the quantized data and output only parts of it. The less you output the more the compression but the less accurately you can reconstruct the original data.

13 Comments

Regarding 4, you can use dir() to check the file size on disk and see if it's less than the uncompressed version. Of course when it's read back in and decompressed it will be the same size.
@ Walter Roberson:"but you can then take the quantized data and output only parts of it". hw do i do tht? hw is tht acomplished in jpeg?
"3.when we save a file as jpeg and open it does it perform both dct and idct or only dct?" it refers to the file saved as jpeg.
My understanding is that in JPEG, the major DCT coefficients occur first, and that as one goes on, additional DCT components add finer and finer detail. If one only outputs a limited number of DCT coefficients rather then the whole set, then one will be unable to recreate the fine detail, but less storage will be taken. On decompression, the missing DCT coefficients are filled in with zeroes. The processing method is such that humans usually have difficulty detecting the missing detail; however, sharp vertical lines such as for text often suffers visibly before other aspects would be noticeable. Humans are good at detecting problems with sharp vertical lines.
3. Compressing an image in JPEG lossy mode and saving it (e.g. to a file) involves dct but not idct. Decompressing a JPEG image (e.g. from a file) involves idct but not dct.
so wil an image be compressed if i take its dct quantize it, and then take its idct ?
No. The compression would not occur unless you discarded parts of the result of the dct. And even if you did that, filling in those missing components with 0 and taking the idct would result in something that was the original size, a slightly blurred version of the original.
how do i discard the missing components after quantization with zeroes? could u please provide me the code for the same(to remove zeroes)?
In real JPEG files, you would write the component values that you wanted to keep, followed by an End Of Block marker. As the total number of components per block is constant, the decompression knows how many zeros need to be filled in.
My recollection is that the component values are written out in a modified Huffman encoding; in that case, the End Of Block marker would be a symbol in the table that the software knew indicated something special instead of a numeric component value.
sorry i could |you please explain how do encode it...how to place and detect EOB using matlab.. |
Are you familiar with huffman encoding?
not actually..How do i encode dct transformed , quantized and zigzag scanned coefficients using matlab?
i have done rle and used NaN to represent EOB. how can i do arithmetic encoding on the rle encoded sequence
i'd prefer to use the built in function for arithmetic encoding but i cant understand what the arguments must be. my input is rle encoded sequence.also how can i show that an image which is dct transformed, quantized, rle encoded ,arithmetic encoded sequence occupies less bandwidth as compared to the original image

Sign in to comment.

More Answers (1)

jithin
jithin on 17 Feb 2014
i am working on Image Compression Using Intra prediction of H.264 using matlab.. 1.Is compression using intra prediction better than that(compression) using jpeg? 2.How can we prove that compression using H.264 is better than jpeg compression? 3.Could you please provide me the code for run length encoding?

3 Comments

H.264 is for motion. JPEG is for static images.
i meant comparison between intraprediction and jpeg.. How can i prove that intraprediction produces better compression?
i meant comparison between intraprediction and jpeg.. How can i prove that intraprediction produces better compression? and how can analysis filter cutoff frequency

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!