20

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.

Luke Quinane
  • 16,447
  • 13
  • 69
  • 88
joinJpegs
  • 1,287
  • 3
  • 14
  • 21

8 Answers8

20

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,287
  • 3
  • 14
  • 21
5

TortoiseIDiff is a free image diff viewer:

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

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

Depending on your project, not all files which are under version control are text files. Most likely you will have images too, for example screenshots and diagrams for the documentation/helpfile.

For those files it's not possible to use a common file diff tool, because they only work with text files and diff line-by-line. Here is where the Tortoise Image Diff tool (TortoiseIDiff) comes to the rescue. It can show two images side-by-side, or even show the images over each other alpha blended.

mjn
  • 36,362
  • 28
  • 176
  • 378
4

You could do a lot worse than Perceptual Diff.

Mark Simpson
  • 23,245
  • 2
  • 44
  • 44
  • 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 Mar 31 '09 at 01:17
  • 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 Apr 01 '09 at 11:32
  • Java port of Hector Yee's Perceptual Diff tool can generate .png difference image: [bitbucket.org/joebowbeer/perceptualdiff](https://bitbucket.org/joebowbeer/perceptualdiff) – Joe Bowbeer Oct 23 '12 at 05:23
2

The best approach would be to use Pix for windows (comes with the DirectX SDK). Supports Bitmap, PNG and Jpeg...Enjoy!

1

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
  • 8,780
  • 2
  • 27
  • 37
1

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
  • 198,648
  • 61
  • 360
  • 533
1

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
  • 3,144
  • 3
  • 27
  • 40
0

There's also a convenient web app called Resemble.js, which analyzes and compares images pixel by pixel. The different pixels in the images (if any) are highlighted with pink or yellow color depending on your preference.

Pavel Vladov
  • 4,707
  • 3
  • 35
  • 39