Convolution#

Objectives#

  • know how to use the function scipy.ndimage.convolve to apply the convolution product

  • be able to identify the kernel applied on a convolved image

The point spread functions#

Before convolving the image by the different filters, it is interesting to display the filters themselves. In case there is no explicit matrix to represent a filter, as with the Gaussian filter skimage.filters.gaussian, we can simply convolve the filter by an image containing only one non-zero pixel. Indeed, this image is equivalent to a Dirac pulse \(\delta\) which is the neutral element of the convolution product.

The two last kernels are defined with (note the double brackets, so as to get a 2D array):

h = np.array([[1, -1]])

and

N = 30
h = np.ones((1,N)) / N

The convolutions#

The results of the convolutions are shown below, for both the “Dirac pulse” (first row) and the smiley (second row).

../_images/749426158f0081f25d88b494f075bf43ecf06c0db7dbe0f68d3f6f8867a8951a.png ../_images/ac5a78be83a2f3d995b2de31fc6f9fdf09b01e544c3c1ec8576bbae09bccc526.png

The function skimage.filters.gaussian defines a Gaussian kernel (this is the second image above). The result of the function is the convolution product of this Gaussian kernel with the image given as a parameter of the function.

The “gradient” image (third image) brings out the vertical contours of the image. We will reuse this filter in Edge detection.