Trying to translate formula for blending mode I am using OpenCV C++ for making the blending mode like in photoshop, I want to make overlay mode in it. I search its alternate in OpenCV in which I found this blending way, but its not the overlay as I want to use the overlay method in it.

Overlay method formula from this documentation

(Target &gt; 0.5) * (1 - (1-2*(Target-0.5)) * (1-Blend)) +
(Target &lt;= 0.5) * ((2*Target) * Blend)


Can anyone please explain this formula for implementation in OpenCV C++ , how I can easily understand it for implementation or is there any already build in function for it or any other easy way out.
You can find many ready solution in the Internet. For example here following macro is given:

#define ChannelBlend_Overlay(A,B)    ((uint8)((B &lt; 128) ? (2 * A * B / 255):(255 - 2 * (255 - A) * (255 - B) / 255)))


Additionally you might want to check this package: blImage for source code as you can very easilly translate it. I am sure you will find what you are looking for.