bob 71babee383 Merge pull request #30661 from NUAAwqy:docs/deriv-kernel-size-range
docs(imgproc): correct the documented Sobel kernel size range - #30661

## Problem

`cv::Sobel` and `cv::getDerivKernels` document the kernel size as

> `@param ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7.`
> `@param ksize Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.`

but `getDerivKernels` (modules/imgproc/src/deriv.cpp) actually enforces a different constraint:

```cpp
if( _ksize % 2 == 0 || _ksize > 31 )
    CV_Error( cv::Error::StsOutOfRange, "The kernel size must be odd and not larger than 31" );
```

so every odd size up to 31 is accepted, and `FILTER_SCHARR` (-1) selects the 3x3 Scharr kernels.

Reproduced with opencv-python-headless 5.0.0:

```
getDerivKernels(1, 0, 9)   -> OK, 9-tap kernel
getDerivKernels(1, 0, 15)  -> OK, 15-tap kernel
getDerivKernels(1, 0, 31)  -> OK, 31-tap kernel
getDerivKernels(1, 0, 33)  -> error: "The kernel size must be odd and not larger than 31"
getDerivKernels(1, 0, -1)  -> OK (Scharr 3x3)
cv2.Sobel(img, cv2.CV_32F, 1, 0, ksize=9/15)  -> OK
cv2.Sobel(img, cv2.CV_32F, 1, 0, ksize=101)   -> error (out of range)
```

## Change

Documentation-only: the two `@param ksize` entries now state the constraint the
implementation enforces (odd, not larger than 31) while keeping 1, 3, 5, 7 as the typical
choices. No code change.

Signed-off-by: NUAAwqy <162230229@nuaa.edu.cn>
2026-11-09 15:15:14 +03:00
2026-09-17 11:51:55 +03:00
2018-10-11 17:57:51 +00:00
2025-08-07 10:35:20 +03:00

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.

Additional Resources

Description
Languages
C++ 87.7%
C 3.1%
Python 2.9%
CMake 2%
Java 1.5%
Other 2.6%