skip to Main Content

I am trying to add some blur brush stroke with OpenCV

If I use cv.add or cv.addweighted, I only got half of the red color (look pink),

but I want the red to cover the underlying picture, not blend.

If I use copyto or clone, I can’t get the blur edge, so how should I do it ??

Paint Brush

enter image description here

2

Answers


  1. Chosen as BEST ANSWER

    I got a trick to do it simply copy the area to a new mat, then draw a circle and blur it on the new mat, and use addWeighted to blend it to the image with whatever alpha I need.

    Mat roi = myImage.submat(y-20, y+20, x-20, x+20);
    Mat mix = roiB.clone();
    
    Imgproc.circle(mix, new Point(20, 20), 12, color, -1);
    Core.addWeighted(mix, alpha, roiB, beta, 0.0, mix);
    Imgproc.GaussianBlur(mix, mix, new Size(21, 21), 0);
    
    mix.copyTo(roiB);
    

  2. The background of your brush image is black. If you were in photoshop and set that brush layer’s blend mode to screen the red gradient would show through and the black background would become transparent.

    Here are a couple of relevant posts:

    Alternatively, if you’re using OpenCV 3.0 you try using seamlessClone.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search