Efficient bar code binarization method and systemTechnical Field
The invention relates to the technical field of electronic science, in particular to a bar code binarization method and a bar code binarization system.
Background
The advent of bar code technology has greatly facilitated the rapid development of industrial society. Whether production and transportation, logistics storage, product part tracking and the like, the bar code recognition technology remarkably improves the completion efficiency of each task.
The bar code recognition technology is early, but research in the field in China starts later, and although progress is made, a certain gap is still kept compared with the foreign bar code recognition technology. In practical application, the barcode recognition environment is more complex and changeable, so that low-quality barcode images with fuzzy, low contrast, low precision and the like are more easily acquired, the low-quality images can seriously influence the barcode binarization effect, and the accuracy of the barcode binarization is a key for determining the performance of a barcode recognition algorithm.
Therefore, in view of the above problems, there is a need for an efficient and stable binarization method to improve the barcode recognition efficiency.
Disclosure of Invention
Aiming at the problem that the current fuzzy, low-contrast and low-precision bar code binarization is inaccurate, the invention provides a bar code binarization method and a bar code binarization system, which can ensure that bar code binarization is efficiently and accurately completed.
One of the present invention is realized as follows: an efficient bar code binarization method, which constructs a sampling image based on a sampling grid and completes sample point binarization by a secondary verification method, comprises the following steps:
 Step1, constructing a sampling grid;
 step 2, generating a sampling graph by adopting an interpolation method according to the grid positions;
 Step 3, performing binarization on the sampling graph by adopting a first binarization method;
 Step 4, performing binarization on the sampled image by adopting a second binarization method;
 Step 5, judging whether two binarization results of each sampling point in the step 4 and the step 5 are the same or not, if the judgment result is yes, storing the binarization result of the sampling point, and if the judgment result is no, marking the sampling point as a suspicious point;
 And 6, re-executing binarization on the suspicious points according to a third binarization method, and storing the binarization result.
Further, in the step 1, the sampling grid needs to cover the center point of the minimum module of the corresponding bar code.
Further, in the step 2, the interpolation method may be nearest neighbor interpolation, bilinear interpolation, weighted average, and other interpolation methods.
Further, the binarization method can map the sampled image into a pair of black-and-white binary images;
 Further, in the steps 5 and 6, the first, second and third binarization methods are different from each other, and the three binarization methods may be completed based on different principles or may be completed based on different manners. The third binarization method is higher in precision than the first and second binarization methods, and the execution efficiency of the first and second binarization methods is obviously better than that of the third binarization method;
 further, the two binarization methods adopt different design ideas, such as global binarization and local binarization methods;
 further, the two binarization modes adopt the same principle, but the modes are different, and can be that image binarization is completed on a row-by-row basis and image binarization is completed on a column-by-column basis.
The second invention is realized in the following way: an efficient bar code binarization system, comprising: the device comprises a sampling grid construction unit, a gray value sampling unit, a first binarization unit, a second binarization unit, a binarization result comparison unit, a suspicious binarization result screening unit, a third binarization unit, a correct binarization result screening unit and a binary map storage unit.
The sampling grid construction unit is used for constructing a sampling grid according to the bar code symbol positions;
 The gray value sampling unit is used for completing the gray value sampling of the bar code minimum module by any interpolation method according to the sampling grid position;
 A first binarization unit that performs a first binarization process on the sampling matrix;
 a second binarization unit for performing a second binarization process on the sampling matrix;
 The binarization result comparison unit is used for comparing the output results of the first binarization unit and the second binarization unit, wherein the same marks are 1, and the different marks are 0;
 The suspicious binarization screening unit screens out sampling points marked with 0 and marks the sampling points as suspicious binarization sampling points;
 A binarization unit III, which carries out third binarization processing on the suspicious binarization sampling points;
 the correct binarization screening unit screens out sampling points marked as 1 and marks the sampling points as correct binarization sampling points;
 and the binary image storage unit is used for storing the correct binary sampling point sampling result and the binary result of the suspicious binary sampling point after the third binarization is performed.
Further, the sampling grid needs to cover the center position of the minimum module of the corresponding bar code;
 further, the gray value sampling unit completes the gray value sampling of the bar code minimum module by any interpolation method according to the sampling grid position, and a gray sampling matrix is constructed;
 the bar code binarization method and the bar code binarization system comprehensively consider the balance of time and performance, and the adopted first and second binarization methods have high execution efficiency and ensure that most sampling points have correct binarization results. And (3) screening out suspicious binarized sampling points through comparison of two kinds of binary results, and further finishing binarization processing on the suspicious sampling points by adopting a third binarization method with high accuracy, thereby finishing binarization of the whole sampling matrix. The invention improves the system operation efficiency on the premise of ensuring the binarization accuracy, and solves the problem that the accuracy and the efficiency cannot be considered to a certain extent.
