c++ - Trying to translate formula for blending mode -


I am using opencv c ++ to create the compositing mode such as photoshop In this mode I want to create an overlay, I find my alternative in OpenCV, in which I found the path, but as an overlay I want to use the overlay method in it.

  (target = 0.5) * (1 - (1-2 * (target -0.5)) * (1-blend)) + (target & lt; = 0.5) * ((* 2 * target) * Blend) Can anyone explain this formula for implementation in OpenCV C ++, how can I easily implement it for implementation Anyone can understand or create any  in advance  function for the second easy way: p  

is actually overlay blending Is multiply to light colors

First of all, provided by you The author of the link assumes that a pixel color as a value between 0 and 1

Imagine that you want to combine 2 mages img1 and img2 . The formula states that if a value in img1 is target> 0.5 then the resultant value (1 - (1-2 * (target -0.5)) * (1-blend)) for mixed image where blend < The value of the pixel of code> img2 is.

On the other hand, if targets < = 0.5 The resulting color will be ((* 2 * target) * blend) .

You have to do this for each pixel.

Provides overlay-matching function with OpenCV.

Here is an example with a grayscale image for the RGB image, you have to do this for each channel. Of course the size of img1 and img2 should be the same. There may be a faster way to do this with OpenCV.

  Mat img1; Mat IMG 2; Img1 = imread ("img1.jpg", CV_LOAD_IMAGE_GRAYSCALE); Img2 = imread ("img2.jpg", CV_LOAD_IMAGE_GRAYSCALE); Mat result (IMG 1. (), CV_32 F); For (int i = 0; i & lt; img1.size (). Height; ++ i) {for (int j = 0; j & lt; img1.size (). Width; ++ j) {float Goal = Float (Img1.at  (i, j)) / 255; Float mix = float (IMG 2.et  uchar> (I, J)) / 255; If (Goal> 0.5) {result.at & lt; Float & gt; (I, j) = (1 - (1-2 * (target -0.5)) * (1-mix)); } Other {result.at    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -