0

I'm trying to understand the JPEG compression process and performed the following steps to verify a few things.

I take an input image img1.jpg and compress it by using IrfanView, say quality=50 (img1_compress.jpg).

Then I crop a small block from the input image img1.jpg (block.jpg of size 8x8 at X,Y=16,16) and compress it by using the same value of quality parameter (50). Let's call it block_compress.jpg.

Now when I compare this block's pixel values with the one in fully compressed image, they don't match.

To clarify, the pixel value at position 0,0 in block_compress.jpg should match with the pixel value at position 16,16 in img1_compress.jpg.

I'm confused why pixel values don't match? Any ideas?

pree
  • 2,297
  • 6
  • 37
  • 55

3 Answers3

2

I just did this experiment with my JPEG codec and the pixel values match. Irfanview may be applying some kind of noise filter or other modifications when it compresses JPEG images. Without seeing the source code to the codec you can't know what it's doing. Your experiment is valid, but by using other people's code to test your theory you can't know what's really going on inside their code.

BitBank
  • 8,500
  • 3
  • 28
  • 46
  • Do you know any tool that I can use for my experiment? – pree Mar 22 '13 at 18:53
  • Since I use my own JPEG codec, I don't have info about others. You might want to use LIBJPEG since you can see what it's doing in the source code. – BitBank Mar 22 '13 at 18:58
  • I see. I will use that to run my experiment. Thanks for the info :) – pree Mar 22 '13 at 18:59
  • I ran my experiments using ImageMagick with a PNG input image and it all worked fine. However, when I use a BMP image for my experiments, it fails sometimes. What I have observed is that it fails for the pixels with "gray" color value. As long as it's RGB, it works fine. Any clue on what's happening here? – pree Apr 08 '13 at 19:05
  • I can't really speculate without seeing the source code. There are all sorts of things that can occur when working with different file formats (e.g. bit depth changes). – BitBank Apr 08 '13 at 20:43
1

JPEG is lossy compression algorithm. Compressing one image with identical compression settings in different tools can produce differ result. You need use one of lossless algorithms if you want pixel-to-pixel result. I.e. you can use PNG

-3

"the DC component of each 8x8 block is predicted from the previous block.” : by Oli Charlesworth

pree
  • 2,297
  • 6
  • 37
  • 55
  • Oh I see. Then I need to do this experiment again by using some other tool – pree Mar 22 '13 at 18:50
  • Since mu results were different and the above answer justified the results. So thought its correct. – pree Mar 22 '13 at 18:52
  • 1
    You're mixing two different concepts. Part of the JPEG compression is achieved by delta compression of the DC values from one MCU block to the next. This has nothing to do with working with the finished output pixels and is unrelated to your experiment. – BitBank Mar 22 '13 at 20:39