Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extracting Identical Pixels Between Two Layers
#1
Hello, I am trying to cut out or isolate in some fashion all of the pixels that are identical between two images. These two images are different coloured variants of each other, and certain pixels are identical. 

I was thinking of putting them into two layers and... I don't know lol. Just wondering if there is an easy way to go about this. 

Note that I am NOT trying to delete these pixels. In the end, I would like to put them onto a layer on their own.
Reply
#2

  1. Align the layers
  2. Put the top one in "Difference" mode: identical pixels in both layers will yield a perfectly black result.
  3. Do Layer > New from visible to snapshot this into a  new layer
  4. Use the Threshold tool to set to white any pixels that is not perfectly black, to obtain an image where all white pixels correspond to different pixels in the compared images
  5. If you want a selection from this, open the Channels list, right click on any R/G/B channel and "Channel to selection". You can then hide/discard the Visible layer.
   
Reply
#3
Another way

This is from here: https://graphicdesign.stackexchange.com/...ge-in-gimp and sort of ties in with your other post.

The two images as layers
Using the bottom layer Filters -> Animation -> Optimize (Difference)
That makes a new image and the top layer has an alpha channel of the common pixels
Layer -> Mask -> Add Layer Mask -> Layers Alpha Channel

Then on the bottom layer using a script (attached) to copy the layer mask without going through the make / copy / paste / anchor routine.
Click in the layer mask to make active and invert it Colors -> Invert
If you just want that result, one way is Layer -> New from Visible.

Attached sg-copy-mask-from-above.zip Unzip and put sg-copy-mask-from-above.scm in your Gimp User Profile folder C:\Users\"yourname"\AppData\Roaming\GIMP\2.10\scripts

Another quick animation, using a very obvious magenta dots common pattern https://i.imgur.com/LHC7JDA.mp4


Attached Files
.zip   sg-copy-mask-from-above.zip (Size: 1.37 KB / Downloads: 330)
Reply


Forum Jump: