views:

2962

answers:

7

Well I've written a basic lossless jpeg joiner thing in java now but I'd like to compare the files it produces with the original files.

I can only compare so much in a hex editor, does anyone know of an easy way, software or java based (preferably software as I dont feel like any more coding for now!) that I can compare two images and produce a "difference map" of where the pixels aren't the same?

Thanks.

A: 

im sure you can do it in photoshop? :P

Petoj
A: 

Use an image editor like Photoshop or the Gimp or whatever, which has multiple layers. Create an image where each source image in a separate layer.

At this point, you can visually compare the images by toggling the top layer's visibility off and on.

In most decent editors, you can also set the top layer to "difference" mode. Now each image pixel's value is the absolute difference of the pixel values in the underlying images. You can use e.g. a histogram tool to see if the images are identical. If they're identical, then all the pixel values will be exactly 0.

Doug
+1  A: 

For stuff like this, I love the netpbm/pbmplus toolkit. You can use djpeg and pnmtoplainpnm to convert each image into a simple ASCII format. You then just read both files and emit a new image which shows where pixels differ. You could, for example, compute the Euclidean distance in RGB space between old and new pixels and emit a white pixel for zero difference, light gray for a small difference, darker for larger differences, and so on. The ASCII format is simple and is well documented on the man pages, and all the standard viewer programs can view it directly.

Norman Ramsey
+2  A: 

You could do a lot worse than Perceptual Diff.

Mark Simpson
This looks very good, but it's probably a lot more than what I need to do. I just want to compare images pixel by pixel and see the exact differences. This is to check how well my "lossless" jpeg editing is working.
joinJpegs
I should have clarified a bit more: you *can* specify a flag that will output an image containing the per-pixel differences using PDiff. The only drawback is that it's in a weird format (PPM) :)
Mark Simpson
A: 

The latest version of Araxis Merge will do image diffs ( http://www.araxis.com/merge/topic_comparing_image_files.html ).

Unfortunately it's not a free app so whether or not you're willing to pay for it is another thing...

Narcissus
+2  A: 

Thanks for the suggestions.

I tried the Gimp approach first which works well except when the difference between the images are very small. I couldn't find an "enhance differences" option to make the differences obvious and the histogram also only gives a rough representation of the differences.

In the end I used ImageMagick something I'd installed a while ago and forgot all about. Creating a difference/comparison image is as easy as typing:

 compare first.jpg second.png difference.gif

in the command line.

It's all nicely explained here.

joinJpegs
+1  A: 

TortoiseIDiff is a free image diff viewer:

http://tortoisesvn.tigris.org/TortoiseIDiff.html

It is part of TortoiseSVN, but can be used without Subversion.

mjustin