Repository navigation
imgproc: avoid padding divisible dimensions in CLAHE - #30304
Merged
asmorkalov merged 3 commits intoOct 21, 2026
Merged
Conversation
Contributor
Author
|
The current |
asmorkalov
approved these changes
Oct 20, 2026
asmorkalov
approved these changes
Oct 21, 2026
asmorkalov
approved these changes
Oct 21, 2026
6 tasks done
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.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.
CLAHE::applypads both dimensions whenever either dimension is not divisible by the tile grid. For an image with 80 rows and 81 columns and an 8x8 grid, the height already fits, but the implementation adds eight reflected rows anyway. The resulting 11-pixel tile height changes the histograms and interpolation across the image; only seven columns are needed to obtain tiles 11 pixels wide and 10 pixels high.Compute the minimum reflected padding independently for each dimension in both the CPU and OpenCL paths. Images with both dimensions divisible, or neither dimension divisible, retain their existing tile geometry. No public interface changes.
Reproduction (applies to both
uint8anduint16):Testing on
b254d3455a, Linux x86-64, GCC 15.2, Release, IPP disabled, OpenCL enabled with PoCL 6 CPU device (OPENCV_OPENCL_DEVICE=:CPU:,POCL_MAX_PTHREAD_COUNT=4,OPENCV_FOR_THREADS_NUM=2):9d80321677with only the new tests: 88 failed, 64 passed. All 24 new OpenCL cases fail; the remaining failures are the CPU mixed-divisibility cases.opencv_test_imgproc --gtest_filter="*CLAHE_Padding*:*CLAHETest.ReflectedBorder*": 152 passed.OPENCV_TEST_DATA_PATH=~/ocv-testdata opencv_test_imgproc --gtest_filter="*Hist*:*BackProject*:*CLAHE*": 232 passed, including the existing OpenCL CLAHE accuracy tests. The initial run lackedcv/optflow/RubberWhale1.png; rerunning with the officialopencv_extraimage passed.opencv_perf_imgproc --gtest_filter="*CLAHE*" --perf_min_samples=10 --perf_force_samples=10: 12 existing CLAHE performance cases passed, plus four framework checks.git diff --check: passed.801fea96e3: renamed the OpenCL test RNG to avoid shadowing its fixture member. Rebuiltopencv_test_imgprocwith no compiler warnings and reran the selected accuracy suite: 232 passed.The regression matrix covers 8-/16-bit inputs, square/rectangular/single-axis grids, all divisibility combinations, clipping, strided inputs, and in-place use. OpenCL cases cover both axes and UMat offsets. No additional test data is needed. Full imgproc suite and physical GPU execution were not run.
The reproduction above is the original report; no earlier issue or competing fix was found.