Repository navigation
imgproc: fix phaseCorrelate ROI padding - #30725
Merged
Merged
Conversation
There was a problem hiding this comment.
Status: 🟡 Yellow
phaseCorrelate now isolates ROI inputs and ROI windows while zero-padding to the optimal DFT size, so copyMakeBorder cannot pull pixels from their parent matrices. The focused regression covers both supported depths, identical and translated inputs, cloned-versus-ROI behavior, and a window whose surrounding parent storage changes. I found no remaining source-level issue at this head; merge readiness is pending CI because this commit has no check result yet.
asmorkalov
approved these changes
Nov 9, 2026
abhishek-gola
approved these changes
Nov 9, 2026
6 tasks done
abhishek-gola
pushed a commit
that referenced
this pull request
Nov 13, 2026
…0782) * imgproc: do not read pixels outside a sub-matrix in CLAHE padding When the size is not a multiple of the tile grid, CLAHE pads the source on the right and bottom with BORDER_REFLECT_101. This padding is internal (CLAHE has no borderType). Without BORDER_ISOLATED, copyMakeBorder takes those rows and columns from the parent matrix when the source is a region of a larger image, so the histograms of the last tiles and the result depended on pixels outside the region. Same pattern as the phaseCorrelate fix in #30725. * imgproc: extend CLAHE_Padding to cover interior ROIs Move the ROI regression into CLAHE_Padding: the ROI now has parent pixels to its right and bottom, and the reference padding is isolated.
5 of 6 tasks
hardikkaurani
added a commit
to hardikkaurani/opencv
that referenced
this pull request
Nov 20, 2026
…cing padding When processing a sub-matrix with VNG Bayer demosaicing (COLOR_Bayer*2BGR_VNG and COLOR_Bayer*2RGB_VNG), copyMakeBorder uses BORDER_REFLECT_101 without BORDER_ISOLATED. This causes the internal 2-pixel boundary halo to be read from the surrounding pixels of the parent matrix rather than reflecting the region's own borders. Consequently, the outer 2 rows and columns of the demosaiced image depend on unrelated pixels in the parent buffer. This patch adds BORDER_ISOLATED to the copyMakeBorder call in Bayer2RGB_VNG_8u, ensuring the 2-pixel padding is strictly computed by reflecting the region boundary. This matches the behavior of isolated/cloned matrices and follows the same pattern as the CLAHE (opencv#30782) and phaseCorrelate (opencv#30725) ROI padding fixes. Also instantiates ImgProc_BayerEdgeAware_SubMatrix with VNG codes and CV_8U, covering sub-matrix source and destination regions across all 4 Bayer VNG codes with odd and even dimensions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The function
phaseCorrelate()usescopyMakeBorder()withBORDER_CONSTANTto pad the input matrices to ideal sizes for the DFT. When processing ROI-based matrices, this can cause pixels outside of the ROIs to be read. As a result, the output of the registration can differ between identically populated ROIs due to varying pixels in the parent matrices.This PR uses the existing padding option
BORDER_ISOLATEDfor the source matrices and optional window. A regression test has been added that uses parameterisation withCV_32FandCV_64F. The test compares different scenarios for ROI based inputs versus cloned inputs. The test checks for zero displacement, known integer displacement and ROI based windows with varying parent values around them. Both parameterised cases previously failed but now pass.Related work: #30281 and #30320 address the separate input-mutation issue when applying a window.
Pull Request Readiness Checklist