- Hands-On Image Processing with Python
- Sandipan Dey
- 135字
- 2025-02-22 06:42:42
Convolution modes, pad values, and boundary conditions
Depending on what you want to do with the edge pixels, there are three arguments: mode, boundary, and fillvalue, which can be passed to the SciPy convolve2d() function. Here, we'll briefly discuss the mode argument:
- mode='full': This is the default mode, in which the output is the full discrete linear convolution of the input.
- mode='valid': This ignores edge pixels and only computes for those pixels with all neighbors (pixels that do not need zero-padding). The output image size is less than the input image size for all kernels (except 1 x 1).
- mode='same': The output image has the same size as the input image; it is centered with regards to the 'full' output.