The fast realization of frequency domain filtering is a milestone in engineering field. The most exciting reason for engineers in frequency domain filtering is from this formula:
F (x) *g (y) <-->f (U) g (v)
This shows that the complex convolution operator in the spatial domain becomes a simple multiplication in the frequency domain, which is simple in calculation and easy to implement in engineering. Before the digital realization of FFT and fast DCT (cosine transform), the computation of frequency domain transformation is very troublesome, and the computational efficiency is not much faster than that of ordinary convolution; after FFT and fast-read DCT, the frequency domain signal processing is almost ubiquitous.
The filter operator in the spatial domain can be transformed into a frequency domain filter operator. Assuming that the current image size is 512x512 and the filter operator is 3x3, it is obvious that the result of the frequency domain conversion directly to the filter operator is still 3x3, which cannot be multiplied. This needs to be explained from the definition.
The definition of convolution is: F (t) *g (t) = if f and g are periodic functions of different periods, then we need to use 0 complement function period, to ensure that the function f ' and G ' have the same period, and then convolution; it is not guaranteed that the F and G functions will be convolution in the same period, result in the mixing of filter results for different periods.
Back to the original spatial filter, our operation is to traverse the current graph 512x512 each pixel, with a 3x3 template for the current pixel domain convolution operation. In fact, this is a simplified operation, the real operation is to build 512x512 size convolution template, the upper left corner of the 3x3 element is the implementation of the spatial domain filter operation operator element, the remaining elements are all 0, with this 512x512 convolution template for the image of the two-dimensional convolution. Since the elements except the 3x3 are all 0, we only need to calculate the value of the 3x3 template range, which looks like only the 3x3 convolution template is used to manipulate the current pixel neighborhood.
Understand the 512x512 image of the spatial filter operator is actually 512x512 size, then we can realize from the spatial domain filtering to the frequency domain filter. Constructs a 512x512 filter operator, puts the 3x3 template parameter in the operator upper left corner (causes the filter result to be strange in the different position, is compared with the like is the cyclic displacement), then carries on the frequency domain transformation to generate the 512x512 frequency domain template, and multiplies it with the frequency domain image (note If the frequency domain image is centered, Then the frequency domain template should also be centralized, and then restore to the spatial domain image, and then complete the same frequency domain filter as the spatial domain filter results.
is the frequency domain filter flawless? Of course not. Assuming that my image size is 512x512 and the grayscale range is 0~255, then each pixel needs only 1 byte, 512x512 bytes, and after frequency domain filtering, I need two float or even double matrix to represent the real and imaginary parts of the frequency domain image. This requires 512x512x4x2 or 512x512x8x2 bytes, a sudden memory consumption more 8~16 times, if the frequency domain conversion accuracy is not high enough, after the frequency domain conversion and then restore to the spatial domain of the image will have a signal loss, and will not be completely restored to the original image. Please note that the compression algorithm commonly used by the computer will be converted in frequency domain, because after the frequency filtering, most of the image information is concentrated near the origin and a few other areas, most of the area is unimportant, or the value is 0, which can greatly reduce the storage size of the data, but in the actual calculation, Compressed data is generally extracted to the original data to perform related calculations and display operations, so the frequency domain method can help to compress data storage, but does not contribute to reducing the size of the data in the calculation.
From image spatial domain filtering to frequency domain filtering