# Barcode Location in Financial Statement System Based on the Partial Differential Equation Image Recognition Algorithm

Authors: Jinghua Ning; Song Yu
Journal: Advances in Mathematical Physics
 (2021)

---

## Abstract

Financial statements are the basis of financial analysis. Most of them are still using traditional financial statement software, and financial data cannot achieve better information sharing. Using a barcode to improve the efficiency of data sharing is undoubtedly the most convenient and fast way to realize financial statement information sharing. This paper studies the problem of the barcode image location and recognition in the financial statement system and tries to apply the partial differential equation image recognition algorithm to the barcode location in the financial statement system. In this paper, image technology is used to preprocess the code 39 barcode label image in the captured image, including color space conversion, image enhancement, threshold segmentation, binarization, and edge detection. The barcode position location is realized by using the method based on integral projection peak analysis and Hough transform line detection. It is proved that the positioning function of the barcode makes the data in financial statements realize resource sharing. Then, the performance of the completed barcode positioning and recognition algorithm is tested. The reliability and effectiveness of the algorithm are verified on the manually made test set.


---

## Body

## 1. Introduction

The financial statement system is the data basis of the financial management system and the basis of managing enterprise finance and analyzing financial data [1]. However, the current situation is that the financial management of many small- and medium-sized enterprises still lags behind [2]. They use traditional financial software or still rely on manual bookkeeping to deal with financial problems and still stay in the “primitive society” stage of financial management [3]. This is bound to bring great challenges to the data collection, processing, and analysis of financial work. It is undeniable that the accuracy and efficiency of the manual financial processing mode are worrying, so it is impossible to support the analysis of enterprise management financial data. The changes of financial data related to economic activities are also refreshed in real time. Finance is the only one that runs through the whole enterprise business chain [4]. Therefore, if a financial statement system cannot provide timely data input, it is bound to affect the subsequent financial business processing and data analysis and sometimes delay the enterprise’s operation and management decisions, resulting in the loss of a strong competitive position in the market. Therefore, efficient, accurate, and timely financial analysis data can become a think tank for enterprise managers, formulate development policies, timely find any problems in operation, make reasonable emergency response, and provide strong guarantee [5]. The modern financial management system is far stronger than the traditional financial management system in terms of speed and accuracy. Therefore, modern financial management has been the key factor for enterprise development, especially for small- and medium-sized enterprises in an invincible position in the competition. In view of the above reasons, using barcode to improve the efficiency of data sharing is undoubtedly the most convenient and fast technology at present [6]. A barcode is a simple and reliable information and data transmission technology. A barcode is composed of black “bars” with different widths and “empty” between bars.Some coding modes also attach letters or numbers. These “bars” and “empty” are combined according to some law, and thousands of information can be expressed [7]. Through barcode technology, many relevant information of an article can be expressed. For example, in the manufacturing industry, there will be a unique barcode on all parts, indicating the country of production, manufacturer, name, production date, and other information. In book retailing, the last barcode of books can represent the classification number of books. Similarly, in financial management, a barcode can be used on the most critical data source—financial statements—so as to improve the circulation of report data and management efficiency [8]. In image processing and computer vision, the systematic use of the partial differential equation (PDE) method is a new field developed in the recent 20 years. It has accumulated rich research results and shown its strong processing ability. Partial differential equation theory can provide a unified theoretical framework for image processing, which has many advantages [9]. Firstly, PDE provides a unified theoretical framework for image processing, which involves almost all image processing fields, including image restoration, segmentation, image inpainting, video moving target tracking, optical flow, and stereo vision. Then, PDE can analyze the image in the continuous domain, independent of the pixel size, which simplifies the image analysis system. Assuming that the grid mesh size tends to be zero, we can study the discrete local nonlinear filter in the framework of PDE and even write the discrete filter in the form of the partial differential operator. Based on the existing research results of PDE in numerical analysis, a fast, accurate, and stable image processing algorithm can be obtained [10]. The unique analysis theory in the field of PDE makes it possible to study better image processing algorithms and meaningful theoretical results [11]. This paper takes the positioning of the barcode in the financial statement system as the research object and uses the image recognition algorithm based on the partial differential equation to complete the research on the key technologies of barcode label image preprocessing, barcode position positioning, barcode symbol recognition, and so on.


## 2. Related Work