[ Description of the drawings ]
FIG. 1 is a flow chart of the bar code binarization method of the present invention.
Fig. 2 is a schematic diagram of the bar code binarization system according to the present invention.
Figure 3 illustrates an alternative binarization method embodying the present invention.
Fig. 4 illustrates an alternative method for binarizing a suspicious spot according to embodiments of the present invention.
[ Detailed description ] of the invention
For the features and technical content of the present invention, please refer to the following detailed description and the accompanying drawings, which are provided for reference and illustration only, and are not meant to limit the present invention.
Referring to fig. 1, a flowchart of the bar code binarization method of the present invention is shown, and the specific steps of the bar code binarization method are as follows:
 In step S100, sampling grids are constructed, and each independent grid can precisely cover the center point of the bar code module.
Step S200, extracting the gray value of the sampling point of the bar code module on the sampling grid according to the interpolation algorithm to obtain a sampling image.
Step S300, performing a binarization operation on the sampled image to obtain a binarized image a.
Step S400, another binarization operation is performed on the sampled image to obtain a binarized image B.
Step S500, initializing i=0, comparing whether the binarized attributes of the ith module in a/B are the same, if yes, executing S700, if no, executing S600.
Step S600, re-executing binarization for the i-th module.
Step S700, the binary attribute of the ith module is stored, i is increased by 1.
Step S800, judging whether the ith module is the last unprocessed module in the sampling chart, if yes, executing step S900, and if no, executing step S500.
Step S900: and after traversing all the sampling modules, finishing bar code binarization.
Referring to fig. 2, a schematic structural diagram of the bar code binarization system of the present invention is shown, and the system structure includes the following units:
 And the sampling grid construction unit 100 establishes a sampling grid according to the bar code symbol positions, and the sampling grid needs to cover the center position of the corresponding bar code minimum module.
And the gray value sampling unit 200 completes the gray value sampling of the bar code minimum module by any interpolation method according to the sampling grid positions.
The binarization unit 300 performs a first binarization process on the sampling matrix.
The binarization unit 400 performs a second binarization process on the sampling matrix.
The binarization result comparing unit 500 performs a comparison operation on the output results of the first and second binarization units, and is labeled 1 for the same reason and 0 for the different reason.
The suspicious binarization filtering unit 600 filters out sampling points marked as 0, and marks the sampling points as suspicious binarization sampling points.
And a third binarization unit 700 for performing third binarization processing on the suspicious binarization sampling point.
The correct binarization filtering unit 800 filters out sampling points marked with 1 and marks the sampling points as correct binarization sampling points.
The binary map storage unit 900 stores the correct binarized sampling point sampling result and the binary result of the suspicious binarized sampling point on which the third binarization is performed.
Referring to fig. 3, an alternative binarization method embodying the present invention is shown. The first binarization method is to traverse the sampled image line by line, perform waveform analysis operation on each one-dimensional data, and determine the binary attribute of the current module according to the peak-trough attribute of each module. Due to image noise, gray value fluctuation caused by factors such as image local gray non-uniformity seriously affects the binarization result of the sampling image, and the reliability of the binarization result is reduced. According to the present invention, a second binarization method, i.e., traversing the sampled image column by column again, can be performed and a waveform analysis operation can be performed. After binarization of the row-column direction based on waveform analysis, if the two binarization results are different, determining the suspicious binarization module.
Referring to fig. 4, an optional method for determining the binarization of suspicious points according to the embodiment of the present invention is shown. Due to image noise, local gray scale of an image is uneven, the binary attribute of the module cannot be determined by a single threshold value, and the binary attribute of the module is highly dependent on local neighborhood gray scale value distribution.
As shown in fig. 4, 3 examples of judging suspicious module binary attributes are enumerated.
As shown in fig. 4 (a), the vertical analysis display center module is "white" in attribute, the horizontal analysis display center module is in the gray transition area, but the gray value of the center module is similar to the gray value of the left module, and the left module is obviously "white", so that the module can be judged to be "white".
As shown in fig. 4 (b), the vertical analysis display center module is "black" in attribute, the horizontal analysis display center module is in the gray transition area, but the gray value of the center module is similar to the gray value of the left module, and the left module is obviously "black", so that the module can be judged to be "black".
As shown in fig. 4 (c), the vertical analysis display center module attribute is "white", and the horizontal analysis display center module attribute is "white", so that the module attribute can be judged as "white".
The above description is merely a preferred embodiment of the present invention, and those skilled in the art may make various modifications and alterations thereto without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.