Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 6, No. 3, 2023 100 Design of Digital Image Processing System Based on Machine Vision Xiaolei Zhong1, * 1Yunnan University Dianchi College, Kunming 650228, China *Corresponding author: e-mail: 1018761837@qq.com Abstract: Digital image processing technology is a technology that has developed rapidly in recent years[1]. A series of images are processed by computers to improve the visual effect of the image in order to achieve the desired presentation effect. Digital image processing technology has been continuously developed with the innovation of computers, and its application range has expanded from the original image field to traffic command, signal processing, medical treatment and other fields closely related to people's lives. With the support of many algorithms, the speed of digital image processing technology is getting faster and faster, which brings a lot of convenience to people's lives, and which becomes an indispensable technology in life. With the help of MATLAB's GUI user interface, image processing toolbox and MATLAB's comprehensive mathematical function library, this article designs an image processing operating platform that realizes some image processing functions after repeated trials. Keywords: Digital image processing, MATLAB, GUI. 1. Introduction of Digital Image Processing and Graphical User Interface 1.1. Introduction of Digital Image Processing Images are the basis of people's vision and the most direct way of understanding the outside world. "Picture" is the reflection of light energy from an objective object[2]. "Image" means that when light energy enters the eyes, it passes through the optic nerve and enters the brain to form image information. From the way the image is recorded, the image types can be divided into two categories: digital and analog. Digital image processing uses a hardware or software processing platform that can convert image information into digital information and digital information into image analog information to complete image preprocessing operations, and process it again according to needs. For example, in modern high-definition TV imaging, it converts the received digital signal into an image signal that people see with the naked eye. In the field of similar image recognition such as fingerprint recognition and face recognition, digital image processing technology is to perform digitized feature extraction and similarity comparison of the obtained image information, and convert the image signal into a digital signal to achieve the desired processing effect. 1.2. Graphical user interface The user interface realizes the function of information interaction between the machine and the user. Through the user interface, the internal operation information of the machine is converted into an information mode that is easy for people to accept[3-4]. Its main function is to meet the needs between control and being controlled, that is, how people control the machine, how the machine receives instructions, and how to make a corresponding response and return to the control interface. The GUI image user interface of MATLAB is an image and graph control window that can interact with the user. It contains many image control objects, such as buttons, menus, sliders, texts, and various dialog boxes. By writing independent M files corresponding to these control objects with specific functions, the program in the M file will be automatically compiled when operating these control objects. For example, when we drag a numeric control slider, the value of the variable controlled by it will change accordingly. The characteristic of MATLAB's GUI graphical user interface is that users do not need to type programs in the MATLAB command line when implementing certain functions, and when designing the GUI interface, we need to make reasonable use of MATLAB's super numerical computing capabilities and image processing capabilities, and accurately write M files that achieve specific functions[5]. Therefore, the users do not need to master the programming, but they can still operate it. According to actual needs, you can customize the function buttons that need to be implemented on the interface to form a simple and easy-to- operate interface to achieve the desired processing functions. 2. Grayscale Histogram and Image Transformation 2.1. Grayscale histogram In the image field, the way that the different saturation levels of black are used as the basic tone of the image is called grayscale[6-7]. The brightness value of the gray-scale object is 0% (white) to 100% (black), and the general gray-scale image can be obtained by a gray-scale scanner. The image gray bar is shown in Figure 1. Figure 1. Gray bar 101 Different from black-and-white images, gray-scale images are composed of multiple gray levels of different tones between white and black. The gray-scale transformations are as follows: 1) For the input image f x, y , an output image g x, y will be generated after the gray level transformation T, and the value of each pixel of g x, y is determined by the value of the corresponding input pixel of f x, y , that is g x, y T f x, y . 2) For the original image f x, y , the gray value transformation function T f x, y , since the gray value is always limited (0-255), the non-geometric transformation can be defined as R T r : 2.2. Grayscale histogram Histogram is a chart that uses different lengths of bar graphs to indicate the number of values on the Y axis. It has the advantage of being intuitive and easy to compare the size of the data. Gray histogram is an important processing basis in image processing. According to the gray data presented, the image can be processed such as image linear transformation and image nonlinear transformation. The histogram can represent the probability of the pixels corresponding to each gray level in an image appearing in the total pixels of the image (that is, the ratio of the pixels corresponding to each gray level to the total pixels in the entire image). Its expression is shown in (1): š‘ƒ š‘Ÿ š‘˜ 0,1,2, … šæ 1 (1) In the expression (3.1), n represents the number of pixels of the k-th gray level, L represents the total number of gray levels, N represents the total number of pixels in the image, and P r represents the probability that the pixel corresponding to each gray level in an image appears in the total pixels of the image, r represents the kth gray level. 3. Histogram Equalization Histogram equalization is an image processing method that changes the gray distribution of the original image, which is achieved through methods such as contrast value adjustment[8]. Histogram equalization increases the value range of pixels to obtain a grayscale image with uniform probability density. Its processing method is to modify the histogram through cumulative distribution function transformation, which is widely used in image enhancement processing. Assuming that the original gray value of a certain pixel is R, the processed gray value is S, and its gray scale transformation function T R is shown in equation 2: S T R āˆ‘ š‘ƒ š‘… āˆ‘ (2) 0 š‘… šæ; š‘˜ 0,1 … In formula 3.2, it represents the probability of the gray value of the j-th level, n represents the total number of pixels of the j-level gray in the image, šæ represents the total number of gray levels, and š‘› represents the total number of pixels in the image. Histogram equalization is widely used in image gray-scale histogram processing. The histogram equalization can be implemented as follows: 1) Perform histogram statistics on the images that need histogram equalization processing, and find š‘ƒ (š‘Ÿ )= (3) 2) Perform further cumulative distribution function transformation processing on the processed gray histogram to obtain a new gray level; š‘† š‘‡ š‘… āˆ‘ š‘ƒ š‘… (4) 3) Integrate the gray value approximately equal to one, and replace the old gray with the new gray. 4. Linear Transformation of Images This article adopts the transformation method of point arithmetic for linear transformation. Point operation is actually the process of calculating the gray value of each pixel of the image according to a certain mapping relationship to obtain a new image. That is, for the pixel gray value f x, y of the original image, the pixel value g x, y of the output image will be generated by the gray level transformation T, and each pixel value of g x, y is determined by the value of the corresponding input pixel of f x, y , thus achieving the point-to-point arithmetic processing on the image, this kind of arithmetic processing is called point arithmetic. r represents the gray level index of the input image, s represents the gray level index of the output image, T represents the functional mapping relationship between the image input value and the image output value, as shown in Equation 5and Equation 6: s T r (5) g x, y T f x, y (6) The grayscale transformation is used to enhance or lighten the grayscale of each pixel of the original image, so that the grayscale dynamic range of the image is changed. The contrast of the image is enhanced to meet the requirements of improving the visual effect of the image. According to the different requirements of the image gray- scale linear transformation processing, the slope š‘˜ of the transformation function can be changed to meet the processing requirements. Supposing the original image gray value f x, y ∈ š‘Ž, š‘ , the image gray value g x, y ∈ š‘, š‘‘ after linear transformation, the transformation relationship (7) can be obtained: g x, y c k f x, y š‘Ž (7) š‘˜ (8) 102 Figure 2. Gray linear transformation relationship According to the value of sum, it can be roughly divided into the following situations: 1) Dynamic range expansion: if š‘Ž, š‘ ∈ š‘, š‘‘ , that is k>1, then the gray value range of the image will be expanded, and the current situation of underexposure of the image will be improved, and the full use of the image display instrument will be improved; 2) Change the value range: If k 1, that is š‘‘ š‘ š‘ š‘Ž , then the gray dynamic range after transformation is the same as the original, but the gray value range will change with the changes of š‘Ž and š‘; 3) Reduce the dynamic range: If š‘, š‘‘ ∈ š‘Ž, š‘ , that is 0 k 1 , the dynamic range of the processed image will decrease accordingly; 4) Image inversion: If k 0, for š‘> š‘Ž, the gray value of the image will be inverted after the transformation process, that is, the original image gray value will be reversed 180 degrees, which is simply to change the image from "black" to "white", or from "white" to "black". At k 1 , g x, y is the inverse of f x, y . 4.1. Piecewise linear transformation of images Image segmentation divides the image into many parts. The overall histogram of an image can be obtained by superimposing the histograms of each part. By highlighting the part of the gray interval, that is, linearly transforming the gray value of the interval, it can highlight the part that people are interested in, image processing methods like this are called image piecewise linear transformation methods. In the piecewise linear transformation, in order to highlight the details of the interesting part in the image, the gray level of the output is often enhanced, and the uninteresting part will be suppressed to a certain extent, and the gray level will also be weaken. Supposing the interval of interest is the pixel gray value of the input image, and the pixel value of the output image is generated after piecewise linear change. The following formula can be obtained: g x, y āŽ© āŽŖ āŽØ āŽŖ āŽ§ f x, y ; 0 f x, y š‘Ž f x, y š‘Ž š‘; š‘Ž f x, y š‘ f x, y š‘ š‘‘; 0 f x, y š‘Ž (9) Figure 3. The relationship of gray-scale piecewise linear transformation 4.2. Non-linear transformation of images When imaging an image, it may be interfered by some uncontrollable factors in the environment, such as noise or other signals that will randomly affect the output image, resulting in non-linear distortion of the output image. At this time, it is necessary to perform a certain amount of non- control on the output image to meet image imaging requirements. In this paper, the exponential transformation method is used as the research method of image nonlinear transformation. 1) Exponential transformation We adopt the method of expanding the high-value gray- scale area of the image and compressing the low-value gray- scale area, that is, the exponential transformation processing method. Its expression is shown in formula (10): g x, y š‘ , 1 (10) 103 The exponential transformation curve of the image is shown in Figure 4. Figure 4. Exponential transformation curve 4.3. Image smoothing The purpose of image smoothing is to improve image quality through specific algorithms in accordance with image processing requirements, thereby it can enhance people's visual effects. Image smoothing processing technology is a commonly used processing method in digital image processing technology. Its main function is to reduce the high- frequency components in the image, reduce the sharpness of the image and remove some noise. The high-frequency components in the image represent the edge contours and high gray value areas of the image. Through image smoothing, the high-frequency components in the image can be well suppressed, so that the overall grayscale distribution is uniform, and the image looks more uniform. This article uses the domain average and median filter method to smooth the image. 4.4. Image sharpening Image sharpening and image smoothing are two different image processing methods. Image sharpening is to make the edge of the image clear, make the image outline more prominent, and achieve a presentation form that is convenient for observing the image outline. In essence, image sharpening is to strengthen the high-frequency part of the image, and then the image noise will be strengthened. After research and processing, the edge of the image is detected by the method of edge detection first, and then based on the detection result, the high-frequency components of the image are enhanced. In the image sharpening method, image processing is mainly to do edge enhancement processing on the prominent lines or isolated points in the image, and it also enhances the image noise signal, that is, the purpose of sharpening is to make the points with large grayscale pixels in the contour of the image to make their grayscale values larger, and the pixels with small grayscale values become smaller, while the pixel point outside the outline is not affected by sharpening. 4.5. Image sharpening algorithm In order to make the edges of the image clear and make the outline of the image more prominent, isotropic gradient algorithms are often used. The basic expression is shown in equation (11): (11) In the above formula, x, y is the image before processing, and š‘„ , š‘¦ is the image after processing. The gradient value of the image x, y point is shown in equation (12): g f kzāˆ‡ š‘“ (12) In the formula (4.5), k represents the coefficient related to the diffusion effect. Through the improvement of the gradient value algorithm, the edge of the object can be effectively made prominent, and āˆ‡ š‘“ represents the Laplacian operator that performs second-order differential processing on the image š‘“. āˆ‡ can be represented by a template, such as (13): H 2 4 2 4 20 4 2 4 2 (13) In practical applications, the value of each coefficient in the template H can be changed. In formula (4.5), the choice of value is also very important. If the value is too large, the edge of the image will be too prominent and affect the visual effect. If the value is too small, the sharpening effect will be insignificant. After repeated trials and verification, the value of kz is between 3 and 8, and the treatment effect is the best. The effect after sharpening is shown in Figure 5 and Figure 6: Figure 5. Original image Figure 6. The sharpened image Compared with the original image, after the image is sharpened, its edge contours are easier to observe, which provides people with a good basis for image features such as image processing operations such as photo restoration. 104 5. Conclusion This article uses MATLAB's powerful scientific computing capabilities to compile the digital image processing program, and finally present the image processing results through the MATLAB graphical user interface. In this way, different processing functions can have independent M files. ,It is more concise and clear when writing and debugging programs. References [1] Zhang Guangcai, Wan Shoupeng.Development and Design of MATLAB GUI Digital Image Processing System [J]. Software, 2019, 40(11): 123-127. [2] Han Zhaoyang, Weng Dongdong. An Optical Tracking System Based on Simple Marker Coding[J]. Acta Graphics: 1-16. [3] Zhang Lili, Bao Xirong, Wang Tong, etc. Research on Integrated Circuit Welding Quality Monitoring System Based on Image Processing Technology [J]. Electronic Devices, 2023,46(01):57-61. [4] Xu Chunhe, Sun Peigang, Zhang Quanyu, etc. Design of Digital Image Processing System Based on Machine Vision [J]. Popular Standardization, 2022, No.379(19): 128-130. [5] He Zhichao, Fan Yuhua, etc. Research on Image Processing Optimization Technology of Railway Passenger Station Video Fusion Intelligent Monitoring System Based on Deep Learning [J].Railway Computer Application, 2022,31(07):81-86. [6] Yan Zongyi, Ren Dejun, etc. Design of Deep Learning Platform for Image Processing Based on B/S Architecture [J]. Modern Electronic Technology, 2022, 45(16): 60-66. [7] Yin Feihao, Shang Jianhua. Research on Image Processing Algorithm IP Verification System Based on ZYNQ Platform [J]. Computer Technology and Development, 2022,32(10):41- 45. [8] Sun Pengwei, Wang Jun, Wang Shujun, etc. Design of Image Processing System Based on MATLAB GUI [J]. Computer Technology and Development, 2022,32(04):215-220.