Ask Your Question
8

Blending artifacts in OpenCV image stitching

asked 2016-03-01 16:41:20 -0600

Finfa811 gravatar image

updated 2020-10-24 03:39:41 -0600

Hi there,

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:

image description

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 the result even more.

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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
8

answered 2016-03-16 17:50:58 -0600

Finfa811 gravatar image

updated 2016-03-17 12:06:22 -0600

Artifacts appear using OpenCV 3.1.0, in 2.4.9 it's working perfectly.

The reason is because warped images were changed to be conformed by borderType BORDER_CONSTANT instead of by BORDER_REFLECT. That leads to black gaps in the images that will blur with foreground pixels in the pyramidal blending step, resulting in the mentioned artifacts. I show two examples of warped images to see the difference:

With BORDER_CONSTANT:

image description

With BORDER_REFLECT:

image description

First case is returning artifacts, second is working perfectly.

I've already reported the issue to change it back.

edit flag offensive delete link more

Comments

@Finfa811 Could you link to the corresponding issue or pull request if any?

Eduardo gravatar imageEduardo ( 2016-09-07 06:14:22 -0600 )edit
1

Hi @Eduardo, I commented the commit that should be reverted few months ago, but since I got no reply I've just opened an issue following your tip.

Finfa811 gravatar imageFinfa811 ( 2016-09-08 03:13:22 -0600 )edit

@Finfa811 I've seen that the issue is closed. But, has it been fixed? I have reproduced the same artifacts when using multi-band blender. I'm working with OpenCV 3.2.0.

SantiagoGil gravatar imageSantiagoGil ( 2017-05-01 15:15:04 -0600 )edit

The modification has been merged here. Your issue could come from another thing?

Eduardo gravatar imageEduardo ( 2017-05-03 04:16:55 -0600 )edit

Hi, Could I Use Multiband blender function for grayscale Images? I have to apply 16bit grayscale Image. But, I think this function support just 16SC3.. Please help me. I want to apply to 16UC1

lighthacker gravatar imagelighthacker ( 2017-11-24 03:07:11 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2016-03-01 16:41:20 -0600

Seen: 9,064 times

Last updated: Apr 23 '16