Design and Realization of Digital Image Processing Based on MATLAB

Design and Realization of Digital Image Processing Based on MATLAB


1. Subject introduction

Digital image processing is an emerging technology. With the development of computer hardware, real-time processing of digital images has become possible. Due to the emergence of various algorithms for digital image processing, its processing speed is getting faster and faster, and it can better serve People serve. Digital image processing is a technology that uses certain algorithms to process graphics and images by computer.

Purpose: To improve the quality of medical images and enhance them.

Methods: Using the Matlab toolbox function, the method of gray histogram equalization and high-pass filtering is used to enhance an X-ray image.

Results: Using the algorithm of histogram equalization, the dense gray distribution of the original image becomes relatively sparse, and the visual effect of the processed image is improved. High-pass filtering can significantly enhance local details, and after high-pass filtering, details that are not easy to be observed become clear.

Conclusion: Using the Matlab toolbox greatly simplifies the programming work, and provides a technical platform for medical image processing. After histogram equalization and high-pass filtering, the visual effect of the medical image is improved.

1.1 Purpose and significance of the subject research

Digital Image Processing (Digital Image Processing) is to use digital computers or other digital hardware to perform certain mathematical operations on electrical signals converted from image information to improve the practicability of images. For example, the feature parameters of the target are extracted from satellite images, and the reconstruction of three-dimensional tomographic images, etc. In general, digital image processing includes point operations, geometric processing, image enhancement, image restoration, image morphology processing, image coding, image reconstruction, pattern recognition, etc.

Due to the continuous enhancement of computer processing capabilities, while the subject of digital image processing is developing rapidly, it is also rapidly cross-penetrating into many other subjects, making images as information acquisition and information utilization become more and more important. . At present, the application of digital image processing is more and more extensive, and has penetrated into various fields such as industry, medical care, aerospace, military, etc., and plays an increasingly important role in the national economy.

The MATLAB software launched by MathWorks is a good helper for learning mathematical knowledge. Applying MATLAB's friendly interface and rich, practical and efficient instructions and modules can help people quickly recognize and understand related concepts of image processing, gradually master the basic methods of image signal processing, and then be able to solve problems in related engineering and scientific research. question.

Images are the main source of information for human beings to acquire and exchange. Therefore, the application fields of image processing must involve all aspects of human life and work. With the continuous expansion of the scope of human activities, the application field of image processing will also continue to expand, and it has played an increasingly important role in national security, economic development, and daily life, and its role in the national economy and people's livelihood cannot be underestimated.


2 Task realization function

2.1 Research content

The main research contents of digital image processing are as follows:

(1) Image transformation. Since the image array is very large, processing directly in the spatial domain involves a large amount of computation. Therefore, various image transformation methods are often used, such as Fourier transform, Walsh transform, discrete cosine transform and other indirect processing techniques, to convert the processing of the spatial domain into the processing of the transform domain, which can not only reduce the amount of calculation, but also obtain more effective processing (for example, Fourier transform can perform digital filtering in the frequency domain). The wavelet transform, which is newly researched at present, has good localization characteristics in both the time domain and the frequency domain, and it also has a wide and effective application in image processing.

(2) Image coding and compression. Image coding compression technology can reduce the amount of data describing the image (that is, the number of bits), so as to save image transmission, processing time and reduce the occupied memory capacity. Compression can be achieved without distortion or with distortion allowed. Coding is the most important method in compression technology, and it is the earliest and relatively mature technology in image processing technology.

(3) Image enhancement and restoration. The purpose of image enhancement and restoration is to improve the quality of the image, such as removing noise and improving the clarity of the image. Image enhancement does not consider the cause of image degradation, and highlights the interesting part of the image. For example, strengthening the high-frequency components of the image can make the outline of objects in the image clear and the details obvious; if strengthening the low-frequency components, it can reduce the influence of noise in the image. Image restoration requires a certain understanding of the reasons for image degradation. Generally speaking, a "degradation model" should be established according to the degradation process, and then some filtering method should be used to restore or reconstruct the original image.

(4) Image segmentation. Image segmentation is one of the key technologies in digital image processing. Image segmentation is to extract the meaningful features in the image. The meaningful features include edges and regions in the image, which is the basis for further image recognition, analysis and understanding. Although many methods of edge extraction and region segmentation have been researched, there is no effective method that is generally applicable to various images. Therefore, the research on image segmentation is still going deep, and it is one of the hot spots in image processing.

(5) Image description. Image description is a necessary prerequisite for image recognition and understanding. As the simplest binary image, its geometric characteristics can be used to describe the characteristics of objects. The general image description method uses two-dimensional shape description, which has two types of boundary description and area description. Two-dimensional texture features can be used to describe special texture images. With the in-depth development of image processing research, research on three-dimensional object description has begun, and methods such as volume description, surface description, and generalized cylinder description have been proposed.

