Main Content

What Is Image Filtering in the Spatial Domain?

Filtering is a technique for modifying or enhancing an image. For example, you can filter an image to emphasize certain features or remove other features. Image processing operations implemented with filtering include smoothing, sharpening, and edge enhancement.

Filtering is aneighborhood operation,in which the value of any given pixel in the output image is determined by applying some algorithm to the values of the pixels in the neighborhood of the corresponding input pixel. A pixel's neighborhood is some set of pixels, defined by their locations relative to that pixel. (SeeNeighborhood or Block Processing: An Overviewfor a general discussion of neighborhood operations.)Linear filteringis filtering in which the value of an output pixel is a linear combination of the values of the pixels in the input pixel's neighborhood.

Convolution

Linear filtering of an image is accomplished through an operation calledconvolution. Convolution is a neighborhood operation in which each output pixel is the weighted sum of neighboring input pixels. The matrix of weights is called theconvolution kernel, also known as thefilter. A convolution kernel is a correlation kernel that has been rotated 180 degrees.

For example, suppose the image is

A = [17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9]

and the correlation kernel is

h = [8 1 6 3 5 7 4 9 2]

You would use the following steps to compute the output pixel at position (2,4):

  1. Rotate the correlation kernel 180 degrees about its center element to create a convolution kernel.

  2. Slide the center element of the convolution kernel so that it lies on top of the (2,4) element ofA.

  3. Multiply each weight in the rotated convolution kernel by the pixel ofAunderneath.

  4. Sum the individual products from step 3.

Hence the (2,4) output pixel is

Shown in the following figure.

Computing the (2,4) Output of Convolution

Correlation

The operation calledcorrelationis closely related to convolution. In correlation, the value of an output pixel is also computed as a weighted sum of neighboring pixels. The difference is that the matrix of weights, in this case called thecorrelation kernel, is not rotated during the computation. The Image Processing Toolbox™ filter design functions return correlation kernels.

The following figure shows how to compute the (2,4) output pixel of the correlation ofA, assumingh相关的内核而不是康沃变频器吗lution kernel, using these steps:

  1. 幻灯片的中心元素相关的内核so that lies on top of the (2,4) element of A.

  2. Multiply each weight in the correlation kernel by the pixel ofAunderneath.

  3. Sum the individual products.

The (2,4) output pixel from the correlation is

Computing the (2,4) Output of Correlation

See Also

||

Related Topics