Image processing (Chapter 5, image enhancement, gray enhancement, histogram processing, histogram equalization, spatial filtering, frequency domain filtering, homomorphic filtering)

Chapter 5 Image Enhancement

5.1 The concept of image enhancement

(1) Purpose:
Use certain technical means to improve the visual effect of the image, or convert the image into a form more suitable for human observation and machine analysis and recognition, so as to obtain more useful information from the image.

(2) Classification:
Image enhancement methods are divided into two categories: spatial domain methods and frequency domain methods.

"Spatial domain" refers to the image plane itself. This type of method is based on the direct processing of the pixels of the image.

The "frequency domain" processing technique is based on the Fourier transform of the modified image.

5.2 Airspace enhancement technology

(1) Definition
Spatial domain enhancement refers to the enhancement of pixels that constitute an image through linear or nonlinear transformation in the spatial domain.

The enhanced methods are mainly divided into two categories: point processing and template processing :

① Point processing is a spatial domain processing method that acts on a single pixel, including image grayscale transformation, histogram processing, pseudo-color processing and other technologies;

② Template processing is a processing method that acts on the pixel neighborhood, including spatial smoothing, spatial sharpening and other technologies.

5.2.1 Image enhancement based on direct grayscale (same as Chapter 3)

(1) Definition:
The gray level r in the input image f (x, y) is mapped to the gray level s in the output image g (x, y) through a mapping function. The result of the calculation is adjacent to the image pixel position and the processed pixel. The domain gray level is irrelevant.

(2) Classification:

①Objects enhanced by linear transformation:
In the case of under-exposure or over-exposure, the image gray scale may be limited to a small range. What you see on the monitor at this time will be a blurry image that does not seem to have gray levels. The gray-scale linear transformation method can stretch the gray-scale dynamic range and make the image clear.
Insert picture description here
② Piecewise linear transformation function
Definition: Similar to linear transformation, it stretches the gray contrast of the input image, but performs different mapping processing for different gray scale ranges.
Insert picture description here
③Reverse transformation
Insert picture description here
④Logarithmic transformation
Insert picture description here

5.2.2 Image enhancement based on histogram processing

The gray level histogram is a statistical expression of an image, which reflects the statistical probability of different gray levels in the image.
Insert picture description here
Normalization, then probability
Insert picture description here
classification: histogram equalization, histogram regularization

5.2.2.1 Histogram equalization

(1) Definition
Through the equalization of the image gray histogram, the gray distribution of the image tends to be uniform, and the pixel gray spacing occupied by the image is stretched, which increases the image contrast, improves the visual effect, and achieves the purpose of enhancement.
(2)
Insert picture description here
The result obtained by the process
Insert picture description here
(3) Example 5.2 The
first column is the condition of the question, and the number of pixels of the k-th gray level in the third column is also the condition of the question, and everything else must be calculated by yourself.

The second column of normalized gray level (r k ) is the k value corresponding to the first column divided by n (total).

The fourth column p r (r k ) "probability density function of the original image gray distribution" is the number of pixels corresponding to the third column divided by the total number of the third column. For example, the first line is 0.19=790/(790+1023+850+656+329+245+122+81).

The gray scale transformation function of the sk histogram equalization in the fifth column is the corresponding cumulative sum before the third column. For example, 0.65=0.19+0.25+0.21 in the third row can also be 0.65=0.44+0.21. The 5/7 in parentheses in the third row means that the result 0.65 is 0.7142 which is closer to the 5/7 in the second column than the other values ​​in the second column.

The transformed gray level in the sixth column is used to represent the number in the fifth column in parentheses. For example, the fifth column in the third row is 5/7, and the sixth column is s 5 .

The n sk in the seventh column is the sum of the number of pixels of the gray level corresponding to the sixth column. For example, 985=656+329 in the fourth column

The p( sk ) in the eighth column is the sum of the probabilities of the gray levels corresponding to the sixth column. For example, 0.24=0.16+0.8 in the fourth column

The three vacancies in the seventh and eighth columns can be filled or not filled, because there are repetitions.
Insert picture description here
The histogram describes the relative frequency of each gray level in the image,

The histogram equalization makes the grayscale distribution of the image tend to be uniform, and the grayscale spacing of the image pixels is stretched, thereby increasing the image contrast, improving the visual effect, and achieving the purpose of image enhancement.

5.2.3 Spatial domain filtering enhancement

(1) Spatial domain filter enhancement uses template processing to filter the image to remove image noise or enhance image details.

Analysis: Any original image, during its acquisition and transmission, will be interfered by various noises, which will deteriorate the image, reduce its quality, blur the image, and submerge its features, which is detrimental to image analysis.

In order to suppress noise and improve image quality, the process is called image smoothing or denoising.