Reviewing the development history of partial differential equations in the field of image processing, we can trace back to the famous active contour model proposed by Liu et al. [12]. The model describes an energy minimization curve. The internal force constrains the contour of the model, and the external force guides its behavior, so that the curve approaches its ideal image features [13]. They first introduced the concept of scale space, which can make an image expressed in a multiscale way. The Gaussian filtering model first expressed the multiscale image, which can be considered as the isotropic diffusion of the original image by the thermal diffusion equation [14]. After a large number of later studies, it is found that the heat conduction equation is not the only partial differential equation used to define multiscale images. As long as the transformation equation satisfies the maximum principle, the creation of multiscale space can be realized. Wulanditya and Aprillianita [15] put forward the level set theory through research. The contour transformation mode can be solved by controlling the change process of the level set curve. Although all curve topology changes can be represented by this model, this algorithm has high complexity and is not conducive to popularization [16]. The first to introduce partial differential equations into the field of image processing and their anisotropic diffusion theory have had a far-reaching impact on the application of partial differential equations in the field of image processing [17]. They proposed that replacing the Gaussian filter with coefficient directional distribution is equivalent to isotropic distribution, which can weaken the noise and blur the regional boundary. They have made great contributions to the theory and solving practical problems in the field of partial differential image processing.This is an optimization effect of the partial differential equation in image processing by using the variational principle [18]. The concept of variation is introduced into the partial differential equation to supplement the model, and the anisotropic diffusion models of the partial differential equation are also realized and optimized. At the same time, the image segmentation model, restoration model, and invariant flow theory are proposed. According to the adaptive diffusion model of different image regions, these methods are widely used in the fields of image super-resolution extraction, image denoising, enhancement, and segmentation [19]. The application of the partial differential equation in the image has gradually become a research hotspot in the field of image processing and has a far-reaching impact on the development direction of image processing research. The traditional partial differential equation image processing method depends on specific problems. When people face a problem, they need to dig into the characteristics of the problem, understand the key to solve the problem, and formalize and calculate it. However, there is only one system in the human eye or human brain. Although their structure does not change with the problem, they can effectively solve all kinds of image processing problems. This prompted people to consider whether there is a unified model to solve different image processing problems. Recently, Amaliah and Murtini [20] proposed the partial differential equation learning model (LPDE), which has proved that it can solve a series of image processing problems with the same form of partial differential equation, including deblurring, denoising, edge detection, image segmentation, object detection, and color image interpolation. In this framework, users who want to obtain partial differential equations only need to provide input-output training image pairs, so as to save the trouble of in-depth mining and research on specific problems. LPDE introduces the idea of “learning” in machine learning into the field of differential equation image processing and puts forward a theoretical framework to solve the problems in image processing by learning specific partial differential equations through training data [21]. Firstly, a unified intelligent differential equation system is constructed by using the rotation and translation basic differential invariants as the basis function, and then, the specific partial differential equation form is trained by using the optimal control theory constrained by the differential equation. These basic differential invariants are derived from the experience and mathematics of some image processing. Whitelock [22] gave 17 basic differential invariants for many problems.A barcode is a new identification technology. It is spliced with a regular, black-and-white staggered strip color block. The final strip image can mark the unique data, that is, the string encoded by 0 and 1. The string corresponds to the relevant information of the object. Generally, barcodes are represented in image form and printed on the object package. The barcode identification equipment is not highly required. The camera, electric scanning equipment, and installed decoding software of the mobile handheld device can be used to identify the stored information of the barcode and then automatically process the information. The composition of a complete barcode is shown in Figure1.Figure 1
Schematic diagram of the barcode.The earliest intellectual property rights related to barcodes were patents applied by Joe Woodland and Berny Silver. In the patents, they proposed how to use codes to represent food items and designed machines that can automatically identify food item codes. In the following two decades, there were records of applying coding to the tram system and railway procurement system. The representative barcode development is the UPC (universal product code) formulated by the American Supermarket Ad Hoc Committee in 1970. The UPC is one of the most widely used barcodes in the retail industry. After the UPC, several new forms of coding have appeared one after another. According to the different characteristics of each coding rule, its application fields are also different. Japan, which is also a world leader in automation promotion, began to implement barcode technology in the 1970s and the Japanese designed and invented the Japanese article code JAN in 1978 based on the code system of the EAN barcode. At present, in today’s society with the continuous promotion of global informatization, the role of the barcode cannot be ignored. Barcode technology has become a new means to lead the circulation of material and information all over the world. As a computer language that can be printed, the barcode is called “computer culture” by futurists. In recent years, a two-dimensional barcode has attracted more attention on the basis of a one-dimensional barcode. The coding information of the two-dimensional code can be expressed in both horizontal and vertical directions, so it can obtain more abundant information expression capacity, and the error rate is lower than that of one-dimensional barcode. It is a research hotspot in the field of the barcode at present. Considering the requirements of this system, it is designed for the financial system of small- and medium-sized enterprises to improve the business processing speed of financial statements and the business scale is small, so the related technologies of the two-dimensional code will not be repeated here, and the system still selects the one-dimensional barcode. The coding rule of the barcode is the core technology in barcode recognition. Some people also call the coding rule of the barcode the coding system of the barcode. The coding rules of barcodes are very diverse, which are briefly introduced below. EAN is a barcode for commodities formulated by the International Article Coding Association. It is an international general symbol system. Its length is fixed and all the information expressed is digital. It is mainly used for commodity identification all over the world. UPC (universal product code) is the first one-dimensional barcode applied on a large scale. Its main feature is that its length is fixed and continuous. It is mainly used in the United States and Canada. Because of its wide range of applications, it is also called the universal barcode. Code39 and code128 are a self-defined coding rule for most domestic enterprises at present. These two codes can determine the length and information of the barcode according to needs. The coded information can be numbers, letters, etc. It is mainly used in enterprise management, logistics, library management, etc.