(6) Image classification (recognition). Image classification (recognition) belongs to the category of pattern recognition. Its main content is to perform image segmentation and feature extraction after some preprocessing (enhancement, restoration, compression) of the image, so as to perform judgment and classification. Image classification often adopts classic pattern recognition methods, including statistical pattern classification and syntactic (structural) pattern classification. In recent years, newly developed fuzzy pattern recognition and artificial neural network pattern classification have also received more and more attention in image recognition.

2.3 Image processing file format

3 Introduction to basic knowledge of MATLAB

3.2 Historical background of MATLAB generation

3.3 Features of MATLAB language

3.4 Application of MATLAB in image processing


4 methods

4.1 Image preprocessing

First judge the format of the image. Since the obtained image is a true color image, which is an RGB image, you can use the rgb2gray() function to convert it to a grayscale image.

4.2 Spatial domain processing

Digital image processing technology can be divided into "spatial domain" technology and "frequency domain" technology two categories. The "spatial domain" refers to the image plane itself, and such methods are based on the direct manipulation of image pixels.

4.2.1 Histogram equalization

Histogram equalization is to use the statistical data of the histogram to modify the histogram, which can effectively deal with the distribution of the histogram of the original image, so that each gray level has a uniform probability distribution. By adjusting the dynamic range of the image gray value , to automatically increase the contrast of the entire image, so that the image has greater contrast and most details are clearer. The histogram equalization algorithm is based on the theory of histogram enhancement technology: set the gray level of the original image at (x, y) as f, and the changed image as g, for discrete images, the method of image enhancement is: g = EH(f). EH(f) is a mapping function that must satisfy two conditions (where the total number of pixels in the image is n, divided into L gray levels): ① EH(f) is a single value in the range of 0≤f≤L-1 And a single increasing function; ② For 0≤f≤L-1, 0≤g≤L-1. Then the mapping function of the histogram equalization method is:

(k=0,1,2,……,L-1)

() (4.1)

According to this equation, the gray value of each pixel after histogram equalization can be obtained directly from the gray value of each pixel in the original image. Due to the complex arithmetic calculation process, this paper can also enhance the image by using the histogram equalization histeq() function in the Image toolbox toolbox of MATLAB.

Figure 4-1(a) is the original image, and the image shown in Figure 4-1(b) is the image adjusted by the function imadjust(), which converts the pixels whose gray level is lower than 0.2 into gray level 0, extending [0.2 1] to [0 1] The contrast of the image is significantly improved. Figure 4-1(c) is the histogram of the image in (b). Figure 4-1(e) is the image after histogram equalization of (b) image. Compared with (b) image, the contrast of the bone is improved, but the background is hazy. Figure 4-1(d) is the histogram of the (e) image. Compared with the histogram of (c), high gray levels produce equalization, but low gray levels have no pixels. Figure 4-1(f) is the adjusted image of (e), it can be clearly observed that most of the haze of the background has been removed.


v2-8e6f8ceb293892a77b604ae2d25a33de_b.jpg

v2-2bdefb4950d3bcd4cf1af0ae4828f23e_b.jpg


  1. (b)



v2-b515e835110030ba137f12303e2a5683_b.jpg

v2-902e47a43e37a9a47e2946378d068cae_b.jpg


  1. (d)


v2-d545b33e9d843264408ddfbf00f362d7_b.jpg

v2-74b887be833a06f36efcbb1e9fabdce3_b.jpg


  1. (f)

Figure 4-1 Image histogram equalization

4.3 Frequency domain processing

The "frequency domain" processing technology is based on the Fourier transform of the modified image. In the Fourier transform, the low frequency mainly determines the overall gray level display of the image in the smooth area, while the high frequency determines the details of the image, such as edges. and noise. The filter that passes the high frequency and attenuates the low frequency is called a "high-pass filter". The high-pass filtered image will reduce some gray level changes in the smooth area and highlight the transition (such as edge) gray level details. part. The Butterworth high-pass filter is a frequency domain processing technique.

4.3.1 Fourier transform of image

A digital image of size M×N can be expressed as a two-dimensional discrete function f(x,y) where x=0,1,2,⋯, M-1,y=0,1,2,⋯,N -1. The Fourier transform of f(x,y) is:

(4.2)

In practical applications, the Fourier transform can be realized by using the fast Fourier transform algorithm. An image array f with a size of M*N can be obtained through the function fft2() of the Image toolbox toolbox of MATLAB.

Figure 4-2(a) shows the frequency spectrum of the image in Figure 4-1(f) after Fourier transform. Figure 4-2(b) is the image of (a) using the IPT function fftshift() to move the origin of the transformation to the center point of the frequency domain rectangle. The area close to the center point represents the low frequency area of ​​image frequency, and the area away from the center is the high frequency region.

v2-b544a741b932f96ad3cc9c3fc5b32e1a_b.jpg

v2-0678a98c6865de7e431d503699102ff1_b.jpg


  1. (b)