(2) Method
①Local smoothing method
(average with noise, neighborhood average method)
②Out-of-limit pixel smoothing method
(less than the threshold value is the original, greater than the threshold value is the neighborhood average)
③K neighbors with the closest gray scale Average method
( averaging method of k neighboring points with the closest gray value, k needs to be customized)
④Spatial low-pass filtering method
(using convolution or Fourier transform spectrogram) (ps: spectrogram is frequency Domain is not airspace)

ps: Spatial domain smoothing and sharpening can be achieved by operator convolution

Insert picture description here

5.2.3.2 Spatial domain sharpening filter (emphasis)

(1) Definition
Image sharpening is to enhance the edge or contour of an image.
Image smoothing makes the edge of the image blurred through the integration process , and sharpening makes the image edge prominent and clear through differentiation . (2) Method (no need to remember the operator) ① Use gradient operator to sharpen ② Laplacian method


Insert picture description here

Insert picture description here
③Low-frequency component subtraction method
Use the original image-low-pass image
or reduce the low-frequency component in the spectrogram (ps: the spectrogram is in the frequency domain, not in the spatial domain)

5.3 Frequency domain enhancement technology

(1) Principle
Time domain convolution is equivalent to frequency domain product. Therefore, the filter can be designed directly in the frequency domain to enhance the signal.

(2) Classification
Common methods include high-pass and low-pass filtering, homomorphic filtering and so on.

5.3.1 The principle of Fourier transform and frequency domain enhancement (understand it)

First Fourier transform fft2(), then inverse Fourier transform ifft2()

5.3.2 Frequency domain smoothing filter (just understand)

(1) defines
the image space domain linear convolution actually neighborhood filter filters the image signal after frequency components, such functionality may be implemented in the transform domain, i.e., the original image for forward transform , to design a filter with The point operation method processes the spectrum data (transformation coefficients), and then performs the inverse transformation to complete the processing. The key here is to design the transfer function H(u,v) of the frequency domain (transform domain) filter .

(2) Classification

① Ideal low-pass filter
where the cut-off frequency is D 0
Insert picture description here

②Butterworth Butterworth low-pass filter
Insert picture description here
Insert picture description here
③ Exponential low-pass filter
Insert picture description here

④ Trapezoidal low-pass filter

Insert picture description here

5.3.3 Frequency domain sharpening filter

(1) Definition
The edges and details of the image are mainly located in the high frequency part, and the blur of the image is caused by the relatively weak high frequency components. The frequency domain sharpening is to eliminate blur and highlight edges.

Therefore, a high-pass filter is used to pass high-frequency components and weaken low-frequency components, and then undergo inverse Fourier transform to obtain an image with sharp edges.

(2) Classification ①Ideal
high-pass filter
Insert picture description here
②Butterworth Butterworth high-pass filter
Insert picture description here
Insert picture description here
ps: Butterworth's high-pass and low-pass filters are actually D(u, v) and D 0 in the formula swap positions

Butterworth low-pass:
Insert picture description here
③Exponential high-pass filtering
Insert picture description here

④Ladder-shaped high-pass filter
Insert picture description here

5.3.4 Homomorphic Filter

Insert picture description here

(1) The definition of
homomorphic filtering belongs to the category of image frequency domain processing. Its function is to adjust the image gray range. By eliminating the problem of uneven illumination on the image, it can enhance the image details in the dark area without losing the image in the bright area. detail.

The gray scale of the image that our human eyes can get is not only determined by the illumination function (illumination component), but also related to the reflection function (reflection component), which reflects the specific content of the image.

Light intensity generally consistent, there is usually spatially slowly varying nature, is realized in the Fourier transform low-frequency component , but not the same as the reflectance of a material quite different, often causes abrupt change in the reflected light , so that The gray value of the image changes, and this change is related to the high and low frequency components . In order to eliminate the influence of uneven illumination and enhance the details of the high-frequency part of the image , a homomorphic filter built in the frequency domain can be used to process images with insufficient illumination or illumination changes , which can minimize the image quality caused by insufficient illumination Decrease , and effectively enhance the scene of interest, so that the original image can be enhanced to a large extent.

(2) Homomorphic filtering process (should test the code)

In the code:
Insert picture description here


Insert picture description here
② Take the logarithm
Insert picture description here

③Fourier transform
Insert picture description here

Filter ④
Insert picture description here
⑤ inverse transform
Insert picture description here
⑥ take index
Insert picture description here
Insert picture description here
ps: Book said p98: a filter function tends to reduce the low frequency contribution (illuminance), and increase high frequency (reflected) contribution, the result is simultaneously compressed dynamic range and contrast enhancement

Guess you like

Origin blog.csdn.net/weixin_44575911/article/details/112687893