## 3. Image Recognition Algorithm Based on the Partial Differential Equation

### 3.1. Partial Differential Equation Learning Model for Image Recognition

This section focuses on the proposed partial differential equation learning model for face recognition. Firstly, the overall model is briefly introduced, and then, the specific partial differential equation learning model and linear classifier for feature extraction are given according to the properties that should keep the features unchanged under some transformations. Firstly, it is assumed that feature extraction is an evolutionary process that can be described by the evolutionary equation. The initial value of the equation is the original input image, and the final result of evolution is the required feature. When the features are extracted, a linear classifier is used for face recognition. Therefore, the complete partial differential equation learning model of face recognition is to determine the functionfu,x,y,t and learn the classifier parameters and then obtain the loss function with smooth regular constraints as follows:
(1)∏i=nNuWM;Fut,S−uλFu.For most evolution equations, they can generally be written in the following form:(2)∂u∂t=kLu,Mu,Fu.For general image processing problems, people often design the specific form ofF according to experience or a priori information. However, for image classification tasks, it is difficult to design feature extraction models based on previous experience or prior information. Therefore, this chapter proposes to learn the partial differential equation model through training data.Illumination variation is a great challenge in most image classification tasks (such as face recognition). In order to make the extracted features meet the illumination invariance, a nonlinear mapping is added to each basic differential invariant, which can weaken the influence of illumination change to a great extent. Then, a simple linear representation is used to estimate the functionL:
(3)Lu,Mu,Fu=∪t=0nftgt.In order to reflect the advantages of the partial differential equation model, a general linear classifier is simply used. Hinge loss function shows its significant advantages in many aspects and has achieved good results in face recognition. Therefore, the multivariable regression model extended by it is used for classification. The specific forms are as follows:(4)J+Ltu−Wt⋅abc=kLu2+uλFu2.To sum up, we give a specific and complete partial differential equation learning model for face recognition and its expression is as follows:(5)minF⋅WM=uxλL+MJ2+λF2+uW2.


### 3.2. Image Recognition Algorithm

This section gives the specific algorithm to solve the proposed image recognition model. The main idea is to update parametersa and W alternately. Firstly, the partial differential equation is numerically discretized, and then, the specific method of updating a and W is given. Refer to the algorithm for specific steps of the algorithm and settings of relevant parameters. Firstly, a finite difference scheme is used to discretize the partial differential equation, as shown in the following formula:
(6)∂f∂x=fx2−2x+fx,∂f∂u=λ4f1−u+fu2,∂2f∂u2=λ4f1−u−fu+2fu2⋅fu.It can be seen thata is a matrix and each element of which is a, tn+1 at each time. The differential equation is approximated by the following formula:
(7)Lii+n=Wut+d∪t=0nftgtWut.FixA, it can be easily calculated by discrete iterative format, and the formula is as follows:
(8)F=minwMuxλL+MJ2+λF2+uW2,F=L⋅MJT⋅MJ⋅MJT+uλF⋅W−1.When parameterW is fixed, the gradient descent method is used to update parameter A. It can be calculated by the chain derivation rule:
(9)∂F∂ut=∂F∂Li+t⋅∂Li+t∂ut,∂F∂Li+t=f2t−3,∂Li+t∂ut=fu2+2u.


## 3.1. Partial Differential Equation Learning Model for Image Recognition

This section focuses on the proposed partial differential equation learning model for face recognition. Firstly, the overall model is briefly introduced, and then, the specific partial differential equation learning model and linear classifier for feature extraction are given according to the properties that should keep the features unchanged under some transformations. Firstly, it is assumed that feature extraction is an evolutionary process that can be described by the evolutionary equation. The initial value of the equation is the original input image, and the final result of evolution is the required feature. When the features are extracted, a linear classifier is used for face recognition. Therefore, the complete partial differential equation learning model of face recognition is to determine the functionfu,x,y,t and learn the classifier parameters and then obtain the loss function with smooth regular constraints as follows:
(1)∏i=nNuWM;Fut,S−uλFu.For most evolution equations, they can generally be written in the following form:(2)∂u∂t=kLu,Mu,Fu.For general image processing problems, people often design the specific form ofF according to experience or a priori information. However, for image classification tasks, it is difficult to design feature extraction models based on previous experience or prior information. Therefore, this chapter proposes to learn the partial differential equation model through training data.Illumination variation is a great challenge in most image classification tasks (such as face recognition). In order to make the extracted features meet the illumination invariance, a nonlinear mapping is added to each basic differential invariant, which can weaken the influence of illumination change to a great extent. Then, a simple linear representation is used to estimate the functionL:
(3)Lu,Mu,Fu=∪t=0nftgt.In order to reflect the advantages of the partial differential equation model, a general linear classifier is simply used. Hinge loss function shows its significant advantages in many aspects and has achieved good results in face recognition. Therefore, the multivariable regression model extended by it is used for classification. The specific forms are as follows:(4)J+Ltu−Wt⋅abc=kLu2+uλFu2.To sum up, we give a specific and complete partial differential equation learning model for face recognition and its expression is as follows:(5)minF⋅WM=uxλL+MJ2+λF2+uW2.


