2

In usual discourse, when looking at an photographed image (A) - which is a JPG - and a slightly photoshopped version of it (A2), most people can intuitively compare the two and visually assess that they are, indeed, the same image except for a small number of differences.

However, that isn't a formal proof that the two images are "nearly identical", and as such, may be challenged in a setting where more stringent standard of proof is needed (legal setting, or Skeptics.SE).

If it was a pair text files, one could run a diff command on them, and establish close similarity by the result of the diff being significantly smaller than the file size.

But since these are JPG images, I would expect that the effect of photoshopping and saving a second version - with a slightly different compression ratio, to boot - would cause the straight up diff to be 100% useless.

  1. Are there formal methodologies in image processing that can be used to "diff" the two photo images saved used lossy compression (JPG)?

    The methodology should be vetted (e.g. via peer review process as far as publication in a well known image processing/computer vision/etc... publication).

    The desired output is either numerical % of change; or some visualization method.

    The methodology should be insensitive to slight post-processing, such as minor edge cropping, resizing and saving with a different compression ratio which causes minor losses.

  2. If so, are there publicly available web sites or freeware programs that (a) can have 2 JPGs uploaded and produce the "diff"; (b) Publish the exact methodology they use, which fits #1.

  • 1
    Pretty much a duplicate of these three questions on SO: 1 2 3 – Philip Kendall Aug 20 '14 at 10:55
  • 1
    @DVK Given nobody in any of those answers has pointed to a "definitive" method, I think the simple answer to your question is "no". – Philip Kendall Aug 20 '14 at 11:38
  • 1
    And I still think the answer to your question is "no". – Philip Kendall Aug 20 '14 at 11:40
  • 1
    I wouldn't worry about trying to meet SkepticsSE "standards" - they seem to work on logic systems and "standards [sic] of proof" unknown in the scientific or engineering world. Just tell them that you saw a website that said the two were the same and they'll be happy. (You may have to post them both to a site and say they are the same and give them the link if they are in rigorous mode). – Russell McMahon Aug 20 '14 at 11:42
  • 4
    For what it's worth, there are no forensic methods of any type of image analysis that provide proof ... of anything. Instead, the methods provide data. Depending upon the situation, it is up to the analyst, or law enforcement, or in some situations, ultimately up to a judge or jury to say that the data amounts to proof. However, if you are looking for something to provide data that may show if an image content has been photoshopped - Error Level Analysis is been around for a few years just for this. – B Shaw Aug 20 '14 at 14:46
4

The computer vision research community frequently uses the PSNR (peak signal to noise ratio) when comparing images, for example to assess how good a particular compression or image reconstruction algorithm is.

The wikipedia page describes how to calculate it: http://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio

It's a mathematical score based on the numerical difference between pixel values. It requires the two images to be aligned first, a small misalignment could lead to a poor matching score even if the image is otherwise identical.

  • Judging on the last paragraph, the requirement of "insensitive to scaling" seems to be greatly violated? – DVK Aug 20 '14 at 16:49
  • Is PSNR a meaningful measure in and of itself, or can it only be used to compare different models? I first though of MAE, which is trivial to compute in PS using the difference mode and the average pixel value from the histogram info. However, you can only use MAE if you have another MAE value to compare it to. That's why I recommended correlation. – JenSCDC Nov 2 '14 at 23:03
  • @DVK PSNR is not insensitive to scaling, I know of no standard metric that is. So the short answer to your question would be "no". There is SIFT (scale invariant feature transform) that works for image features (lines, corners etc.) but not entire images. You could come up with a way of converting images into SIFT features and then comparing the features, but then it wouldn't be a widely accepted method, as you would have just invented it. – Matt Grum Nov 3 '14 at 11:21
  • @AndyBlankertz yes PSNR scores are meaningful in isolation - unlike the MAE the error is expressed relative to the signal. – Matt Grum Nov 3 '14 at 12:20
1

You could use Photoshop and layers to view a "difference" between them. I'm aware of a diff Mac app that does this with images: Kaleidoscope's image scope sounds like what you want.

  • What is the methodology used for either of those, and is it proven to be a good methodology? – DVK Aug 20 '14 at 11:38
  • In both cases it's just subtracting the the difference between overlaid pixels to visualize where the changes are. It's proven in that it works well, yes, but whether or not that provides you with the information you need is up to you. I doubt it'll do what you want because as user28116 mentioned in the comments on the question any change to the image whatsoever causes it to appear in the difference blending mode. – Dan Wolfgang Aug 20 '14 at 14:11
  • 1
    @DanWolfgang: Small differences will show up as dark gray values, which are easily interpreted. For instance, if you take two identical image layers, convert to Lab color mode, and add 1 to the L channel for all pixels in one layer, you'll get a solid very dark gray output. That's the real problem with the difference technique: your monitor is probably adjusted so that you can't tell the difference between 99% black and 100% black. It'll just look black. I drop a Levels or Curves adjustment layer on top when doing this, to increase the contrast. – Warren Young Nov 3 '14 at 21:27
1

What you need is an image similarity measure.

This paper deals with that, but you'll have to implement by yourself. Don't know wheter their results are accurate, since I can't see the images they used.

This behind paywall paper also deals with that using a technique I used before, called NCD (normalized compression distance). The output of such measure is a value between 0 and 1, where 0 indicates that both images are identical (ok, I never saw it be 0 even for identical files, but values very close to 0).

  • My reading of the FCD paper says it is good only for detecting images that are either identical or that differ only in parts of the image. I believe if you take an image, convert it to the HSL color space, and add 1 to all the L components, making it just a bit brighter, you will get an output of 1 from the FCD algorithm, meaning they're entirely different. I don't think the OP wants that. – Warren Young Nov 3 '14 at 9:35
1

What about calculating the correlation of the images? This is a well established method of finding the differences between images, and it gives you a a useful number quantifying the difference.

I'm sure that there are a lot of free programs that can do correlation.

  • Could you please elaborate on the method? (may be links to references). Thx – DVK Nov 3 '14 at 0:06
  • I learned about from a free book at dspguide.com – JenSCDC Nov 3 '14 at 0:10
  • 1
    You just take a few small areas from both pictures and align these small areas separately by maximizing the correlation between them. You then see if the separate alignments are compatible with a single global alignment transform (e.g. if you move two of the areas on top of each other, you check if the other areas can be aligned by a single rotation around the two that you put on top). If this works, you can check the correlations between parts of the image that should correspond to each other. You then consider the correlation between many such randomly chosen areas. – Count Iblis Nov 3 '14 at 17:00
  • 1
    The size of the areas should be taken to be quite small so that the variations in the brightness is mainly due to the way the camera processed the image. You don't want any correlation you find now to be dominated by the similarity of the physical object depicted. – Count Iblis Nov 3 '14 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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