kakush
kakush

Reputation: 3484

How to detect if a compressed image was created from an uncompressed image

I have 2 images: 1 raw image in pgm format 1 compressed image in pgn/jpg format

Is there a tool that can detect if the compressed image was created from the raw image?

I'm using c++ in linux, but any lead on this subject will be very helpful.

Upvotes: 1

Views: 93

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207345

There are lots of ways to compare images. You can look at the:

  • Absolute Error - a count of the number of pixels that differ
  • Peak Absolute Error - maximum difference at any pixel
  • Mean Absolute Error - average error across all pixels
  • Mean Squared Error - as above but squared
  • Root Mean Squared Error - square root of above
  • Normalized Cross Correlation.

There is a very good summary by Anthony Thyssen here.

If we take a greyscale Lena image and compare its PGM form with PNG and JPEG, you can get a good idea of the differences with ImageMagick at the command-line, like this:

# Compare lossy JPEG Lena with PGM
compare -metric RMSE lena.pgm lena.jpg null:
567.167 (0.00865442)

# Compare lossless PNG Lena with PGM
compare -metric RMSE lena.pgm lena.png null:
0 (0)

If I now generate a JPEG Lena with lower quality and compare with the PGM again, you can see that the error/difference is larger:

convert lena.pgm -quality 50 lena.jpg
compare -metric RMSE lena.pgm lena.jpg null:
1110.81 (0.0169498)

Upvotes: 1

Related Questions