## 3.2. Image Recognition Algorithm

This section gives the specific algorithm to solve the proposed image recognition model. The main idea is to update parametersa and W alternately. Firstly, the partial differential equation is numerically discretized, and then, the specific method of updating a and W is given. Refer to the algorithm for specific steps of the algorithm and settings of relevant parameters. Firstly, a finite difference scheme is used to discretize the partial differential equation, as shown in the following formula:
(6)∂f∂x=fx2−2x+fx,∂f∂u=λ4f1−u+fu2,∂2f∂u2=λ4f1−u−fu+2fu2⋅fu.It can be seen thata is a matrix and each element of which is a, tn+1 at each time. The differential equation is approximated by the following formula:
(7)Lii+n=Wut+d∪t=0nftgtWut.FixA, it can be easily calculated by discrete iterative format, and the formula is as follows:
(8)F=minwMuxλL+MJ2+λF2+uW2,F=L⋅MJT⋅MJ⋅MJT+uλF⋅W−1.When parameterW is fixed, the gradient descent method is used to update parameter A. It can be calculated by the chain derivation rule:
(9)∂F∂ut=∂F∂Li+t⋅∂Li+t∂ut,∂F∂Li+t=f2t−3,∂Li+t∂ut=fu2+2u.


## 4. Image Recognition Algorithm and Barcode Positioning

### 4.1. Barcode Image Preprocessing

#### 4.1.1. Image Grayscale Stretching

Image grayscale stretching is a kind of point operation of image. Point operation is a simple and very important image processing technology, which can realize the gray range occupied by image data. The input image generates a new output image after point operation, and the gray value of the corresponding output point is determined by the gray value of the input pixel point. Therefore, point operation is an operation that does not change the spatial relationship in the image. The point operation can change the gray histogram of an image in a predetermined way. If it is assumed that the input image isIx,y and the output image is I′x,y, the pixel-based operation applied to the input image is
(10)dGu,t=∫gu,tdtdu.Image gray stretching is a typical point operation process, which is generally a linear transformation of gray. However, it should be emphasized that the gray stretching of an image is a piecewise linear transformation, which is usually not a linear transformation of all domains. Gray stretch is a fast and flexible technique to adjust the gray histogram distribution of the whole image. If the gray stretching area is selected instead of limited to the whole image, the gray stretching can also selectively adjust the histogram of a gray interval of the image to improve the output value of the desired enhanced part of the gray domain. It can be represented by the following schematic diagram (Figure2):Figure 2
Gray scale stretching diagram.


#### 4.1.2. Image Histogram and Threshold Segmentation

A histogram is a frequently used tool in analyzing and processing images. The histogram distributes the obtained probability values to several distribution intervals that have been defined in advance by counting the probability distribution in all data. The value in bin can be a pixel gray value, gradient, direction, color, or any other feature. After histogram calculation, the dimension of the histogram will be much lower than that of the original image. Then, in digital image processing, the histogram represents the gray level content of an image, is a function of the image gray level, and expresses the number of pixels with this gray level in the current image. The histogram drawn is a two-dimensional statistical image. Its abscissa represents the gray level of the pixel, and its ordinate represents the frequency of the gray level or the number of pixels of the image at the gray level. Figure3 shows a gray image and its corresponding gray histogram. Figure 3 describes the main forms of the image histogram and threshold separation.Figure 3
Gray image and its corresponding histogram.


#### 4.1.3. Corrosion and Expansion of the Image

Mathematical morphology is based on the set theory. In image processing technology, the set of morphology represents the shape of binary or gray image. Usually, the selected set is the foreground of the image, that is, those pixels set to 255 after threshold segmentation, while the unselected set is the background of the image, that is, the pixels set to 0 after threshold segmentation. In this paper, the processed binary image is used as the element set of morphological processing. The basic morphological processing mainly includes four operations: erosion, dilation, open, and close. The on operation is to corrode the binary image first and then expand it. The closing operation is to expand the binary image first and then corrode it. Therefore, the basic operation of morphological treatment is corrosion and expansion. Leta and B be the sets in the complete set P of pixels, and then, a is corroded by B. Here, a is the front scenic spot of the binarization result image (i.e., the point with the value of 255) and B is the structural element defined according to the requirements. The corrosion process is shown in Figure 4.Figure 4
Corrosion diagram.The main function of corrosion in morphological operation is to eliminate the boundary of objects. Corrosion can remove objects smaller than structural elements from the original binary image and obtain a cleaner foreground image. Therefore, if there is a very small connection between two objects, when the designed structural elements are large enough, the two objects can be separated by corrosion operation. After etching, the whole image can be clean and smooth. Leta and B be sets in the complete set P of pixels, and then, set a is expanded by structural element B. The expansion process is shown in Figure 5.Figure 5
Expansion diagram.The main function of expansion operation is to expand the boundary points outward, so that the small areas that may not be connected at first are connected together after inflation treatment and merged into a large connected area. Therefore, expansion can be used to fill the holes in the binary image, expand the outer contour of the target outward, increase the target area, and bridge small cracks, fractures, and broken small pixel blocks through expansion operation.


