Add a Compare blend mode

  • 1
  • Idea
  • Updated 5 years ago
  • Not Planned
I want a Compare blend mode, which computes (A-B)/2 + 0.5.

Why? There is currently no tool in Photoshop that can give a scientifically accurate verdict, "are these two images identical"?

There are four blend modes currently in Photoshop that kinda sorta achieve this same end, but they're all flawed by the way they handle exception cases and value clamping: Difference, Exclusion, Subtract, and Divide.

To see why none of these solve the problem, try putting a black Solid Color adjustment layer over an image and set its blend mode to Divide.

Result? You probably got an all-white image, which is also what you get if you divide two identical layers, since N / N = 1. That is, it has lied to you, if you thought white meant "no difference." Worse, you run into an odd exception case when there is black point clipping in the lower layer, since Photoshop is trying to protect itself from dividing by zero (black divided by black) and so gives bright yellow pixels out. This is the opposite sort of lie, since two identical pixels result in non-white!

To further explore the problems, try swapping the black comparison layer and the image layer, or switch the solid color layer to white. Try these variations with all four blend modes. For the Exclusion mode, also try it with two identical images.

The point is, none of these variations give you a reliable answer to the original question, "Are these two images identical?" Three of the four can easily be tricked into giving a false negative, "These images are identical," when they are not. The fourth can be tricked into giving a false positive, "These images are different," when they are actually identical.

My proposed blend mode solves these problems. For identical images, you get 50% gray out. Any difference appears as lighter or darker pixels, with 100% differences (e.g. color inversion) appearing as either black or white, depending on the order of the layers.

My proposal also copes with solid white or solid black comparisons gracefully. You either get a faded version of the original image out -- that is, with the dynamic range crushed to 50% -- or an inverted image of that same crushed image. Either way, it indicates "large difference".

In scientific use, you'd probably have to stack a Levels adjustment layer above this in order to scale the differences to a visible level, but that shouldn't subtract (ahem) from the value (cough) of this feature.

Because of the dynamic range compression effect, this blend mode must be able to function in 32-bit mode if you want it to be used in scientific applications. Otherwise, there is a risk of false negatives due to precision loss. In 8-bit images, two pixels differing by only 1 significant digit would compare as equal. The problem is less likely in 16-bit images, but still very possible.
Photo of Warren Young

Warren Young

  • 32 Posts
  • 1 Reply Like
  • underprivileged, and have all kinds of first world problems

Posted 5 years ago

  • 1
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 812 Reply Likes
You can do that with Apply Image.

But normally the absolute difference is what you need, and what the difference blend mode already gives you: abs( A - B )
That does answer "are the two images identical", because only identical images would give a result that is zero.

Image Forensics experts have been using the difference blend mode that way ever since Photoshop was released.
Photo of Warren Young

Warren Young

  • 32 Posts
  • 1 Reply Like
Thank you!

Please feel free to delete this request. I don't see how to do that myself.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 788 Reply Likes
How about we leave it here, so folks with similar questions can find it?