Skip to content
Advertisement

Black and white color addition

When red is mixed with green, I get yellow as expected.

JavaScript

But when white is mixed with black, I should get normally grey but I get white. Shouldn’t I get grey?

JavaScript

Here is the code:

JavaScript

Advertisement

Answer

I think what @Cris Luengo said (“If you want to get gray, average the white and black pixels together”) is valid; Also I think one additional thing can be a MixFactor.

You can use OpenCV for this.

Imports:

JavaScript

Load image:

JavaScript

Main code:

JavaScript

My input values for color:

JavaScript

I draw the first colorful image using a graphical software; The other 8 created with this Python code.

enter image description here


Credit: The text on the image is written using the default Hershey font included in OpenCV. And you can read more here and here.


Update:
If you want to use imshow for the output of this blending method; use it like this:

JavaScript
Advertisement