### 4.2. Pretreatment Process of Barcode Identification

The above is the basic knowledge of image processing that may be involved in the preprocessing process. According to the research content of this paper, the algorithm of preprocessing link will be selected pertinently, considering that when shooting barcode images, ordinary microcameras are generally used and the barcode area is printed in the blank of the header of financial statements and photographed by hand. There may be paper tilt and inconsistent barcode image scale. Financial statements containing barcodes are generally printed in black and white, but the uneven indoor lighting and the impact of camera quality may make the barcode color nonstandard black-and-white binary images (Figure6). According to the actual situation of this paper, the preprocessing flow chart of the barcode recognition algorithm is designed as follows:Figure 6
Barcode recognition and processing flow.


### 4.3. Barcode Positioning and Recognition Algorithm

#### 4.3.1. Barcode Location Based on Gray Projection

Gray integral projection is the process of reducing the dimension of the two-dimensional gray image according to the row/column and projecting it in a vertical/horizontal direction to obtain a one-dimensional histogram. The main basis is that there is a very obvious gray distribution in the horizontal or vertical direction of the image to be analyzed. Because the gray value of the bar code area in the selected image is very low, close to 0, while the brightness of other areas is high, close to 255, which means that the image has a very obvious gray distribution in the horizontal or vertical direction. The difference between the two directions is that when the integral projection is made in the horizontal direction, there is only one step change of “peak trough peak,” while when the integral projection is made in the vertical direction, there may be multiple step changes of “peak trough peak.” Therefore, when extracting the region through this peak/trough change, the two directions need to be processed separately, as shown in Figures7(a) and 7(b).Figure 7
(a) Image after vertical integral projection. (b) Image after horizontal integral projection.
(a)(b)


#### 4.3.2. Barcode Recognition Algorithm

The identification process of the barcode can be represented by Figure8.Figure 8
Schematic diagram of the barcode recognition process.For the segmented and corrected ROI region images, the initial and end positions of barcode recognition are found according to the projection peak method. According to the coding law of the code39 barcode, the whole barcode area is divided according to the coding rules of the code39 codeword. The barcode symbols represented in each area are extracted and recognized in turn. After decoding, they are matched with the corresponding numbers and characters stored in the preestablished database, and finally, the recognition results are output. Fortunately, there is a relatively mature open source barcode recognition component Google ZXing, which can recognize 13 barcodes. Therefore, in this system, after barcode positioning and correction, ZXing is directly called to complete the identification of code39. The most important thing is how to scan the bars and spaces in the barcode, that is, it is necessary to calculate a local optimal segmentation threshold to binarize the barcode area. In order to test the performance of the system algorithm, a self-made barcode image library is used for recognition. Considering that the system is used indoors and the barcode area will be printed in the specified blank when printing financial statements, there is no very chaotic barcode background area. This algorithm is used to recognize 100 barcode pictures with basically clear image shooting quality and basically flat declaration under indoor lighting, and the correct decoding results are obtained, with a recognition success rate of 91. For the 8 barcode diagrams incorrectly identified, the main problem is still the problem of barcode positioning. Due to the paper distortion and dark light in the handheld printing barcode area, the positioning of the barcode area failed, resulting in subsequent identification. In contrast, if only ZXing is used for barcode recognition, the accuracy will drop to 86%. It is analyzed that the main problem may exist in the correction part of the algorithm in this paper, which improves the standardization of barcode area and is conducive to the clear segmentation between “bar” and “empty,” so it can improve the recognition rate of ZXing.


## 4.1. Barcode Image Preprocessing

### 4.1.1. Image Grayscale Stretching

Image grayscale stretching is a kind of point operation of image. Point operation is a simple and very important image processing technology, which can realize the gray range occupied by image data. The input image generates a new output image after point operation, and the gray value of the corresponding output point is determined by the gray value of the input pixel point. Therefore, point operation is an operation that does not change the spatial relationship in the image. The point operation can change the gray histogram of an image in a predetermined way. If it is assumed that the input image isIx,y and the output image is I′x,y, the pixel-based operation applied to the input image is
(10)dGu,t=∫gu,tdtdu.Image gray stretching is a typical point operation process, which is generally a linear transformation of gray. However, it should be emphasized that the gray stretching of an image is a piecewise linear transformation, which is usually not a linear transformation of all domains. Gray stretch is a fast and flexible technique to adjust the gray histogram distribution of the whole image. If the gray stretching area is selected instead of limited to the whole image, the gray stretching can also selectively adjust the histogram of a gray interval of the image to improve the output value of the desired enhanced part of the gray domain. It can be represented by the following schematic diagram (Figure2):Figure 2
Gray scale stretching diagram.


