Pages: [1]   Go Down

Author Topic: Comparing two photos pixel by pixel  (Read 725 times)

PeterAit

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 4559
    • Peter Aitken Photographs
Comparing two photos pixel by pixel
« on: March 18, 2022, 10:48:52 am »

For reasons that I won't go into, I need to compare two photos to see if they are identical byte-for-byte. It seems that Photoshop would have a way to do this, but I cannot figure it out. For example, subtract one from the other? Thanks in advance.
Logged

Peter McLennan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 4690
Re: Comparing two photos pixel by pixel
« Reply #1 on: March 18, 2022, 11:26:20 am »

Off the top of my head…put each photo into a separate layer, choose “difference” blending mode.
Logged

Redcrown

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 507
Re: Comparing two photos pixel by pixel
« Reply #2 on: March 18, 2022, 12:00:34 pm »

Yes, put the 2 images as layers in Photoshop, set the top one to Difference mode. You will see a black image, which tells you nothing. So, display the histogram. Click on the little yellow triangle warning in the histogram window. That warning is telling you the histogram is an estimate. Once clicked, the histogram becomes real.

Read the StdDev value. If it is zero, the images are 100% identical. If not, they are different. If StdDev is below 1.0, the difference is insignificant. To see where the differences are, add a Threshold layer on top. Move the slider to the far left, then slowly nudge it to the right. White means difference, black means identical.
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Re: Comparing two photos pixel by pixel
« Reply #3 on: March 20, 2022, 01:14:27 pm »

Read the StdDev value. If it is zero, the images are 100% identical. If not, they are different. If StdDev is below 1.0, the difference is insignificant. To see where the differences are, add a Threshold layer on top. Move the slider to the far left, then slowly nudge it to the right. White means difference, black means identical.
If the op needs 100% accuracy, i.e. to know if two images are absolutely identical byte per byte, Photoshop rounds to 15-bit any loaded image so it won't be able to distinguish many 1-bit differences.

I would just load them in any language and compare them. In R this is so straightforward as:

img1=readTIFF("img1.tif", native=FALSE, convert=FALSE)
img2=readTIFF("img1.tif", native=FALSE, convert=FALSE)
ifelse(max(abs(img1-img2))==0, "Images are identical", "Different images")

Regards
« Last Edit: March 20, 2022, 01:20:55 pm by Guillermo Luijk »
Logged

Alan Klein

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 15850
    • Flicker photos
Re: Comparing two photos pixel by pixel
« Reply #4 on: March 20, 2022, 04:20:21 pm »

PeterAit

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 4559
    • Peter Aitken Photographs
Re: Comparing two photos pixel by pixel
« Reply #5 on: March 21, 2022, 10:12:52 am »

Thanks for the answers. I found a command line utility FC that does a byte-for-byte, but then I realized that 2 files containing identical images could still have different metadata. The idea that was presented here to load the images as layers and then use the Difference blend mode does the trick.
Logged

digitaldog

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 20646
  • Andrew Rodney
    • http://www.digitaldog.net/
Re: Comparing two photos pixel by pixel
« Reply #6 on: March 21, 2022, 11:32:58 am »

For reasons that I won't go into, I need to compare two photos to see if they are identical byte-for-byte. It seems that Photoshop would have a way to do this, but I cannot figure it out. For example, subtract one from the other? Thanks in advance.
How to do so in Photoshop:
http://digitaldog.net/files/Apply_Image.pdf
Quote
If the images were truly 100% identical, every pixel in the image would be a solid level 128 gray as seen below from the Histogram using Levels. Pixels that aren’t level 128 gray are different by the amount they depart from 128 gray. You can use Levels to exaggerate the difference, which makes patterns easier to see. Just move the sliders on either side to the center as far as you can.
Logged
http://www.digitaldog.net/
Author "Color Management for Photographers".
Pages: [1]   Go Up