Figure 4-2 Fourier transform

4.3.2 Inverse Fourier Transform

The spectrogram can restore the image without distortion through the inverse Fourier transform. The inverse Fourier transform formula of formula (5.2) is as follows:

(4.3)

Take the complex conjugate on both sides of formula (4.3):

(4.4)

Formula (4.4) is very similar to Fourier transform formula (5.1), so as long as the Fourier transform algorithm is called, it will be used as input, and it can be obtained, and then the complex conjugate can be obtained. Since f(x,y) is a real function, = .

4.3.3 Image frequency domain filtering

The frequency domain image processing process is called frequency domain filtering, and its basic steps are shown in Figure 4-3:




F(u,v) H(u,v)F(u,v)

Figure 4-3

Among them, H(u, v) is the transfer function, and its function is to suppress some frequencies but retain other frequencies in the Fourier transform, so it is also called a filter. f(x,y) is the input image, F(u,v) is its Fourier transform, let G(u,v) be the filtered Fourier transform, then:

G(u,v)=H(u,v)F(u,v) (4.5)

The algorithm to realize G is not complicated, because both H and F are two-dimensional discrete functions, the multiplication of H and F is actually multiplication element by element, that is, the first element of H is multiplied by the first element of F to get the value of G The first element, ⋯⋯, G can be obtained by analogy. After G undergoes inverse Fourier transform, a filtered digital image can be obtained.

4.3.4 Butterworth high-pass filtering

The transfer function of the Butterworth high-pass filter with nth order cut-off frequency D0 is:

(4.6)

in:

(4.7)

The three-dimensional plot of the transfer function is shown in Figure 4-4:



v2-7d33a4ceeb283a9f0b02639e95e68177_b.jpg


Figure 4-4 Three-dimensional diagram of the transfer function of the Butterworth high-pass filter


In practical applications, an image array f with a size of M*N can be used to implement high-pass filtering through the function hpfilter() of the Image toolbox toolbox of MATLAB.

Figure 4-5(a) is the Butterworth high-pass filtered image of the image in Figure 4-1(f), and the edge of the image can be seen; Figure 4-5(b) is the image of Figure 4-5(a) After being added to the image in Figure 4-1(f), the boundary becomes clearer compared with the image in Figure 4-1(f); Figure 4-5(c) is the image after further accumulation; Figure 4-5( d) is the image after further accumulation; the clinician can select the number of times of accumulation according to needs.








v2-1cd4fcec94ec3849be7f4f77804823f8_b.jpg

v2-161971281c44f7def0f2eedc8aea10b6_b.jpg


  1. (b)


v2-aa97f860fc4a91bba3a873917674b7fe_b.jpg

v2-bf528c6b0024dc25534db0e7468ffba2_b.jpg


  1. (d)








5 results

5.1 Results after preprocessing

Using the histogram equalization algorithm to enhance the medical image, the processed image is obtained (Fig. 4-1(f)). After image preprocessing, the displayed result is: the original image is a matrix of 608×500×3 in true color, with a size of 0.87M; after converting to a grayscale image, it is a matrix of 608×500, with a size of 0.27M.

5.2 Results after histogram equalization

In the original image (Figure 4-1(a)), we can see that the image is blurred, the dynamic range is small, and the entire image presents low contrast. Using the histogram equalization algorithm to enhance the medical image, the processed image is obtained (Fig. 4-1(f)). The overall image contrast is significantly enhanced. Especially the spine edges become clear.

5.3 Results after Butterworth high-pass filtering

After equalizing the histogram of the original image, the image is further subjected to Butterworth high-pass filtering. Figure 4-1(f) is the image before Butterworth high-pass filtering. It can be seen that the edges of the image are blurred. Figure 4-5(a) is the image after Butterworth high-pass filtering, and you can clearly see the edge of the entire image; then add the edge to the image before Butterworth high-pass filtering (as shown in Figure 4-5(b) ), it can be seen that the entire image becomes clear, the image is sharpened, and the contrast of the edges is enhanced. After further accumulation, the overall image becomes clearer, the contrast of the edge is further enhanced, and the noise is also enhanced, so the number of accumulations is selected according to actual needs.

6 Summary

This paper mainly introduces the theoretical knowledge of digital image and the characteristics of MATLAB language. Based on the digital image processing environment of MATLAB, it introduces how to use MATLAB and its image processing toolbox for digital image processing. Histogram equalization can make blurry, small dynamic range, and low contrast images clear, increase dynamic range, and present high contrast. High-pass filtering can enhance the edge details of the image and sharpen the image. Make the image clearer. Histogram equalization and high-pass filtering can be used together to further enhance the image to meet actual needs.

MATLAB provides a technical platform for medical image processing, not only for the analysis and diagnosis of medical images

Significance. And the enhancement of other images also has some value.

Guess you like

Origin blog.csdn.net/TuTu998/article/details/120177067