### 4.1.2. Image Histogram and Threshold Segmentation

A histogram is a frequently used tool in analyzing and processing images. The histogram distributes the obtained probability values to several distribution intervals that have been defined in advance by counting the probability distribution in all data. The value in bin can be a pixel gray value, gradient, direction, color, or any other feature. After histogram calculation, the dimension of the histogram will be much lower than that of the original image. Then, in digital image processing, the histogram represents the gray level content of an image, is a function of the image gray level, and expresses the number of pixels with this gray level in the current image. The histogram drawn is a two-dimensional statistical image. Its abscissa represents the gray level of the pixel, and its ordinate represents the frequency of the gray level or the number of pixels of the image at the gray level. Figure3 shows a gray image and its corresponding gray histogram. Figure 3 describes the main forms of the image histogram and threshold separation.Figure 3
Gray image and its corresponding histogram.


### 4.1.3. Corrosion and Expansion of the Image

Mathematical morphology is based on the set theory. In image processing technology, the set of morphology represents the shape of binary or gray image. Usually, the selected set is the foreground of the image, that is, those pixels set to 255 after threshold segmentation, while the unselected set is the background of the image, that is, the pixels set to 0 after threshold segmentation. In this paper, the processed binary image is used as the element set of morphological processing. The basic morphological processing mainly includes four operations: erosion, dilation, open, and close. The on operation is to corrode the binary image first and then expand it. The closing operation is to expand the binary image first and then corrode it. Therefore, the basic operation of morphological treatment is corrosion and expansion. Leta and B be the sets in the complete set P of pixels, and then, a is corroded by B. Here, a is the front scenic spot of the binarization result image (i.e., the point with the value of 255) and B is the structural element defined according to the requirements. The corrosion process is shown in Figure 4.Figure 4
Corrosion diagram.The main function of corrosion in morphological operation is to eliminate the boundary of objects. Corrosion can remove objects smaller than structural elements from the original binary image and obtain a cleaner foreground image. Therefore, if there is a very small connection between two objects, when the designed structural elements are large enough, the two objects can be separated by corrosion operation. After etching, the whole image can be clean and smooth. Leta and B be sets in the complete set P of pixels, and then, set a is expanded by structural element B. The expansion process is shown in Figure 5.Figure 5
Expansion diagram.The main function of expansion operation is to expand the boundary points outward, so that the small areas that may not be connected at first are connected together after inflation treatment and merged into a large connected area. Therefore, expansion can be used to fill the holes in the binary image, expand the outer contour of the target outward, increase the target area, and bridge small cracks, fractures, and broken small pixel blocks through expansion operation.


## 4.1.1. Image Grayscale Stretching

Image grayscale stretching is a kind of point operation of image. Point operation is a simple and very important image processing technology, which can realize the gray range occupied by image data. The input image generates a new output image after point operation, and the gray value of the corresponding output point is determined by the gray value of the input pixel point. Therefore, point operation is an operation that does not change the spatial relationship in the image. The point operation can change the gray histogram of an image in a predetermined way. If it is assumed that the input image isIx,y and the output image is I′x,y, the pixel-based operation applied to the input image is
(10)dGu,t=∫gu,tdtdu.Image gray stretching is a typical point operation process, which is generally a linear transformation of gray. However, it should be emphasized that the gray stretching of an image is a piecewise linear transformation, which is usually not a linear transformation of all domains. Gray stretch is a fast and flexible technique to adjust the gray histogram distribution of the whole image. If the gray stretching area is selected instead of limited to the whole image, the gray stretching can also selectively adjust the histogram of a gray interval of the image to improve the output value of the desired enhanced part of the gray domain. It can be represented by the following schematic diagram (Figure2):Figure 2
Gray scale stretching diagram.


## 4.1.2. Image Histogram and Threshold Segmentation

A histogram is a frequently used tool in analyzing and processing images. The histogram distributes the obtained probability values to several distribution intervals that have been defined in advance by counting the probability distribution in all data. The value in bin can be a pixel gray value, gradient, direction, color, or any other feature. After histogram calculation, the dimension of the histogram will be much lower than that of the original image. Then, in digital image processing, the histogram represents the gray level content of an image, is a function of the image gray level, and expresses the number of pixels with this gray level in the current image. The histogram drawn is a two-dimensional statistical image. Its abscissa represents the gray level of the pixel, and its ordinate represents the frequency of the gray level or the number of pixels of the image at the gray level. Figure3 shows a gray image and its corresponding gray histogram. Figure 3 describes the main forms of the image histogram and threshold separation.Figure 3
Gray image and its corresponding histogram.


