Search code examples
opencvimage-processingedge-detectionsobel

OpenCV Sobel kernel aperture size 7 or 31


The OpenCV documentation states that the maximum kernel size for the Sobel function is 7:

ksize:  size of the extended Sobel kernel; it must be 1, 3, 5, or 7. 

Here's the link to the documentation:

https://docs.opencv.org/trunk/d4/d86/group__imgproc__filter.html#gacea54f142e81b6758cb6f375ce782c8d

However, when coding I'm able to use a ksize up to 31 (over 31 gives an error). For example, I can execute the following:

cv2.Sobel(src=image, ddepth=-1, dx=1, dy=0, ksize=31)

Why does the documentation say up to 7, when it is allowed up to 31?


Solution

  • Apparently the kernel is padded with zeroes after the size exceeds 7x7.