2
$\begingroup$

I am using OpenCV to blend a set of pre-warped images. As input I have some 4-channel images (*.png or *.tif) from where I can extract a bgr image and an alpha mask with the region related to the image (white) and the background (black). Both image and mask are the inputs of the Blender module cv::detail::Blender::blend.

When I use feather (alpha) blending the result is ok, however, I would like to avoid ghosting effects. When I use multi-band, some artifacts are appearing on the edges of the images:

enter image description here

The problem is similar to the one raised here, and solved here. The thing is, if the solution is creating a binary mask (that I already extract from the alpha channel), it does not work for me. If I add padding to the ovelap between both images, it takes pixels from the background and messes up even more the result.

I guess that probably it has to do with the functions pyrUp and pyrDown, because maybe the blurring to create the Gaussian and Laplacian pyramids is applied to the whole image, and not only to the positive alpha region. In any case, I don't know how to fix the problem using these functions, and I cannot find another efficient solution.

When I use another implementation of multiresolution blending, it works perfectly, however, I am very interested in integrating the multi-band implementation of OpenCV. Any idea of how to fix this issue?

$\endgroup$

2 Answers 2

0
$\begingroup$

You need a edge detection algotithm witch will filter the critical edges and then create out of them an binary image. That image will give you an region to blur and the rest should tay the same. This should avoid the water stains or ghost efects.

$\endgroup$
5
  • $\begingroup$ I can extract the binary image from the alpha channel. But then, how to create a gaussian pyramid from just the white region of the image (not using the background)? $\endgroup$
    – Finfa811
    Mar 4, 2016 at 8:36
  • $\begingroup$ Basicly you take the edge detection images (not binary, because the edge detection gives you intensity of an edge, filter all low intensity edges out) of two fields that should overlap and build an alghorithm that gives you the most amount of overlaping by moving the images around an comparing the added values. Then the water stains will bee less. The parts where the edges do not overlap need to be blured. All of this can be done with and standard deviation equation per overlaped layer. $\endgroup$ Mar 8, 2016 at 16:57
  • $\begingroup$ Alignment is already fine... and I don't follow you with the rest. Do you mean bluring non-overlaping regions between edge images and then averaging pixel intensities on the edges in every layer of the pyramid? $\endgroup$
    – Finfa811
    Mar 13, 2016 at 17:00
  • $\begingroup$ Yep. This should do the trick. But you will probably always have smo artefacts. Witch have to be interpolated. The thig is that your edges do not overlap perfectly those regions have to be detected and blured. $\endgroup$ Mar 14, 2016 at 6:58
  • $\begingroup$ I've already fixed the issue. Problem was in OpenCV version. Basically the padding added to the warped image was filled with black pixels instead than with pixels from the image. That resulted in artifacts after bluring & rezising the image to create the pyramid for blending step. You can check the reported answer. $\endgroup$
    – Finfa811
    Mar 16, 2016 at 23:10
0
$\begingroup$

Issue has been already reported and solved here:

http://answers.opencv.org/question/89028/blending-artifacts-in-opencv-image-stitching/

$\endgroup$
2
  • $\begingroup$ Can you explain more clearly? So use border reflect or border reflect 101 rather than border constant? $\endgroup$ Nov 21, 2019 at 9:52
  • 1
    $\begingroup$ @mLstudent33 yes, that was the bug that I reverted in the original OpenCV code. Follow the link to the opencv forum for a better technical explanation. $\endgroup$
    – Finfa811
    May 12, 2020 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.