Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong/misleading placement of seamlessClone source image #21902

Closed
3 of 4 tasks
sfaroy opened this issue Apr 23, 2022 · 1 comment
Closed
3 of 4 tasks

Wrong/misleading placement of seamlessClone source image #21902

sfaroy opened this issue Apr 23, 2022 · 1 comment

Comments

@sfaroy
Copy link

sfaroy commented Apr 23, 2022

System information (version)
  • OpenCV => 4.2
Detailed description

When I tested seamlessClone, I have noticed that the placement of the crop that I used is different from the case where I use simple alpha-blend. Digging into the code, I have noticed this:

Rect roi_s = boundingRect(mask);
if (roi_s.empty()) return;
Rect roi_d(p.x - roi_s.width / 2, p.y - roi_s.height / 2, roi_s.width, roi_s.height);

Meaning that seamless clone, crops the src image, and the mask to remove zero margins from the mask - this is probably for improving the performance of the module. In this process, seamlessClone places the cropped source image on the destination image where the Point p is the center of the cropped source (after margin removal) - and not the center of the original source. This will cause a deviation in relation to the original InputArray _src that is provided to the function.

I think that this behavior is wrong or at least misleading - as when a developer uses the seamlessClone function, the information that is generally available (in the debug phase) - is the shapes of the destination, source & the mask images (knowing the zero margins is not always trivial). If this is intentional, then it should be documented here:
https://docs.opencv.org/4.x/df/da0/group__photo__clone.html#ga2bf426e4c93a6b1f21705513dfeca49d

I suggest adding an offset to the destination ROI that will cancel the change of location of the original src image. The offset can be added here:

Rect roi_d(p.x - roi_s.width / 2, p.y - roi_s.height / 2, roi_s.width, roi_s.height);

Thanks,
Roee

Issue submission checklist
  • I report the issue, it's not a question

  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution

  • I updated to the latest OpenCV version and the issue is still there

  • There is reproducer code and related data files: videos, images, onnx, etc

@syguan96
Copy link

I also met this problem. This behavior is quite weird.

@asmorkalov asmorkalov removed the RFC label Dec 19, 2024
@asmorkalov asmorkalov added this to the 4.11.0 milestone Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants