Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV Seamless Cloning shift position after finish the process

I am trying to used the seamsless cloning to blend to image together. but I notice that after using the seamsless clone function the area in the mask that I want to transfer is shift upward. So I have a question that is this a normal behaviour of the seamsless clone function or it is a bug on my implementation.

Here are the Source photo

enter image description here

Here are the destination photo

enter image description here

Here are the result photo

enter image description here

like image 817
Supason Kotanut Avatar asked Oct 28 '22 21:10

Supason Kotanut


1 Answers

I encountered similar situation. Moreover, like @JoshuaCWebDeveloper noted, this shift disappeared when all one mask is used. Nevertheless, I got a fix for this. What I did is this. I cropped valid mask (non-zero sub-section) out using cv2.boundingRect. So my source image and mask image are reduced to a smaller size, while center is now calculated from boundingRect outputs (Since reference point is marked on destination image). This way, error got solved/shift got ridden.

like image 130
Fractalic Forieu Avatar answered Dec 24 '22 23:12

Fractalic Forieu