Question

Trying to subtract a JPEG image from itself results in a non empty image, i.e. the delta image is almost white, but something from the original image is still visible.

I do not know if this is something intrinsic to the JPEG format, or if it depends on the program I used or on my parameters.

The program I used for a test is ImageMagick.

This is the command (tried with different values of -fuzz):

compare.exe img.jpg img.jpg delta1.jpg
compare.exe -fuzz 1000.0 img.jpg img.jpg delta2.jpg
Was it helpful?

Solution

The problem can arise because JPEG is a lossy format. There is thus no "perfect answer" to the decompressed form of the image. It also means that a decompressor cannot be tested as returning that perfect answer, and it might well return a different result at each run, even if this result is correct and near enough from the original given the compression parameters.

You could expect the same decompressor to always return the same bitmap image bits for a given JPEG file but unless the decompressor is explicitely tested for that (and it is definitely not a common requirement), your experiment results can happen without meaning that the decompressor is of worse quality than a decompressor which would always return the same results.

You could do a PSNR/MSE comparison with respect to the original bitmap several times (i.e. comparing the .bmp to the decompressed .jpg several times), these measures will probably stay nearly constant.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top