## 4.1.3. Corrosion and Expansion of the Image

Mathematical morphology is based on the set theory. In image processing technology, the set of morphology represents the shape of binary or gray image. Usually, the selected set is the foreground of the image, that is, those pixels set to 255 after threshold segmentation, while the unselected set is the background of the image, that is, the pixels set to 0 after threshold segmentation. In this paper, the processed binary image is used as the element set of morphological processing. The basic morphological processing mainly includes four operations: erosion, dilation, open, and close. The on operation is to corrode the binary image first and then expand it. The closing operation is to expand the binary image first and then corrode it. Therefore, the basic operation of morphological treatment is corrosion and expansion. Leta and B be the sets in the complete set P of pixels, and then, a is corroded by B. Here, a is the front scenic spot of the binarization result image (i.e., the point with the value of 255) and B is the structural element defined according to the requirements. The corrosion process is shown in Figure 4.Figure 4
Corrosion diagram.The main function of corrosion in morphological operation is to eliminate the boundary of objects. Corrosion can remove objects smaller than structural elements from the original binary image and obtain a cleaner foreground image. Therefore, if there is a very small connection between two objects, when the designed structural elements are large enough, the two objects can be separated by corrosion operation. After etching, the whole image can be clean and smooth. Leta and B be sets in the complete set P of pixels, and then, set a is expanded by structural element B. The expansion process is shown in Figure 5.Figure 5
Expansion diagram.The main function of expansion operation is to expand the boundary points outward, so that the small areas that may not be connected at first are connected together after inflation treatment and merged into a large connected area. Therefore, expansion can be used to fill the holes in the binary image, expand the outer contour of the target outward, increase the target area, and bridge small cracks, fractures, and broken small pixel blocks through expansion operation.


## 4.2. Pretreatment Process of Barcode Identification

The above is the basic knowledge of image processing that may be involved in the preprocessing process. According to the research content of this paper, the algorithm of preprocessing link will be selected pertinently, considering that when shooting barcode images, ordinary microcameras are generally used and the barcode area is printed in the blank of the header of financial statements and photographed by hand. There may be paper tilt and inconsistent barcode image scale. Financial statements containing barcodes are generally printed in black and white, but the uneven indoor lighting and the impact of camera quality may make the barcode color nonstandard black-and-white binary images (Figure6). According to the actual situation of this paper, the preprocessing flow chart of the barcode recognition algorithm is designed as follows:Figure 6
Barcode recognition and processing flow.


## 4.3. Barcode Positioning and Recognition Algorithm

### 4.3.1. Barcode Location Based on Gray Projection

Gray integral projection is the process of reducing the dimension of the two-dimensional gray image according to the row/column and projecting it in a vertical/horizontal direction to obtain a one-dimensional histogram. The main basis is that there is a very obvious gray distribution in the horizontal or vertical direction of the image to be analyzed. Because the gray value of the bar code area in the selected image is very low, close to 0, while the brightness of other areas is high, close to 255, which means that the image has a very obvious gray distribution in the horizontal or vertical direction. The difference between the two directions is that when the integral projection is made in the horizontal direction, there is only one step change of “peak trough peak,” while when the integral projection is made in the vertical direction, there may be multiple step changes of “peak trough peak.” Therefore, when extracting the region through this peak/trough change, the two directions need to be processed separately, as shown in Figures7(a) and 7(b).Figure 7
(a) Image after vertical integral projection. (b) Image after horizontal integral projection.
(a)(b)


### 4.3.2. Barcode Recognition Algorithm

The identification process of the barcode can be represented by Figure8.Figure 8
Schematic diagram of the barcode recognition process.For the segmented and corrected ROI region images, the initial and end positions of barcode recognition are found according to the projection peak method. According to the coding law of the code39 barcode, the whole barcode area is divided according to the coding rules of the code39 codeword. The barcode symbols represented in each area are extracted and recognized in turn. After decoding, they are matched with the corresponding numbers and characters stored in the preestablished database, and finally, the recognition results are output. Fortunately, there is a relatively mature open source barcode recognition component Google ZXing, which can recognize 13 barcodes. Therefore, in this system, after barcode positioning and correction, ZXing is directly called to complete the identification of code39. The most important thing is how to scan the bars and spaces in the barcode, that is, it is necessary to calculate a local optimal segmentation threshold to binarize the barcode area. In order to test the performance of the system algorithm, a self-made barcode image library is used for recognition. Considering that the system is used indoors and the barcode area will be printed in the specified blank when printing financial statements, there is no very chaotic barcode background area. This algorithm is used to recognize 100 barcode pictures with basically clear image shooting quality and basically flat declaration under indoor lighting, and the correct decoding results are obtained, with a recognition success rate of 91. For the 8 barcode diagrams incorrectly identified, the main problem is still the problem of barcode positioning. Due to the paper distortion and dark light in the handheld printing barcode area, the positioning of the barcode area failed, resulting in subsequent identification. In contrast, if only ZXing is used for barcode recognition, the accuracy will drop to 86%. It is analyzed that the main problem may exist in the correction part of the algorithm in this paper, which improves the standardization of barcode area and is conducive to the clear segmentation between “bar” and “empty,” so it can improve the recognition rate of ZXing.


