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>
This commit is contained in:
bob
2026-11-07 21:39:27 +08:00
committed by GitHub
parent e2c04b9cac
commit f1a605c037

View File

@@ -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 );