• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Image comparison, difference as black/white mask

Community Beginner ,
Sep 22, 2021 Sep 22, 2021

Copy link to clipboard

Copied

Hello,

I'm using Substance 3D Designer and have two Bitmaps. They are almost identical, except some spots have a different color-tint (e.g. greenish vs yellowish). I need these differences as a black/white mask (goal is to use this mask in a game-engine to give a color at runtime).

 

I tried with blending (subtract/divide) and roughly that works, but has pixel-artifacts - which makes sense because it's not looking for an exact match. So what i'd like to do is compare each pixel in image 1 to the corresponding pixel in image 2 and if they are identical I'd like the output mask to contain black for that pixel, otherwise white. 

 

Can someone point me in the right direction?

Thanks in advance!

TOPICS
Scripting , Substance Graph

Views

212

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Sep 23, 2021 Sep 23, 2021

Hello @rboerdijk,

 

I can suggest two ways of approaching this: one uses a combination of Difference and Levels nodes while the other uses a custom function in a Pixel Processor node.

 

Connect the two RGBA images to a Difference node, then use a Levels node to bring the detected differences up to flat white.

 

difference-to-white-1.png

 

 

 

 

 

 

In a Pixel Processor, sample the two RGBA images and subtract one to the other. If the result is zero (no difference), output black (0.0). If there is any difference, output

...

Votes

Translate

Translate
Adobe Employee ,
Sep 23, 2021 Sep 23, 2021

Copy link to clipboard

Copied

Hello @rboerdijk,

 

I can suggest two ways of approaching this: one uses a combination of Difference and Levels nodes while the other uses a custom function in a Pixel Processor node.

 

Connect the two RGBA images to a Difference node, then use a Levels node to bring the detected differences up to flat white.

 

difference-to-white-1.png

 

 

 

 

 

 

In a Pixel Processor, sample the two RGBA images and subtract one to the other. If the result is zero (no difference), output black (0.0). If there is any difference, output white (1.0).

 

difference-to-white-2.png

difference-to-white-2-function.png

 

 

 

 

 

 

 

 

 

 

 

If you want to set a tolerance for the difference, simply check that the difference is lower than the tolerance value instead of strictly equal to (0, 0, 0, 0).

 

I hope this is useful!

 

Best regards.

 

Luca Giarrizzo | QA Analyst, 3D & Immersive | Adobe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

Thanks, used the pixel processor and it works perfectly!

... and good call suggesting the lower-than tolerance, it indeed needed a bit of a 'fudge' value.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 24, 2021 Sep 24, 2021

Copy link to clipboard

Copied

Oh, in case anyone is interested, this is what I ended up using. 

sd_pixelprocessor_diff.png

Note that I have 3 source images and tried to improve the result a bit by combining those. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

LATEST

Hi @rboerdijk,

 

I am glad this was helpful, nice job implementing what you needed!

 

Best regards.

 

Luca Giarrizzo | QA Analyst, 3D & Immersive | Adobe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines