Per-pixel logic in Photoshop

Issue

I have 2 images.

enter image description here
enter image description here

I need to create a 3rd image, based on this logic:

If the pixel in image 1 and 2 is identical, the pixel in image 3 should be transparent.

If the pixel is different between image 1 and 2, use the pixel from image 1.

Photoshop blend modes don’t seem to be the right direction. Are there any good 3rd party or scripting tools for this kind of operation?

Solution

Pending a more clever solution, with Gimp:

  • Stack the images as layers
  • Fill the background of both images with white (bucket fill the whole layer in Behind mode)
  • Set top to Difference mode and create a layer with the result (Layer > New from visible)
  • Threshold the layer/ This is where you discover that your images are far from identical outside of the spear… (*). In an ideal world, you would threshold at "1" but here you have way too much noise, "20" seems a bare minimum)
  • Copy one of the RGB channels to a new channel
  • Make a copy of Image 1, and add a layer mask, initializing to the channel you copied.

enter image description here

(*) Here is the alpha channel of Image1: plenty of random not-so-transparent dots:

enter image description here

And Image2 is similar, with other random dots:

enter image description here

Answered By – xenoid

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published