From f1a605c037285bb6d6cf07eb363f792a4a8ecbb8 Mon Sep 17 00:00:00 2001 From: bob <146524024+NUAAwqy@users.noreply.github.com> Date: Sat, 7 Nov 2026 21:39:27 +0800 Subject: [PATCH] Merge pull request #30662 from NUAAwqy:docs/medianblur-ksize-1 docs(imgproc): medianBlur also accepts ksize = 1 - #30662 ## Problem `cv::medianBlur` documents the aperture as > `@param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ...` but the implementation only requires an odd size: the aperture check is `(ksize % 2 == 1) && (_src0.dims() <= 2)`, and `ksize = 1` is accepted and returns the image unchanged (a 1x1 median is the pixel itself). Reproduced with opencv-python-headless 5.0.0: ``` cv2.medianBlur(img, 1) -> OK, output is identical to the input cv2.medianBlur(img, 2) -> error: "(ksize % 2 == 1) && (_src0.dims() <= 2)" in 'medianBlur' ``` ## Change Documentation-only: mention `ksize = 1` so the docs match the implemented behavior. No code change. Signed-off-by: NUAAwqy <162230229@nuaa.edu.cn> --- modules/imgproc/include/opencv2/imgproc.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/imgproc/include/opencv2/imgproc.hpp b/modules/imgproc/include/opencv2/imgproc.hpp index a0d3bb7329..ba5fc582d8 100644 --- a/modules/imgproc/include/opencv2/imgproc.hpp +++ b/modules/imgproc/include/opencv2/imgproc.hpp @@ -1278,7 +1278,7 @@ In-place operation is supported. @param src input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U. @param dst destination array of the same size and type as src. -@param ksize aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ... +@param ksize aperture linear size; it must be odd and positive, for example: 1, 3, 5, 7 ... (ksize = 1 returns the image unchanged) @sa bilateralFilter, blur, boxFilter, GaussianBlur */ CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize );