CN115690431A - Bar code image binarization method and device, storage medium and computer equipment - Google Patents

Bar code image binarization method and device, storage medium and computer equipment Download PDF

Info

Publication number
CN115690431A
CN115690431A CN202211422277.4A CN202211422277A CN115690431A CN 115690431 A CN115690431 A CN 115690431A CN 202211422277 A CN202211422277 A CN 202211422277A CN 115690431 A CN115690431 A CN 115690431A
Authority
CN
China
Prior art keywords
score
binarization
sampling point
value
algorithm
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211422277.4A
Other languages
Chinese (zh)
Inventor
顾善中
吴俊斌
田晓明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Seuic Technologies Co Ltd
Original Assignee
Seuic Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Seuic Technologies Co Ltd filed Critical Seuic Technologies Co Ltd
Priority to CN202211422277.4A priority Critical patent/CN115690431A/en
Publication of CN115690431A publication Critical patent/CN115690431A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Facsimile Image Signal Circuits (AREA)

Abstract

The application provides a bar code image binarization method, a bar code image binarization device, a storage medium and computer equipment. The method comprises the following steps: acquiring a bar code image; identifying the central point of each unit module in the bar code image, and respectively determining the central point as a sampling point of each unit module; performing binarization scoring on each sampling point according to at least two preset binarization algorithms, and calculating the binarization scoring of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score; calculating a binarization total score of each sampling point according to the binarization score of each sampling point corresponding to each binarization algorithm; if the black score in the total binaryzation scores of the sampling points is greater than the white score, determining the unit module to which the sampling points belong as a black module; and if the black value in the total binary points of the sampling points is not greater than the white value, determining the unit module to which the sampling points belong as a white module. The method and the device can improve the accuracy of binarization processing of the bar code image.

Description

Bar code image binarization method and device, storage medium and computer equipment
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a method and an apparatus for binarizing barcode images, a storage medium, and a computer device.
Background
At present, bar codes are more and more widely applied in the fields of commodity equipment labels, mobile payment and the like, and mainly comprise one-dimensional codes and two-dimensional codes. The bar code expresses certain information through the arrangement pattern with light and shade change, can be read by a specific device, and is converted into binary and decimal information compatible with a computer. When analyzing a barcode image, it is generally necessary to perform binarization processing first for easy recognition.
The conventional main binarization method mainly comprises a global threshold and a self-adaptive threshold, but the bar code image is influenced by uneven illumination, sampling deviation, expansion or corrosion of surrounding modules in the process of collecting the bar code image, so that the bar code image is difficult to select a proper threshold, the problem of poor binarization effect is easy to occur, and the accuracy and efficiency of bar code information identification are further influenced.
Disclosure of Invention
The embodiment of the application provides a bar code image binarization method and device, a storage medium and computer equipment, which can improve the accuracy of binarization processing of a bar code image.
In a first aspect, the present application provides a method for binarizing barcode images, where the method includes:
acquiring a bar code image;
identifying the central point of each unit module in the bar code image, and respectively determining the central point as a sampling point of each unit module;
carrying out binarization scoring on each sampling point according to at least two preset binarization algorithms, and calculating the binarization scoring of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score;
calculating a binarization total score of each sampling point according to a binarization score of each sampling point corresponding to each binarization algorithm;
if the black value in the total binary scores of the sampling points is greater than the white value, determining the unit module to which the sampling points belong as a black module;
and if the black score in the total binaryzation scores of the sampling points is not greater than the white score, determining the unit module to which the sampling points belong as a white module.
In one embodiment, the binarization scoring algorithm is a global threshold algorithm, a local threshold algorithm or a neighborhood difference algorithm.
In one embodiment, when the binarization algorithm comprises the neighborhood difference algorithm, performing the calculating of the binarization score of each sampling point corresponding to each binarization scoring algorithm comprises:
calculating the gray level difference value of each sampling point and each adjacent sampling point;
calculating the sum of the gray difference value of each sampling point and each adjacent sampling point;
determining a neighborhood score according to the sum of the gray difference values;
if the sum of the gray level difference values is less than or equal to zero, the black score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the white score is equal to zero;
and if the sum of the gray level difference values is greater than zero, the white score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the black score is equal to zero.
In one embodiment, when the binarization algorithms include the global threshold algorithm, the calculating the binarization score of each sampling point corresponding to each binarization algorithm is performed and includes:
calculating a global characteristic value of the bar code image as a global threshold value; the global characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the barcode image;
determining a global score according to the global feature value;
judging whether the gray value of each sampling point is smaller than the global threshold value;
if the value is smaller than the global threshold value, the black score and the white score of the sampling point corresponding to the global threshold value algorithm are equal to the global score and zero respectively;
if the value is not less than the global threshold, the white score and the black score of the sampling point corresponding to the global threshold algorithm are equal to the global score and zero respectively.
In one embodiment, when the binarization algorithm comprises the local threshold algorithm, performing the calculating of the binarization score of each sampling point corresponding to each binarization algorithm comprises:
equally dividing the bar code image into a plurality of windows;
respectively calculating the local characteristic value of each window as the local threshold value of the window; the local characteristic value is a grey value median value, a grey value mean value or a valley value of an image histogram of the window;
determining a local score according to the local characteristic value of each window;
judging whether the gray value of each sampling point in each window is smaller than the local threshold of the window to which the sampling point belongs;
if the value is smaller than the local threshold value of the window to which the sampling point belongs, the black score of the sampling point corresponding to the local threshold value algorithm is equal to the local score, and the white score is equal to zero;
and if the value is not less than the local threshold value of the window to which the sampling point belongs, the white score of the sampling point corresponding to the local threshold value algorithm is equal to the local score, and the black score is equal to zero.
In one embodiment, the calculating a total binarization score for each sampling point according to the binarization score of each sampling point corresponding to each binarization algorithm comprises:
and accumulating the binarization scores of each sampling point corresponding to each binarization algorithm to obtain the binarization total score of each sampling point.
In one embodiment, the calculating a total binarization score for each sampling point according to the binarization score of each sampling point corresponding to each binarization algorithm includes:
according to the preset weight corresponding to each binarization algorithm, multiplying the binarization score of each sampling point corresponding to each binarization algorithm by the preset weight to calculate a weighted score;
and accumulating the weighted scores corresponding to each binarization algorithm to obtain a binarization total score of each sampling point.
In a second aspect, the present application provides a barcode image binarization device, including:
the image acquisition module is used for acquiring a bar code image;
the identification module is used for identifying the central point of each unit module in the bar code image and respectively determining the central point as a sampling point of each unit module;
the grading module is used for carrying out binarization grading on each sampling point according to at least two preset binarization algorithms and calculating the binarization grade of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score;
the total score calculating module is used for calculating the binarization total score of each sampling point according to the binarization score of each sampling point corresponding to each binarization algorithm;
the first determining module is used for determining the unit module to which the sampling point belongs as a black module when the black value in the total binary score of the sampling point is greater than the white value;
and the second determining module is used for determining the unit module to which the sampling point belongs as a white module when the black score in the total binary score of the sampling point is not more than the white score.
In a third aspect, the present application provides a storage medium having computer readable instructions stored therein, which when executed by one or more processors, cause the one or more processors to perform the steps of the method for binarizing barcode images as described in any of the above embodiments.
In a fourth aspect, the present application provides a computer device comprising: one or more processors, and a memory;
the memory stores computer readable instructions which, when executed by the one or more processors, perform the steps of the method for binarizing barcode images as described in any of the above embodiments.
According to the technical scheme, the embodiment of the application has the following advantages:
the application provides a bar code image binarization method, a bar code image binarization device, a storage medium and computer equipment, wherein the identification of a unit module is carried out on an obtained bar code image, the central point of the unit module is identified, the central point of each unit module is respectively determined as a sampling point, each sampling point is subjected to binarization scoring according to at least two binarization algorithms, the black score and the white score of each sampling point corresponding to each binarization algorithm are calculated, the binarization total score of each sampling point is calculated according to the binarization scoring (namely the black score and the white score) corresponding to each binarization algorithm, and finally the sampling point is determined to be a black module or a white module according to the size relation of the black score and the white score in the binarization total score.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a schematic flow chart of a method for binarizing barcode images in an embodiment;
FIG. 2 is a schematic diagram of a process for calculating a binarization score for each sampling point corresponding to each binarization scoring algorithm in one embodiment;
FIG. 3 is a schematic diagram of a process for calculating a binarization score corresponding to each binarization scoring algorithm for each sampling point in another embodiment;
FIG. 4 is a schematic diagram illustrating a process of calculating a binarization score for each sampling point corresponding to each binarization scoring algorithm in yet another embodiment;
FIG. 5 is a block diagram of a bar code image binarization device in an embodiment;
FIG. 6 is a diagram of the internal structure of a computer device in one embodiment.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort belong to the protection scope of the present application.
As shown in fig. 1, an embodiment of the present application provides a method for binarizing barcode images, where the method includes steps S101 to S107, where:
and step S101, acquiring a bar code image.
The bar code image is an image which needs to be identified and contains a bar code, and can be obtained after being directly acquired by image acquisition equipment.
Step S102, identifying the central point of each unit module in the bar code image, and respectively determining the central point as the sampling point of each unit module.
The unit module refers to each black bar/black dot or blank arranged according to a certain rule in the bar code area, and if the bar code is a one-dimensional code, each black bar or blank bar is a unit module; and if the bar code is a two-dimensional code, each black code point or each blank code point is a unit module. The central point of the unit module is the pixel point corresponding to the geometric central point, the central point is determined as the sampling point of the unit module to carry out subsequent binarization processing, namely, the binarization condition of the unit module is represented according to the binarization condition of the sampling point, and the phenomenon that the binarization effect is influenced due to the fact that light rays or other reasons cause chromatic aberration of the same unit module can be avoided.
And S103, performing binarization scoring on each sampling point according to at least two preset binarization algorithms, and calculating binarization scoring of each sampling point corresponding to each binarization algorithm.
The binarization scoring comprises black scores and white scores, the binarization scoring is carried out on the sampling points according to a binarization algorithm, preliminary binarization judgment is carried out on each sampling point according to the binarization algorithm, namely, each binarization algorithm can obtain a preliminary binarization result of the sampling points, and the result is used as a basis for scoring the sampling points. And if the preliminary binarization result shows that the sampling point is a dark block, the black score of the sampling point is higher than the white score.
In one embodiment, the binarization scoring algorithm is a global threshold algorithm, a local threshold algorithm or a neighborhood difference algorithm. The global threshold algorithm is different according to the selected threshold, and each threshold can be used as a binarization algorithm to carry out binarization scoring; the local threshold algorithm is different according to the selected threshold, and each threshold can be used as a binarization algorithm to carry out binarization scoring. The binaryzation algorithm selected for binaryzation scoring can be preset according to the environment or equipment condition of the collected image, and at least two binaryzation algorithms are combined to overcome the influence of the environment, equipment and other factors on the binaryzation effect in the image collecting process.
And step S104, calculating the total binary score of each sampling point according to the binary score of each sampling point corresponding to each binary algorithm.
And the binarization total score comprises a black score and a white score of the binarization total score which are calculated according to the black score and the white score in each binarization score respectively.
In one embodiment, the binarization scores of each sampling point corresponding to each binarization algorithm are accumulated to obtain a binarization total score of each sampling point.
In one embodiment, according to the preset weight corresponding to each binarization algorithm, multiplying the binarization score of each sampling point corresponding to each binarization algorithm by the preset weight to calculate a weighted score; and accumulating the weighted scores corresponding to each binarization algorithm to obtain a binarization total score of each sampling point. The influence degree of each binarization algorithm on the binarization result can be adjusted by adjusting the preset weight, and the weight can be configured according to the collection environment and the collection equipment characteristics of the bar code image, so that the accuracy of the binarization result is improved.
And step S105, comparing whether the black score in the total binary score of each sampling point is greater than the white score.
And step S106, if the black score in the total binary scores of the sampling points is greater than the white score, determining the unit module to which the sampling points belong as a black module.
And S107, if the black score in the total binaryzation scores of the sampling points is not more than the white score, determining the unit module to which the sampling points belong as a white module.
And judging whether the binarization result of each sampling point is a black pixel point or a white pixel point according to a binarization total score calculated by integrating the binarization scores obtained by at least two binarization algorithms, and further determining that the unit module to which the sampling point belongs is a black module or a white module. Judging each sampling point respectively, and if the black value in the total binary score is greater than the white value, judging the corresponding sampling point to be a black pixel point, wherein the unit module to which the sampling point belongs is a black module; if the black score in the total binaryzation score is not greater than the white score, the corresponding sampling point is judged to be a white pixel point, and the unit module to which the sampling point belongs is a white module. The method does not depend on a single threshold value for judgment, but performs binarization by combining a plurality of binarization algorithms, thereby effectively avoiding the problem of binarization error caused by improper selection of the threshold value
In the embodiment, through identifying the unit module of the acquired barcode image, identifying the central point of the unit module, respectively determining the central point of each unit module as the sampling point, performing binarization scoring on each sampling point according to at least two binarization algorithms, calculating the black score and the white score of each sampling point corresponding to each binarization algorithm, calculating the total binarization score of each sampling point according to the binarization scoring (namely the black score and the white score) corresponding to each binarization algorithm, and finally determining the sampling point as the black module or the white module according to the size relationship between the black score and the white score in the total binarization score, the problem of binarization misjudgment caused by improper threshold value selection can be overcome, the preliminary identification results of multiple binarization algorithms are determined together, and the binarization accuracy is improved.
As shown in fig. 2, in one embodiment, when the binarization algorithms include a neighborhood difference algorithm, the calculating the binarization score of each sampling point corresponding to each binarization scoring algorithm includes:
step S201, calculating the gray level difference value of each sampling point and each adjacent sampling point;
step S202, calculating the sum of the gray level difference value of each sampling point and each adjacent sampling point;
step S203, determining a neighborhood score according to the sum of the gray level difference values;
step S204, comparing whether the sum of the gray difference values is larger than zero.
Step S205, if the sum of the gray level difference values is less than or equal to zero, the black score of the sampling point corresponding to the neighborhood difference algorithm is equal to the neighborhood score, and the white score is equal to zero;
in step S206, if the sum of the gray level differences is greater than zero, the white score and the black score of the sampling point corresponding to the neighborhood difference algorithm are equal to the neighborhood score and zero, respectively.
The adjacent sampling points may be four-direction adjacent or eight-direction adjacent, the adjacent sampling points may be adjacent pixel points or may not be adjacent pixel points, and the adjacent sampling points refer to the nearest sampling points in a certain direction of the sampling points which are currently identified. The neighborhood score may be a preset fixed score corresponding to the neighborhood difference algorithm, or may be a preset weight corresponding to the neighborhood difference algorithm, and the product of the absolute value of the gray-scale difference sum and the preset weight is used as the neighborhood score.
For example, if the gray level difference between a certain sampling point and adjacent sampling points in four directions is D1, D2, D3, and D4, respectively, the sum of the gray level differences is calculated as D = D1+ D2+ D3+ D4, and if D is less than or equal to zero, the neighborhood score is recorded as a black score, and the white score is zero; and if D is larger than zero, recording the neighborhood score as a white score, and recording the black score as zero.
The condition that binaryzation cannot be carried out through a threshold value possibly exists in a bar code image, for example, an uneven contrast area exists, binaryzation scoring is carried out through a neighborhood difference algorithm, the gray difference value of a unit module is used for judging, the gray difference value of each sampling point and each adjacent sampling point is calculated by taking the alternate black and white change of the bar code as prior information, the problem that contrast change is inconsistent due to sampling deviation, expansion or corrosion of surrounding modules can be effectively solved, and the binaryzation accuracy is improved.
As shown in fig. 3, in one embodiment, when the binarization algorithm includes the global threshold algorithm, the calculating the binarization score of each sampling point corresponding to each binarization algorithm includes:
step S301, calculating a global characteristic value of the barcode image as a global threshold value.
And the global characteristic value is the gray value median value, the gray value mean value or the valley value of the image histogram of the barcode image.
Step S302, determining a global score according to the global feature value.
Wherein the global score may be a preset score corresponding to the global feature value. Different scores may be preset for different global feature values, respectively. In another embodiment, the same score may also be set.
Step S303, determining whether the gray level of each sampling point is less than the global threshold.
Step S304, if the value is smaller than the global threshold, the black score and the white score of the sampling point corresponding to the global threshold algorithm are equal to the global score and zero, respectively.
In step S305, if not less than the global threshold, the white score and the black score of the sampling point corresponding to the global threshold algorithm are equal to the global score and zero, respectively.
In the embodiment, the global feature value is used as the global threshold value to perform binarization scoring, so that the calculated amount is small, and the problem of monochrome area binarization failure can be solved. In some embodiments, the binarization score obtained by the global threshold algorithm may be used as an initial score, and the final judgment may be performed in combination with the binarization scores of other algorithms. In some embodiments, different global feature values can be respectively used as global threshold values to perform binarization scoring, so as to overcome the problem that binarization is not accurate due to inappropriate threshold value selection. In some embodiments, the binarization scores derived from one or more global feature values may be binarized in conjunction with binarization scores derived from other types of algorithms.
As shown in fig. 4, in one embodiment, when the binarization algorithm includes a local threshold algorithm, the calculating the binarization score of each sampling point corresponding to each binarization algorithm includes:
step S401, the bar code image is equally divided into a plurality of windows.
Step S402, respectively calculating a local feature value of each window as a local threshold of the window.
The local characteristic value is the gray value median, the gray value mean or the valley of the image histogram of each window.
And step S403, determining a local score according to the local characteristic value of each window.
The local score may be a preset score value corresponding to the local feature value. In one embodiment, different scores may be preset for different local feature values, respectively. In another embodiment, the same score may also be set.
Step S404, determining whether the gray level of each sampling point in each window is smaller than the local threshold of the window to which the sampling point belongs.
Step S405, if the value is smaller than the local threshold of the window to which the sampling point belongs, the black score of the sampling point corresponding to the local threshold algorithm is equal to the local score, and the white score is equal to zero.
Step S406, if the value is not less than the local threshold of the window to which the sampling point belongs, the white score of the sampling point corresponding to the local threshold algorithm is equal to the local score, and the black score is equal to zero.
In the process of collecting the image, the brightness of different areas may be different, the barcode image is equally divided into a plurality of windows, and each window determines a local threshold value according to the characteristic parameters of the window to perform binarization judgment, so that the negative influence of the brightness difference of the areas on the binarization result can be reduced. In some embodiments, different local feature values can be respectively used as local threshold values to perform binarization scoring, so that the problem of inaccurate binarization caused by improper threshold value selection is solved. In some embodiments, the binarization scores obtained by one or more local feature values may be binarized together with binarization scores obtained by other types of algorithms.
It should be understood that, although the steps in the flowcharts related to the embodiments as described above are sequentially displayed as indicated by arrows, the steps are not necessarily performed sequentially as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the embodiments described above may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution order of the steps or stages is not necessarily sequential, but may be rotated or alternated with other steps or at least a part of the steps or stages in other steps.
The barcode image binarization device provided by the embodiment of the application is described below, and the barcode image binarization device described below and the barcode image binarization method described above can be referred to correspondingly.
As shown in fig. 5, an embodiment of the present application provides a barcode image binarization apparatus 500, including:
an image obtaining module 501, configured to obtain a barcode image;
an identification module 502, configured to identify a central point of each unit module in the barcode image, and determine the central point as a sampling point of each unit module;
the scoring module 503 is configured to perform binarization scoring on each sampling point according to at least two preset binarization algorithms, and calculate binarization scoring of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score;
a total score calculating module 504, configured to calculate a total score of binarization for each sampling point according to a binarization score of each sampling point corresponding to each binarization algorithm;
a first determining module 505, configured to determine, when a black score in a binarization total score of a sampling point is greater than a white score, a unit module to which the sampling point belongs as a black module;
a second determining module 506, configured to determine the unit module to which the sample point belongs as a white module when the white score in the total binarized scores of the sample points is greater than the black score.
In one embodiment, the scoring module is configured to perform the steps of:
calculating the gray level difference value of each sampling point and each adjacent sampling point;
calculating the sum of the gray level difference value of each sampling point and each adjacent sampling point;
determining a neighborhood score according to the sum of the gray level difference values;
if the sum of the gray level difference values is less than or equal to zero, the black score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the white score is equal to zero;
and if the sum of the gray level difference values is greater than zero, the white score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the black score is equal to zero.
In one embodiment, the scoring module is further configured to perform the steps of:
calculating a global characteristic value of the bar code image as a global threshold value; the global characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the barcode image;
determining a global score according to the global feature value;
judging whether the gray value of each sampling point is smaller than the global threshold value or not;
if the value is smaller than the global threshold value, the black score and the white score of the sampling point corresponding to the global threshold value algorithm are equal to the global score and zero respectively;
if the value is not smaller than the global threshold, the white score of the sampling point corresponding to the global threshold algorithm is equal to the global score, and the black score is equal to zero.
In one embodiment, the scoring module is further configured to perform the steps of:
equally dividing the bar code image into a plurality of windows;
respectively calculating the local characteristic value of each window as the local threshold value of the window; the local characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the window;
determining a local score according to the local characteristic value of each window;
judging whether the gray value of each sampling point in each window is smaller than the local threshold of the window to which the sampling point belongs;
if the value is smaller than the local threshold value of the window to which the sampling point belongs, the black value of the sampling point corresponding to the local threshold value algorithm is equal to the local value, and the white value is equal to zero;
and if the value is not less than the local threshold value of the window to which the sampling point belongs, the white score of the sampling point corresponding to the local threshold value algorithm is equal to the local score, and the black score is equal to zero.
In one embodiment, the total score calculation module is configured to perform the steps of:
and accumulating the binarization scores of each sampling point corresponding to each binarization algorithm to obtain the binarization total score of each sampling point.
In one embodiment, the total score calculation module is configured to perform the steps of:
according to the preset weight corresponding to each binarization algorithm, multiplying the binarization score of each sampling point corresponding to each binarization algorithm by the preset weight to calculate a weighted score;
and accumulating the weighted scores corresponding to each binarization algorithm to obtain a binarization total score of each sampling point.
The division of each module in the barcode image binarizing apparatus is only for illustration, and in other embodiments, the barcode image binarizing apparatus may be divided into different modules as required to complete all or part of the functions of the barcode image binarizing apparatus. All or part of the modules in the bar code image binarization device can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, the present application further provides a storage medium having stored therein computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of:
acquiring a bar code image;
identifying the central point of each unit module in the bar code image, and respectively determining the central point as a sampling point of each unit module;
performing binarization scoring on each sampling point according to at least two preset binarization algorithms, and calculating the binarization scoring of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score;
calculating a binarization total score of each sampling point according to a binarization score of each sampling point corresponding to each binarization algorithm;
if the black value in the total binary scores of the sampling points is greater than the white value, determining the unit module to which the sampling points belong as a black module;
and if the white value in the binaryzation total score of the sampling point is greater than the black value, determining the unit module to which the sampling point belongs as a white module.
In one embodiment, the computer readable instructions when executed by the processor further implement the steps of:
calculating the gray level difference value of each sampling point and each adjacent sampling point;
calculating the sum of the gray difference value of each sampling point and each adjacent sampling point;
determining a neighborhood score according to the sum of the gray level difference values;
if the sum of the gray level difference values is less than or equal to zero, the black score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the white score is equal to zero;
and if the sum of the gray level difference values is greater than zero, the white score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the black score is equal to zero.
In one embodiment, the computer readable instructions when executed by the processor further implement the steps of:
calculating a global characteristic value of the bar code image as a global threshold value; the global characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the barcode image;
determining a global score according to the global feature value;
judging whether the gray value of each sampling point is smaller than the global threshold value or not;
if the value is smaller than the global threshold value, the black score and the white score of the sampling point corresponding to the global threshold value algorithm are equal to the global score and zero respectively;
if the value is not smaller than the global threshold, the white score of the sampling point corresponding to the global threshold algorithm is equal to the global score, and the black score is equal to zero.
In one embodiment, the computer readable instructions when executed by the processor further implement the steps of:
equally dividing the bar code image into a plurality of windows;
respectively calculating the local characteristic value of each window as the local threshold value of the window; the local characteristic value is a grey value median value, a grey value mean value or a valley value of an image histogram of the window;
determining a local score according to the local characteristic value of each window;
judging whether the gray value of each sampling point in each window is smaller than the local threshold of the window to which the sampling point belongs;
if the value is smaller than the local threshold value of the window to which the sampling point belongs, the black value of the sampling point corresponding to the local threshold value algorithm is equal to the local value, and the white value is equal to zero;
and if the value is not less than the local threshold of the window to which the sampling point belongs, the white value of the sampling point corresponding to the local threshold algorithm is equal to the local value, and the black value is equal to zero.
In one embodiment, the computer readable instructions when executed by the processor further implement the steps of:
and accumulating the binarization scores of each sampling point corresponding to each binarization algorithm to obtain the binarization total score of each sampling point.
In one embodiment, the computer readable instructions when executed by the processor further implement the steps of:
according to the preset weight corresponding to each binarization algorithm, multiplying the binarization score of each sampling point corresponding to each binarization algorithm by the preset weight to calculate a weighted score;
and accumulating the weighted scores corresponding to each binarization algorithm to obtain a binarization total score of each sampling point.
In one embodiment, the present application further provides a computer device having computer-readable instructions stored therein, which when executed by the one or more processors, perform the steps of:
acquiring a bar code image;
identifying the central point of each unit module in the bar code image, and respectively determining the central point as a sampling point of each unit module;
performing binarization scoring on each sampling point according to at least two preset binarization algorithms, and calculating the binarization scoring of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score;
calculating a binarization total score of each sampling point according to a binarization score of each sampling point corresponding to each binarization algorithm;
if the black value in the total binary scores of the sampling points is greater than the white value, determining the unit module to which the sampling points belong as a black module;
and if the white value in the binaryzation total score of the sampling point is greater than the black value, determining the unit module to which the sampling point belongs as a white module.
In one embodiment, the processor when executing the computer readable instructions further performs the steps of:
calculating the gray level difference value of each sampling point and each adjacent sampling point;
calculating the sum of the gray difference value of each sampling point and each adjacent sampling point;
determining a neighborhood score according to the sum of the gray level difference values;
if the sum of the gray level difference values is less than or equal to zero, the black score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the white score is equal to zero;
and if the sum of the gray level difference values is greater than zero, the white score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the black score is equal to zero.
In one embodiment, the processor, when executing the computer readable instructions, further performs the steps of:
calculating a global characteristic value of the bar code image as a global threshold value; the global characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the barcode image;
determining a global score according to the global feature value;
judging whether the gray value of each sampling point is smaller than the global threshold value or not;
if the value is smaller than the global threshold value, the black score and the white score of the sampling point corresponding to the global threshold value algorithm are equal to the global score and zero respectively;
if the value is not smaller than the global threshold, the white score of the sampling point corresponding to the global threshold algorithm is equal to the global score, and the black score is equal to zero.
In one embodiment, the processor when executing the computer readable instructions further performs the steps of:
equally dividing the bar code image into a plurality of windows;
respectively calculating the local characteristic value of each window as the local threshold value of the window; the local characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the window;
determining a local score according to the local characteristic value of each window;
judging whether the gray value of each sampling point in each window is smaller than the local threshold of the window to which the sampling point belongs;
if the value is smaller than the local threshold value of the window to which the sampling point belongs, the black score of the sampling point corresponding to the local threshold value algorithm is equal to the local score, and the white score is equal to zero;
and if the value is not less than the local threshold of the window to which the sampling point belongs, the white value of the sampling point corresponding to the local threshold algorithm is equal to the local value, and the black value is equal to zero.
In one embodiment, the processor, when executing the computer readable instructions, further performs the steps of:
and accumulating the binarization scores of each sampling point corresponding to each binarization algorithm to obtain the binarization total score of each sampling point.
In one embodiment, the processor when executing the computer readable instructions further performs the steps of:
according to the preset weight corresponding to each binarization algorithm, multiplying the binarization score of each sampling point corresponding to each binarization algorithm by the preset weight to calculate a weighted score;
and accumulating the weighted scores corresponding to each binarization algorithm to obtain a binarization total score of each sampling point.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The communication interface of the computer device is used for communicating with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to realize a bar code image binarization method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on a shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 6 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high-density embedded nonvolatile Memory, resistive Random Access Memory (ReRAM), magnetic Random Access Memory (MRAM), ferroelectric Random Access Memory (FRAM), phase Change Memory (PCM), graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing based data processing logic devices, etc., without limitation.
Finally, it should also be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present application, "plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, the embodiments may be combined as needed, and the same and similar parts may be referred to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A bar code image binarization method is characterized by comprising the following steps:
acquiring a bar code image;
identifying the central point of each unit module in the bar code image, and respectively determining the central point as a sampling point of each unit module;
carrying out binarization scoring on each sampling point according to at least two preset binarization algorithms, and calculating the binarization scoring of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score;
calculating a binarization total score of each sampling point according to a binarization score of each sampling point corresponding to each binarization algorithm;
if the black score in the total binaryzation scores of the sampling points is greater than the white score, determining the unit module to which the sampling points belong as a black module;
and if the black score in the total binaryzation scores of the sampling points is not greater than the white score, determining the unit module to which the sampling points belong as a white module.
2. The binarization method for the barcode image according to claim 1, characterized in that the binarization scoring algorithm is a global threshold algorithm, a local threshold algorithm or a neighborhood difference algorithm.
3. The barcode image binarization method according to claim 2, wherein when the binarization algorithm comprises the neighborhood difference algorithm, the performing of the calculating of the binarization score of each sampling point corresponding to each binarization scoring algorithm comprises:
calculating the gray level difference value of each sampling point and each adjacent sampling point;
calculating the sum of the gray difference value of each sampling point and each adjacent sampling point;
determining a neighborhood score according to the sum of the gray difference values;
if the sum of the gray level difference values is less than or equal to zero, the black score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the white score is equal to zero;
and if the sum of the gray level difference values is greater than zero, the white score of the sampling point corresponding to the neighborhood difference value algorithm is equal to the neighborhood score, and the black score is equal to zero.
4. The barcode image binarization method according to claim 2, wherein when the binarization algorithm comprises the global threshold algorithm, the performing of the calculating of the binarization score of each sampling point corresponding to each binarization algorithm comprises:
calculating a global characteristic value of the bar code image as a global threshold value; the global characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the barcode image;
determining a global score according to the global feature value;
judging whether the gray value of each sampling point is smaller than the global threshold value or not;
if the value is smaller than the global threshold value, the black score and the white score of the sampling point corresponding to the global threshold value algorithm are equal to the global score and zero respectively;
if the value is not smaller than the global threshold, the white score of the sampling point corresponding to the global threshold algorithm is equal to the global score, and the black score is equal to zero.
5. The barcode image binarization method according to claim 2, wherein when the binarization algorithm comprises the local threshold algorithm, the performing of the calculating of the binarization score of each sampling point corresponding to each binarization algorithm comprises:
equally dividing the bar code image into a plurality of windows;
respectively calculating the local characteristic value of each window as the local threshold value of the window; the local characteristic value is a gray value median value, a gray value mean value or a valley value of an image histogram of the window;
determining a local score according to the local characteristic value of each window;
judging whether the gray value of each sampling point in each window is smaller than the local threshold of the window to which the sampling point belongs;
if the value is smaller than the local threshold value of the window to which the sampling point belongs, the black score of the sampling point corresponding to the local threshold value algorithm is equal to the local score, and the white score is equal to zero;
and if the value is not less than the local threshold of the window to which the sampling point belongs, the white value of the sampling point corresponding to the local threshold algorithm is equal to the local value, and the black value is equal to zero.
6. The binarization method for the barcode image according to claim 1, characterized in that the calculating of the binarization total score of each sampling point according to the binarization score of each sampling point corresponding to each binarization algorithm comprises the following steps:
and accumulating the binarization scores of each sampling point corresponding to each binarization algorithm to obtain the binarization total score of each sampling point.
7. The binarization method for the barcode image according to claim 1, characterized in that the calculating of the binarization total score of each sampling point according to the binarization score of each sampling point corresponding to each binarization algorithm comprises the following steps:
according to the preset weight corresponding to each binarization algorithm, multiplying the binarization score of each sampling point corresponding to each binarization algorithm by the preset weight to calculate a weighted score;
and accumulating the weighted scores corresponding to each binarization algorithm to obtain a binarization total score of each sampling point.
8. A bar code image binarization device is characterized by comprising:
the image acquisition module is used for acquiring a bar code image;
the identification module is used for identifying the central point of each unit module in the bar code image and respectively determining the central point as a sampling point of each unit module;
the grading module is used for carrying out binarization grading on each sampling point according to at least two preset binarization algorithms and calculating the binarization grade of each sampling point corresponding to each binarization algorithm; wherein the binarization score comprises a black score and a white score;
the total score calculating module is used for calculating the binaryzation total score of each sampling point according to the binaryzation score of each sampling point corresponding to each binaryzation algorithm;
the first determining module is used for determining the unit module to which the sampling point belongs as a black module when the black value in the total binary score of the sampling point is greater than the white value;
and the second determining module is used for determining the unit module to which the sampling point belongs as a white module when the black score in the total binary score of the sampling point is not more than the white score.
9. A storage medium, characterized by: the storage medium has stored therein computer readable instructions which, when executed by one or more processors, cause the one or more processors to perform the steps of the barcode image binarization method according to any one of claims 1 to 7.
10. A computer device, comprising: one or more processors, and a memory;
the memory has stored therein computer readable instructions which, when executed by the one or more processors, perform the steps of the barcode image binarization method according to any one of claims 1 to 7.
CN202211422277.4A 2022-11-14 2022-11-14 Bar code image binarization method and device, storage medium and computer equipment Pending CN115690431A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211422277.4A CN115690431A (en) 2022-11-14 2022-11-14 Bar code image binarization method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211422277.4A CN115690431A (en) 2022-11-14 2022-11-14 Bar code image binarization method and device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN115690431A true CN115690431A (en) 2023-02-03

Family

ID=85051112

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211422277.4A Pending CN115690431A (en) 2022-11-14 2022-11-14 Bar code image binarization method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN115690431A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117635729A (en) * 2023-11-28 2024-03-01 钛玛科(北京)工业科技有限公司 Line camera backlight calibrator and line camera backlight calibration method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117635729A (en) * 2023-11-28 2024-03-01 钛玛科(北京)工业科技有限公司 Line camera backlight calibrator and line camera backlight calibration method
CN117635729B (en) * 2023-11-28 2024-06-11 钛玛科(北京)工业科技有限公司 Line camera backlight calibrator and line camera backlight calibration method

Similar Documents

Publication Publication Date Title
CN110060237B (en) Fault detection method, device, equipment and system
CN110288602A (en) Come down extracting method, landslide extraction system and terminal
CN113159147A (en) Image identification method and device based on neural network and electronic equipment
CN111398176B (en) Water body water color abnormity remote sensing identification method and device based on pixel scale characteristics
CN114897779A (en) Cervical cytology image abnormal area positioning method and device based on fusion attention
US20190378180A1 (en) Method and system for generating and using vehicle pricing models
US20170178341A1 (en) Single Parameter Segmentation of Images
CN115759148B (en) Image processing method, device, computer equipment and computer readable storage medium
CN115908363B (en) Tumor cell statistics method, device, equipment and storage medium
CN112906816A (en) Target detection method and device based on optical differential and two-channel neural network
CN115690431A (en) Bar code image binarization method and device, storage medium and computer equipment
CN110796250A (en) Convolution processing method and system applied to convolutional neural network and related components
CN110866931B (en) Image segmentation model training method and classification-based enhanced image segmentation method
CN114898357A (en) Defect identification method and device, electronic equipment and computer readable storage medium
CN113392455B (en) House pattern scale detection method and device based on deep learning and electronic equipment
CN114187009A (en) Feature interpretation method, device, equipment and medium of transaction risk prediction model
CN114240924A (en) Power grid equipment quality evaluation method based on digitization technology
CN116994721B (en) Quick processing system of digital pathological section graph
Zhang et al. A YOLOv3‐Based Industrial Instrument Classification and Reading Recognition Method
CN116843983A (en) Pavement disease recognition method, model training method, electronic equipment and medium
CN114882020B (en) Product defect detection method, device, equipment and computer readable medium
CN116168377A (en) License plate recognition method, license plate recognition device, computer equipment and storage medium
CN114140336B (en) Infrared image-based dead pixel processing method and device
CN113610098B (en) Tax payment number identification method and device, storage medium and computer equipment
CN115601655A (en) Water body information identification method and device based on satellite remote sensing and readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination