Digital image processing (Digital Image Processing) is a method and technology for removing noise, enhancing, restoring, segmenting, and extracting features of an image through a computer. This column will summarize the key basic knowledge of digital image processing in the form of study notes. Welcome to learn and communicate together!
Column link: Digital image processing study notes
Spatial filtering example
Definition of spatial filtering and spatial filter
Image processing using spatial templates is called spatial filtering . The template itself is called a spatial filter .
On the M × N image f, use the m × n filter:
Where m = 2a + 1, n = 2b + 1, w (s, t) is the filter coefficient, and f (x, y) is the image value. Generally the minimum size is 3.
Simplified form of spatial filtering:
Where w is the filter coefficient, z is the image gray value corresponding to this coefficient, and mn is the total number of pixels included in the filter.
Linear filters can also use even size filters, but for ease of indexing, use odd size filters
Correlation and convolution concepts when performing spatial filtering
One filter
NOTE: This filter is a w-only filter, thus expanding the expansion at both sides thereof related operation is finished and then inverted convolution operation is first inverted and then
The basic characteristic of convolution is that a function is convolved with a unit impulse, and a copy of the function at the impulse is obtained. (The related operation also gets a copy of the function, but the copy is rotated by 180 °)
The correlation is different from this:
① The correlation is a function of filter displacement. The related first value (c) corresponds to the zero displacement of the filter, and the second value (d) corresponds to a unit displacement ...
② The filter w and the function containing all 0s and 1s (called discrete unit (Excited), the result is a copy of w, but rotated 180 ° (see the first line and the last line on the left)
Conclusion : a function is related to the impulse of discrete units, and the function is generated at the impulse position. A flipped version
Two-only filter
For a filter of size m × n, at least m-1 row 0 is filled at the top and bottom of the image, and n-1 column 0 is filled at the left and right sides
. It is the same as one correlation and convolution. The correlation is first operated and then inverted, and the convolution is rotated Post-operation
(in a two-dimensional case, rotating 180 ° is equivalent to flipping along one coordinate axis, and then flipping along another coordinate axis [ie, x, y axis flips twice])
If the filter template is symmetric, then the correlation and convolution get Results are consistent
Correlation can also be used to find matches in images
The role of smoothing spatial filters
☞ Blur: remove some unimportant details in the image
☞ reduce noise
Classification of smooth spatial filters
☞Linear filter: mean filter (including the average value of pixels in the filter neighborhood, also known as mean filter)
Function : reduce the "sharp" change of the image grayscale, reduce noise
because the image edge is caused by the image gray Caused by sharp changes in the degree, so there is also the problem of edge blur
☞ nonlinear filters: maximum filter, median filter, minimum filter
application
Application ①: De-noise (blur the small noise part, so as to achieve the purpose of denoising)
Application ②: Extract the part of interest (use a filter to remove the point size of the part to blur the image (Figure b), and then threshold to change the binary image (Figure c))
In fact, the "filter" principle in Photoshop also uses the content described above