Spatial filtering is a kind of image enhancement method using filter processing. Its theoretical basis is spatial convolution and spatial correlation. The aim is to improve image quality.
A template for spatial filtering is called a spatial filter.
The word filter is borrowed for frequency domain processing. The intention is that the signal has a variety of frequency components, filter out the unwanted ingredients, that is, to filter out often said noise, leaving the desired ingredient, which is both the process of filtering, but also the purpose of filtering.
There are one by one correspondence between linear spatial filtering and frequency domain filtering. Spatial filtering can provide a considerable amount of functionality and can also be used in nonlinear filtering, which is not available in the frequency domain. spatial filtering mechanism
At any point in the image (x, y), the response g (x, Y) of the filter is the sum of the product of the filter coefficients and the image pixels surrounded by the filter.
In general, a filter of size M * n is used for linear spatial filtering of images of size M * N, which can be represented by the following formula:
W is the coefficient of the filter, and F is the pixel value. For the M * N template, we assume that M = 2a + 1,n = 2b + 1,a,b is a positive integer.spatial correlation and convolutionWhen performing linear spatial filtering, it is important to understand the two concepts clearly first. Correlation and convolution. Correlation is the filter template moves over the image and calculates the processing of the sum of the product of each position. The convolution process is similar, but the filter first rotates 180 °. eg The following examples explain the process of correlation and convolution.
There are several points to note: First, correlation is the function of the filter displacement. Second, the filter w is related to a function that contains only one 1 of the remaining 0, and the resulting result is a 180° filter W. We will only contain one 1 of the rest of the 0 functions calledDiscrete Unit Impulse。 Therefore, we can draw a conclusion: a function is associated with a discrete unit impulse, which produces a flipped version of the function at that impulse position.
The concept of convolution is the cornerstone of the theory of linear systems. The basic feature of convolution is that a function and a unit impulse convolution, resulting in a copy of this function at that impulse.
The previous concept is easily extended to the image. For filters with size M * N, we need to fill the top and bottom of the image with M-1 line 0, fill n-1 column 0 on the left and right. eg Suppose the size of the filter is 3 * 3.
If the image f contains an area exactly equal to W in the center of the image, when W is at the center of the F-zone, the value of the correlation function (normalized) will be the largest. In this case, the correlation can also be used to find matches in the image.
Let's summarize the previous discussion with a formula. A filter w (x, y) of size M * n is associated with an image f (x, y) and can be expressed as
Similarly, the convolution of W (x, Y) and F (x, Y) is represented as
Where the minus sign to the right of the equation means flip f (that is, rotate 180°). To simplify symbolic representations, we follow the convention of flipping shifts w instead of F. The result is the same.
The preferred method for performing spatial filtering using correlation or convolution. In fact, whether it is convolution or related, we can use a simple translation filter to perform its function, it is important that in a given filter task, the corresponding to the desired operation of the way to specify the filter template. It is also important to note that in the image processing literature, we are likely to encounter the terms of convolutional filters, convolution templates, or convolutional cores. By convention, these terms are used to denote a spatial filter, and the filter may not be used for real convolution. Similarly, templates and image convolution are often used to represent the sum of the sliding products we discussed earlier, without having to differentiate between correlation and convolution. More appropriately, it is typically used to represent one of two operations. This less stringent term is the source of confusion.vector representation of linear filteringWhen our interest lies in the response characteristic r of a related or convolution template, sometimes it is convenient to write a summation of the product:
Where W is a filter coefficient of size M * N, and z is the grayscale value of the corresponding image covered by the filter.