Eva

Eva

by Petr Újezdský

submit your photo


Picture of the Week Themes
Suggest and vote on themes

Win a Lifehacker Syndication contest!

For example, for a recent conversation about JPEG compression I wanted to compare pixel for pixel what changed between two JPEGs (one with compression level 100, and one with compression level 95).

How do I generate good visual maps of what changed without tedious custom software programing?

link|improve this question

80% accept rate
Not submitting this as an answer as it's probably not a viable solution for photos, but GitHub (a programmer's site) has some interesting ways of comparing images: github.com/cameronmcefee/Image-Diff-View-Modes/commit/… Try clicking "2-up", "Swipe", "Onion Skin" and "Difference". – Henrik N May 6 '11 at 12:19
feedback

5 Answers

up vote 16 down vote accepted

Photoshop + Layers FTW. (yes, you can also use the Gimp, or any other editing software with the same functions.)

Start with your base image, in the case above, I used the jpeg quality 100 image.

  1. create a new layer atop it
  2. paste the second image into that layer
  3. set the layer style to "difference"
  4. create an effect layer atop that
  5. set the effect to threshold
  6. set the threshold value to 1

In the resulting image, any pixel that is any any way different between the two images will be white. You can adjust it to allow things to be "a little different" by altering the threshold value.

Example showing a LOT of difference between jpeg 92 and 100 from Lightroom. comparing jpeg 92 and 100 from LR with photoshop layers

Example showing no difference at all between 95 and 100. comparing jpeg 95 and 100 from LR with photoshop layers

Not that's just showing a binary "changed or not", what if you wanted more detail on how much it changed, say by color channel?

  1. Replace the threshold adjustment layer with a curves adjustment layer.
  2. edit the curve
  3. turn on show clipping
  4. grab the input white handle below the lower right corner and drag it over to the left, as far as you can go
  5. slowly move back to the right until you don't see any clipping (the preview image is all black)
  6. turn clipping back off and save the curve change

The brighter the resulting pixels, the more they're different in that color. The downside though is you end up with a lot of grey mud... so sometimes it's easier to just threshold it to see where differences are. That's why I build both and toggle which one is visible.

more descriptive view of the difference

link|improve this answer
You should mark this as the accepted answer for its pure awesomeness. ;) – jrista Dec 23 '11 at 20:19
well, if you insist.... ;) (thanks for reminding me I hadn't accepted one.) – cabbey Dec 27 '11 at 7:01
feedback

If you use Photoshop, here's how I'd do it:

Put the two jpegs in the same psd file, in two separate layers. They should overlap exactly, since their dimensions are the same. (which one goes on top doesn't matter).

Set the layer blending mode to "Difference." You'd see a mostly black result. Depends on the quality difference between the two original layers you may see more or less of the noise.

enter image description here

link|improve this answer
Difference alone doesn't really help much when you're left with a big black void like that. :) – cabbey May 6 '11 at 7:15
@cabbey sure, comparing 100% to 95% you most likely will get a solid black. But that's what your question was asking isn't it? In your owner answer, you're changing the values from the originals being compared, which makes them no longer having the original compression settings. – Jin May 6 '11 at 7:20
You get virtually solid black on just about any comparison, because the differences are so small. The threshold/curve layer after the difference doesn't do anything to the compression settings, it just aids the visualization of the lower bounds of that black soup that difference prepared. (I'm not 100% sure what you meant by that, so I could be heading off in a different direction there....) – cabbey May 6 '11 at 7:31
@cabbey if you're asking for a pure bit-wise operation of the difference between the 2 images, then "Difference" blending mode alone gives you that. When you adjust threshold/curve, though the result is more obvious to the naked eye, but it's not an accurate representation of what has changed. When do you that, you're not longer comparing a 100% to a 95%. – Jin May 6 '11 at 7:36
Sure you are. The level of compression stopped mattering the second photoshop loaded the image from disk into it's internal buffers, it is now an uncompressed pixel array in memory... if those pixels got there because the image had a square blob there or because they are an artifact of the compression level is not relevant. – cabbey May 6 '11 at 7:42
show 2 more comments
feedback

Gimp has two functions implemented to show the difference of two images. Take a look here: http://www.linuxtopia.org/online_books/graphics_tools/gimp_advanced_guide/gimp_guide_node55_001.html

In order to calculate the exact difference you need a tool like Matlab. See here for an example: http://www.mathworks.com/help/toolbox/images/ref/imabsdiff.html

link|improve this answer
Matlab is exactly what I meant by "without tedious custom software programing". – cabbey May 6 '11 at 7:47
1  
4 lines of code. ;-) – ceving May 6 '11 at 11:21
1  
... and $$$$$ to buy matlab in the first place, although I suspect Octave would do fine for this. And either way the right four lines of code rest on top of a fairly steep learning curve. – RBerteig May 6 '11 at 18:43
feedback

GitHub has some interesting image diff tools built into it on the web, as described here and demonstrated in this demo.

link|improve this answer
feedback
  1. Open one of the images in GIMP or Photoshop.
  2. Add the second image as a new layer on top of the first one.
  3. Set the blend mode of the top layer to "Difference"

In the resulting image the black parts show where the original images are identical and anything lighter shows differences.

link|improve this answer
Difference alone doesn't really help much when you're left with a big black void like that. :) – cabbey May 6 '11 at 7:15
You can always adjust the levels on the resulting image. Whenever I've used this technique I've had pictures different enough to be able to see the changes :) – Dan May 6 '11 at 10:27
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.