## 4.3.1. Barcode Location Based on Gray Projection

Gray integral projection is the process of reducing the dimension of the two-dimensional gray image according to the row/column and projecting it in a vertical/horizontal direction to obtain a one-dimensional histogram. The main basis is that there is a very obvious gray distribution in the horizontal or vertical direction of the image to be analyzed. Because the gray value of the bar code area in the selected image is very low, close to 0, while the brightness of other areas is high, close to 255, which means that the image has a very obvious gray distribution in the horizontal or vertical direction. The difference between the two directions is that when the integral projection is made in the horizontal direction, there is only one step change of “peak trough peak,” while when the integral projection is made in the vertical direction, there may be multiple step changes of “peak trough peak.” Therefore, when extracting the region through this peak/trough change, the two directions need to be processed separately, as shown in Figures7(a) and 7(b).Figure 7
(a) Image after vertical integral projection. (b) Image after horizontal integral projection.
(a)(b)


## 4.3.2. Barcode Recognition Algorithm

The identification process of the barcode can be represented by Figure8.Figure 8
Schematic diagram of the barcode recognition process.For the segmented and corrected ROI region images, the initial and end positions of barcode recognition are found according to the projection peak method. According to the coding law of the code39 barcode, the whole barcode area is divided according to the coding rules of the code39 codeword. The barcode symbols represented in each area are extracted and recognized in turn. After decoding, they are matched with the corresponding numbers and characters stored in the preestablished database, and finally, the recognition results are output. Fortunately, there is a relatively mature open source barcode recognition component Google ZXing, which can recognize 13 barcodes. Therefore, in this system, after barcode positioning and correction, ZXing is directly called to complete the identification of code39. The most important thing is how to scan the bars and spaces in the barcode, that is, it is necessary to calculate a local optimal segmentation threshold to binarize the barcode area. In order to test the performance of the system algorithm, a self-made barcode image library is used for recognition. Considering that the system is used indoors and the barcode area will be printed in the specified blank when printing financial statements, there is no very chaotic barcode background area. This algorithm is used to recognize 100 barcode pictures with basically clear image shooting quality and basically flat declaration under indoor lighting, and the correct decoding results are obtained, with a recognition success rate of 91. For the 8 barcode diagrams incorrectly identified, the main problem is still the problem of barcode positioning. Due to the paper distortion and dark light in the handheld printing barcode area, the positioning of the barcode area failed, resulting in subsequent identification. In contrast, if only ZXing is used for barcode recognition, the accuracy will drop to 86%. It is analyzed that the main problem may exist in the correction part of the algorithm in this paper, which improves the standardization of barcode area and is conducive to the clear segmentation between “bar” and “empty,” so it can improve the recognition rate of ZXing.


## 5. Conclusion

Barcode technology is an important technology of information dissemination and material transmission. Aiming at the problems of manual financial statement management, low-data sharing rate, and high-manual input error rate in the current financial management system of small- and medium-sized enterprises, this paper designs the barcode embedding system in the financial statement system, realizes the code39 barcode in the designated area of the declaration through the CCD camera, and completes the entry of the declaration information by the financial management department. Considering the existing open-source decoding plug-in ZXing, its own decoding accuracy has achieved ideal results. Therefore, this paper focuses on how to apply the image recognition algorithm of the partial differential equation to the barcode location. By improving the positioning rate and correction rate, the quality of the barcode recognition image input into ZXing is improved, so as to improve the recognition rate of the barcode. The main research contents of this subject are summarized as follows:Firstly, it introduces the research background and significance of this subject, expounds the background and research significance of barcode recognition technology based on digital image analysis, and summarizes the application of existing image processing technology and barcode positioning and recognition technology in the financial statement system at home and abroad. Next, the basic image preprocessing technologies involved in the barcode positioning and recognition algorithm studied in this paper are introduced, such as image graying and so on. These image processing algorithms can give an ideal image contour of the barcode target, which is the basis of the barcode target location. Then, the function of barcode positioning and recognition is realized. This paper focuses on the preliminary positioning of the barcode area and the rotation correction of barcode, so as to obtain an ideal barcode image. Finally, the performance of the barcode positioning and recognition algorithm proposed in this paper is tested. The reliability and effectiveness of the algorithm are verified on the artificially made test set. This paper also summarizes the work already carried out and looks forward to the future research direction, in order to provide further optimization for this system in the future.



---

*Source: 9177159-2021-12-13.xml*