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 barcode technology has greatly facilitated the rapid development of industrial society. The barcode identification technology remarkably improves the completion efficiency of each task no matter production and transportation, logistics storage, or product part tracking and the like.
The barcode identification technology appears earlier, but the research in the field starts later in China, and although the technology has already advanced, the technology has a certain gap compared with the foreign barcode identification technology. In practical application, the barcode recognition environment is more complex and changeable, so that low-quality barcode images such as blur, low contrast, low precision and the like can be more easily acquired, the low-quality images can seriously affect the barcode binarization effect, and the accuracy of barcode binarization is the key for determining the performance of a barcode recognition algorithm.
Therefore, in order to solve the above problems, an efficient and stable binarization method is needed to improve the barcode recognition efficiency.
Disclosure of Invention
Aiming at the problem that the existing fuzzy, low-contrast and low-precision bar code binaryzation is inaccurate, the invention provides a bar code binaryzation method and a bar code binaryzation system, which can ensure that the bar code binaryzation is completed efficiently and accurately.
One of the present invention is realized by: an efficient bar code binarization method is used for constructing a sampling image based on a sampling grid and completing binarization of sampling points by a secondary verification method, and comprises the following steps:
step 1, constructing a sampling grid;
step 2, generating a sampling graph by adopting an interpolation method according to the grid position;
step 3, performing binarization on the sampling image 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 thestep 5 are the same, 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-performing binarization on the suspicious points according to a third binarization method, and storing binarization results.
Further, in step 1, the sampling grid needs to cover the central point of the corresponding barcode minimum module.
Further, in the step 2, the interpolation method may be nearest neighbor interpolation, bilinear interpolation, weighted average, or other interpolation methods.
Further, the binarization method can map the sampling image into a black-and-white binary image;
further, in thesteps 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 different manners. The precision of the third binarization method is higher than the precision of the first binarization method and the second binarization method, and the execution efficiency of the first binarization method and the second binarization method is obviously better than that of the third binarization method;
further, the two binarization methods adopt different design ideas and can be global binarization methods, local binarization methods and the like;
further, the two binarization modes adopt the same principle, but different modes, and can be image binarization based on waveform analysis line by line, and the like.
The second invention is realized by the following steps: an efficient barcode binarization system, comprising: the device comprises a sampling grid construction unit, a gray value sampling unit, a binarization unit I, a binarization unit II, a binarization result comparison unit, a suspicious binarization result screening unit, a binarization unit III, a correct binarization result screening unit and a binary image storage unit.
The sampling grid construction unit is used for establishing a sampling grid according to the position of the bar code symbol;
the gray value sampling unit completes the gray value sampling of the minimum module of the bar code by any interpolation method according to the sampling grid position;
a first binarization unit for performing first binarization processing on the sampling matrix;
a second binarization unit which executes second binarization processing on the sampling matrix;
the binarization result comparison unit is used for performing comparison operation on output results of the first binarization unit and the second binarization unit, wherein the output results are marked as 1 in the same way and are marked as 0 in different ways;
the suspicious binarization screening unit screens out the sampling points marked as 0 and marks the sampling points as suspicious binarization sampling points;
a third binarization unit, which is used for carrying out third binarization processing on the suspicious binarization sampling points;
a correct binarization screening unit for screening out the sampling points marked as 1 and marking the sampling points as correct binarization sampling points;
and the binary image storage unit is used for storing the sampling result of the correct binary sampling point and the binary result of the suspicious binary sampling point after the third binary operation.
Furthermore, the sampling grid needs to be covered to the central position of the corresponding bar code minimum module;
furthermore, the gray value sampling unit completes the gray value sampling of the minimum module of the bar code by any interpolation method according to the sampling grid position, and constructs a gray sampling matrix;
the bar code binarization method and the bar code binarization system comprehensively consider the balance between time and performance, the adopted first binarization method and the adopted second binarization method have high execution efficiency, and most sampling points are ensured to have correct binarization results. And (4) screening out suspicious binary sampling points by comparing two binary results, and further completing binary processing on the suspicious sampling points by adopting a third binary method with high accuracy so as to complete the binarization of the whole sampling matrix. On the premise of ensuring the binarization accuracy, the invention improves the system operation efficiency and solves the problem that the precision and the efficiency can not be considered at the same time to a certain extent.
[ description of the drawings ]
Fig. 1 shows a flow chart of a bar code binarization method of the present invention.
Fig. 2 is a schematic structural diagram of a bar code binarization system of the invention.
Fig. 3 illustrates an alternative binarization method in accordance with an embodiment of the present invention.
Fig. 4 illustrates an alternative suspicious node binarization determination method according to an embodiment of the present invention.
[ detailed description ] embodiments
With regard to the features and technical content of the present invention, reference is made to the following detailed description and accompanying drawings, which are provided for reference and illustration only and are not intended to limit the invention.
Referring to fig. 1, a flowchart of a barcode binarization method of the present invention is shown, and the barcode binarization method specifically includes the following steps:
and S100, constructing sampling grids, wherein each independent grid can accurately cover the central point of the bar code module.
And step S200, extracting a sampling point gray value of the bar code module on a sampling grid according to an interpolation algorithm to obtain a sampling image.
And step S300, performing binarization operation once on the sampled image to obtain a binarized image A.
In 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 binarization attributes of the i-th module in the a/B are the same, if the result is yes, executing S700, and if the result is no, executing S600.
In step S600, the binarization is re-executed for the i-th module.
And S700, storing the binary attribute of the ith module, i plus 1.
Step S800, determining whether the i-th module is the last unprocessed module in the sampling graph, if the determination result is "yes", executing step S900, and if the determination result is "no", executing step S500.
Step S900: and after traversing all the sampling modules, completing the binaryzation of the bar code.
Referring to fig. 2, a schematic structural diagram of a barcode binarization system of the present invention is shown, wherein the system structure includes the following units:
and the sampling grid construction unit 100 is used for establishing a sampling grid according to the position of the bar code symbol, wherein the sampling grid needs to cover the central position of the corresponding bar code minimum module.
And the gray value sampling unit 200 completes the gray value sampling of the minimum module of the bar code by any interpolation method according to the sampling grid position.
The binarization unit one 300 performs a first binarization process on the sampling matrix.
And asecond binarization unit 400 for performing a second binarization process on the sampling matrix.
And the binarization result comparing unit 500 is used for performing comparison operation on the output results of the first binarization unit and the second binarization unit, wherein the same mark is 1, and the different marks are 0.
And the suspicious binarization screening unit 600 screens out the sampling points marked as 0 and marks the sampling points as suspicious binarization sampling points.
And athird binarization unit 700 for carrying out third binarization processing on the suspicious binarization sampling points.
The correctbinarization screening unit 800 screens out the sampling points marked as 1, and marks the sampling points as correct binarization sampling points.
The binaryimage storage unit 900 stores the sampling result of the correct binary sampling point and the binary result of the suspicious binary sampling point after the third binary operation.
Referring to fig. 3, an alternative binarization method is shown in the embodiment of the present invention. The first binarization method in the 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, the sampled image binarization result is seriously influenced by gray value fluctuation caused by factors such as local gray level unevenness of the image, and the reliability of the binarization result is reduced. According to the present invention, a second binarization method may be performed, i.e., traversing the sampled image again column by column, and performing a waveform analysis operation. After the binarization based on waveform analysis in the row and column direction, if the two binarization results are different, the module is determined to be a suspicious binarization module.
Referring to fig. 4, a method for binary determination of a selectable suspicious point is disclosed. Due to the problems of image noise, uneven local gray level of an image and the like, the binary attribute of the module cannot be determined by a single threshold, and the binary attribute of the module highly depends on the gray value distribution of the local neighborhood.
As shown in fig. 4, 3 examples of determining the binary attribute of the suspect module are listed.
As shown in fig. 4(a), the attribute of the vertical analysis display center module is "white", 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", and the module can be determined to be "white".
As shown in fig. 4(b), the attribute of the central module is "black" in the vertical analysis display, the central module is in the excessive gray level region in the horizontal analysis display, but the gray level value of the central module is similar to the gray level value of the left module, and the left module is obviously "black", and the module can be judged to be "black".
As shown in fig. 4(c), the attribute of the vertical analysis display center module is "white", and the attribute of the horizontal analysis display center module is "white", so that it can be determined that the module attribute is "white".
The foregoing is merely a preferred embodiment of the present invention, and various modifications and changes in form can be made by those skilled in the art without departing from the spirit and scope of the present invention, and it is within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.