CN107085849B - Image binarization processing method, device, equipment and storage medium - Google Patents

Image binarization processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN107085849B
CN107085849B CN201710350947.9A CN201710350947A CN107085849B CN 107085849 B CN107085849 B CN 107085849B CN 201710350947 A CN201710350947 A CN 201710350947A CN 107085849 B CN107085849 B CN 107085849B
Authority
CN
China
Prior art keywords
image
binarization
value
preset
binarization threshold
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.)
Active
Application number
CN201710350947.9A
Other languages
Chinese (zh)
Other versions
CN107085849A (en
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.)
Shenzhen Yihua Computer Co Ltd
Shenzhen Yihua Time Technology Co Ltd
Shenzhen Yihua Financial Intelligent Research Institute
Original Assignee
Shenzhen Yihua Computer Co Ltd
Shenzhen Yihua Time Technology Co Ltd
Shenzhen Yihua Financial Intelligent Research Institute
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 Shenzhen Yihua Computer Co Ltd, Shenzhen Yihua Time Technology Co Ltd, Shenzhen Yihua Financial Intelligent Research Institute filed Critical Shenzhen Yihua Computer Co Ltd
Priority to CN201710350947.9A priority Critical patent/CN107085849B/en
Publication of CN107085849A publication Critical patent/CN107085849A/en
Application granted granted Critical
Publication of CN107085849B publication Critical patent/CN107085849B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/267Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds

Abstract

The invention discloses an image binarization processing method, a device, equipment and a storage medium, wherein the method comprises the following steps: selecting at least two binarization threshold values from a preset binarization threshold value range to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image; summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image; judging whether the characteristic value is larger than a preset black point number threshold value or not, if so, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image; and taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value. The accuracy of the calculation of the binarization threshold value is improved, and the binarization processing effect is enhanced.

Description

Image binarization processing method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to an image processing technology, in particular to an image binarization processing method, device, equipment and storage medium.
Background
Image binarization is an important step of optical character recognition, generally, the effect of a binarized image plays an important role in other processing of the image, and when the quality of the binarized image is not high, the accuracy of image processing is affected, wherein the processing of the image comprises character recognition, character cutting and characters. In the binarization process, it is critical to determine a binarization threshold.
The methods for determining the binary threshold value generally include percentage method and OTSU (maximum between-class variance) method. However, the binarization threshold determined by the two methods is inaccurate, so that the binarization processing effect is poor.
Disclosure of Invention
The embodiment of the invention provides an image binarization processing method, device, equipment and storage medium, which improve the accuracy of binarization threshold calculation and enhance the binarization processing effect.
In a first aspect, an embodiment of the present invention provides an image binarization processing method, where the method includes:
selecting at least two binarization threshold values from a preset binarization threshold value range to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image;
summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image;
judging whether the characteristic value is larger than a preset black point number threshold value or not, if so, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image;
and taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value.
Further, at least two binarization threshold values are selected from the range of the preset binarization threshold value to carry out binarization processing on the image to be detected respectively, and corresponding binarization images are generated, wherein the binarization processing method comprises the following steps:
obtaining a plurality of binarization threshold values from a first end value of a preset binarization threshold range to a second end value of the preset binarization threshold range according to a preset step length;
and selecting at least two binarization threshold values from the plurality of binarization threshold values to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image.
Further, summing the number of black points of any continuous preset number of lines in each binarized image, and taking the maximum value obtained by summing each binarized image as the characteristic value of the binarized image comprises:
calculating the number of black points of each line in each binary image;
summing the number of black points of any continuous preset line number in each binary image to obtain a plurality of summation results;
and selecting the maximum value in the plurality of summation results as the characteristic value of the binarization image corresponding to the maximum value.
Further, the preset black point threshold value is determined according to the number of pixel points of the sample image and/or the number of black points of the sample image, wherein the black points of the sample image are points of which the gray value is smaller than the sample image binarization threshold value.
In a second aspect, an embodiment of the present invention provides an image binarization processing apparatus, the apparatus including:
the processing module is used for selecting at least two binarization threshold values from a preset binarization threshold value range to carry out binarization processing on the images to be detected respectively so as to generate corresponding binarization images;
the characteristic value calculation module is used for summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image;
the judging module is used for judging whether the characteristic value is larger than a preset black point number threshold value or not, and if so, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image;
and the target binarization threshold value determining module is used for taking the binarization threshold value corresponding to the binarization image with the maximum ratio as the target binarization threshold value.
Further, the processing module is specifically configured to:
obtaining a plurality of binarization threshold values from a first end value of a preset binarization threshold range to a second end value of the preset binarization threshold range according to a preset step length;
and selecting at least two binarization threshold values from the plurality of binarization threshold values to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image.
Further, the feature value calculation module is specifically configured to:
calculating the number of black points of each line in each binary image;
summing the number of black points of any continuous preset line number in each binary image to obtain a plurality of summation results;
and selecting the maximum value in the plurality of summation results as the characteristic value of the binarization image corresponding to the maximum value.
Further, the preset black point threshold value is determined according to the number of pixel points of the sample image and/or the number of black points of the sample image, wherein the black points of the sample image are points of which the gray value is smaller than the sample image binarization threshold value.
In a third aspect, an embodiment of the present invention provides a computer device, including:
one or more processors;
a memory for storing one or more programs;
the one or more programs are executed by the one or more processors, so that the one or more processors implement the image binarization processing method according to any one of the embodiments of the present invention.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements an image binarization processing method according to any one of the embodiments of the present invention.
In the embodiment of the invention, at least two binarization threshold values are selected from a preset binarization threshold value range to carry out binarization processing on an image to be detected respectively to generate corresponding binarization images, then the characteristic value of each binarization image is calculated according to the summation of the number of black points of continuous preset line number in each binarization image, when the characteristic value is greater than the preset black point number threshold value, the ratio of the characteristic value to the total number of the black points in the corresponding binarization image is calculated, and the binarization threshold value corresponding to the binarization image with the largest ratio is used as a target binarization threshold value. The accuracy of the calculation of the binarization threshold value is improved, and the binarization processing effect is enhanced.
Drawings
FIG. 1a is a flowchart of a method for image binarization processing according to a first embodiment of the present invention;
FIG. 1b is a binarized image of a banknote serial number region, which is applicable to the first embodiment of the present invention;
FIG. 1c is a binarized image of a banknote crown word number region, which is applicable to the first embodiment of the present invention;
FIG. 1d is a binarized image of a banknote crown word number region, which is applicable to the first embodiment of the present invention;
FIG. 1e is a binarized image of a banknote serial number region, which is applicable to the first embodiment of the present invention;
FIG. 2 is a flowchart of a method for binarizing an image according to a second embodiment of the present invention;
FIG. 3 is a flowchart of a method for binarizing an image according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an image binarization processing device in a fourth embodiment of the invention;
fig. 5 is a schematic structural diagram of a computer device in the fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1a is a flowchart of an image binarization processing method according to an embodiment of the present invention, which is applicable to a case of performing binarization processing on an image, and the method can be executed by a binarization processing apparatus according to an embodiment of the present invention, and the apparatus can be implemented by software and/or hardware. As shown in fig. 1a, the method may specifically include the following steps:
and S110, selecting at least two binarization threshold values from the range of the preset binarization threshold values to carry out binarization processing on the images to be detected respectively, and generating corresponding binarization images.
Specifically, in the process of image binarization processing, a color image needs to be converted into a gray image, and then an appropriate binarization threshold value is selected to process the gray image to obtain a binarized image. The determination of the binarization threshold value directly influences the processing effect of binarization. The preset binarization threshold range can be given with the minimum value and the maximum value of the binarization threshold value meeting the preset condition, and the binarization threshold value between the minimum value and the maximum value forms the preset binarization threshold range.
In a specific example, the image to be measured takes a region including a banknote serial number as an example, and the region of the image to be measured is referred to as a feature region. According to the resolution of the image to be detected in the process of obtaining, dividing the characteristic region according to 60 x 120, namely dividing the characteristic region into 60 pixel points in the row direction and 120 pixel points in the column direction. Optionally, the height of the crown word size is 30, it should be noted that the crown word size is a specific attribute of the paper money, the height of the crown word size is fixed and unchanged, and the crown word size is represented by a pixel point and does not represent an actual height value of the crown word size. Counting the number of pixel points of each gray value in the image to be detected, and recording the number of the pixel points with the gray value of 0 as N0The number of the pixel points with the gray value of 1 is recorded as N1The number of the pixel points with the gray value of 2 is recorded as N2… … the number of pixel points with N gray value is recorded as NnWherein n is a positive integer, n is more than or equal to 0 and less than or equal to 255, and the number of black dots of the crown word number of the characteristic region is set by a developer according to experience and is generally between 1100 and 1300. Exemplary, statistics N0+N1+…+N20Is marked as A, and N is counted0+N1+…+N19Is marked as A1Counting N0+N1+…+N30Is marked as B, and N is counted0+N1+…+N29Is marked as B1If A is greater than 1100 and A1If the sum of the number of the pixel points with the gray value less than or equal to 20 is less than 1100 (namely the sum of the number of the pixel points with the gray value less than or equal to 20 is greater than 1100, and the sum of the number of the pixel points with the gray value less than or equal to 19 is less than 1100), the 20 is used as the preset twoThe smallest binary threshold value in the range of the valued threshold values, if B is larger than 3000 and B is1And if the sum of the number of the pixel points with the gray value less than or equal to 3000 (namely the sum of the number of the pixel points with the gray value less than or equal to 30 is greater than 3000, and the sum of the number of the pixel points with the gray value less than or equal to 29 is less than 3000), taking 30 as the largest binarization threshold value in the preset binarization threshold value range, wherein the range of the determined binarization threshold value is 20-30.
After the preset binarization threshold range is determined, at least two binarization threshold values are selected from the preset binarization threshold range to carry out binarization processing on the image to be detected, the point gray value smaller than the binarization threshold value is represented by 0 and is recorded as a black point, and the point gray value larger than the binarization threshold value is represented by 255 and is recorded as a white point. For example, fig. 1b, fig. 1c, fig. 1d, and fig. 1e respectively show binarized images obtained by binarizing a banknote crown size region with four different binarization threshold values, it should be noted that the four binarized images are only used schematically, different binarized images can be obtained by processing the same image with different binarization threshold values only for the purpose of explaining that the definition of the binarized image is related to the selected binarization threshold value, and different binarized images with different effects can be obtained by selecting different binarization threshold values. In the binarized images shown in fig. 1b and fig. 1e, in addition to the black dots of the crown-word-number characters, the image background includes other black dots, which may be a background pattern existing in the image to be measured, and the black dots obtained after the background pattern binarization processing are referred to as noise. As can be seen from fig. 1b and 1e, the processing result of the binarization threshold applied in the process of obtaining the binarization images like fig. 1b and 1e generates much noise. In the binarized image shown in fig. 1c, it can be seen that the crown word number cannot be clearly displayed, resulting in a situation of binary blur. In the binarized image shown in fig. 1d, it can be seen that the crown symbols are clearly displayed and have no noise. As can be seen from fig. 1b, fig. 1c, fig. 1d and fig. 1e, the binary threshold obtained by applying the calculation method provided by the embodiment of the present invention is used to process the image to be detected, and the effect of the obtained binary image of fig. 1d is less in noise and avoids binary blur compared with other three binary images.
And S120, summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image.
The number of any continuous preset lines can be set according to the specific characteristics of the image to be detected, and illustratively, if the image to be detected is a banknote serial number region, the continuous preset lines can be longitudinal regions which just contain serial number characters. And summing the number of black points of any continuous preset line number in each binary image, and taking the maximum value of the summation result of each binary image as the characteristic value of the binary image.
In a specific example, taking the image to be measured as the banknote crown number area as an example, the binary image is divided into 60 × 120 pixel points according to the setting of the resolution, that is, the binary image is divided into 60 pixel points in the row direction and 120 pixel points in the column direction. The height of the capital character is 30, the height 30 of the capital character can be taken as the continuous preset line number, for example, the sum of the numbers of the black dots of the lines 1 to 30, 2 to 31, 3 to 32, … …, 31 to 60 is calculated respectively, and the maximum value of the numbers of the black dots obtained in the respective summation results is taken as the characteristic value of the binary image. For example, if the sum of the black dot numbers of the lines 16 to 45 is 1200 at maximum, 1200 is taken as the feature value of the binarized image.
And S130, judging whether the characteristic value is larger than a preset black point threshold value, if so, executing S140, otherwise, continuing to execute S130.
Correspondingly, whether the characteristic value is larger than a preset black point threshold value or not is judged, wherein the preset black point threshold value can be set by a tester according to the specific characteristics of the image to be tested. In a specific example, if the image to be measured is a crown word number at the lower left corner of the front face of 2015-edition 100-yuan paper currency, and the number of black dots of the crown word number characters in the binarized image obtained after binarization processing is performed through a proper binarized threshold value is usually between 1100 and 1300, a preset black dot number threshold value is selected between 1100 and 1300.
Optionally, the preset black point number threshold is determined according to the number of pixel points of the sample image and/or the number of black points of the sample image, where the black points of the sample image are points whose gray values are smaller than the sample image binarization threshold.
The black point threshold value can be determined according to the number of pixel points of the sample image and/or the number of black points of the sample image.
In a specific example, to ensure the accuracy of the calculation result, the selected sample and the image to be measured belong to the same nature of images, for example, if the image to be measured is the area of the crown word number at the lower left corner of the front of 2015 version of 100 yuan banknote, the selected sample image should also be the crown word number at the lower left corner of the front of 2015 version of 100 yuan banknote, so that the selection can exclude the interference of, for example, background patterns or background colors. The number of sample images selected may be multiple, for example 1000. Counting the number of pixel points of the sample image, taking the minimum value of the number of all sample pixel points, then taking 20% of the minimum value as a black point threshold value, taking the minimum value of the number of the sample image pixel points as 7200 as an example, then selecting 20% of 7200, namely 1440 as the black point threshold value; counting the number of black points of the sample image, wherein points with the gray value smaller than the sample image binarization threshold value are marked as black points, the binarization threshold value of the sample image is set according to the characteristics of the sample image, the sum of the black points in all the sample images is divided by the sample number to obtain an average value, then 90% of the average value is taken as the black point threshold value, and if the average value is 1300, 90% of 1300%, namely 1170 is taken as the black point threshold value.
And S140, calculating the ratio of the characteristic value to the total number of the black points in the corresponding binary image.
And when the characteristic value is larger than a preset black point number threshold value, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image.
In a specific example, when the feature value is 1200 and the preset black dot count threshold value is 1170, the condition that the feature value is greater than the preset black dot count threshold value is satisfied. Taking the example of dividing the binarized image into 60 × 120 pixel points, the feature value is the maximum value of the sum of the number of black points of any continuous preset line number, at this time, the total number of the black points refers to the total number of the black points of 60 lines, and the ratio of the feature value to the total number of the black points in the corresponding binarized image is calculated. Illustratively, if the total number of black dots is 1320, the ratio is 90.9%.
It should be noted that each binarized image corresponds to such a ratio, which is obtained by calculating the ratio of the feature value to the total number of black dots in the corresponding binarized image.
And S150, taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value.
The method comprises the steps of selecting at least two binarization threshold values to process an image to be detected, and obtaining at least two binarization images, wherein the ratio of the obtained characteristic values to the total number of black points in the corresponding binarization images is at least two. And selecting the binarization threshold corresponding to the binarization image with the largest ratio as a target binarization threshold. In a specific example, if the selected binarization threshold 25 is the largest corresponding ratio in the binarization image after the binarization processing is performed on the image to be detected, the binarization threshold 25 is taken as the target binarization threshold.
In the embodiment of the invention, at least two binarization threshold values are selected from a preset binarization threshold value range to carry out binarization processing on an image to be detected respectively to generate corresponding binarization images, then the characteristic value of each binarization image is calculated according to the summation of the number of black points of continuous preset line number in each binarization image, when the characteristic value is greater than the preset black point number threshold value, the ratio of the characteristic value to the total number of the black points in the corresponding binarization image is calculated, and the binarization threshold value corresponding to the binarization image with the largest ratio is used as a target binarization threshold value. The accuracy of the calculation of the binarization threshold value is improved, and the binarization processing effect is enhanced.
Example two
Fig. 2 is a flowchart of an image binarization processing method according to a second embodiment of the present invention, and in this embodiment, optimization is performed on "selecting at least two binarization threshold values from a preset binarization threshold value range for performing binarization processing on an image to be detected, and generating a corresponding binarization image" in the second embodiment of the present invention. As shown in fig. 2, the method may specifically include the following steps:
s210, starting from a first end value of a preset binarization threshold range, and taking values according to a preset step length until a second end value of the preset binarization threshold range to obtain a plurality of binarization threshold values.
Specifically, the preset binarization threshold range may be an interval, and starting from a first end of the preset binarization threshold range, the first end may take an interval lower limit, and take a value according to a preset step length, where the preset step length may take a value according to a specific situation, and is not specifically limited herein. And taking the value according to the preset step length until the second end value of the preset binarization threshold range, wherein the second end value can be an interval upper limit.
In a specific example, if the preset binarization threshold range is 20 to 30 and the preset step length is 2, the preset binarization threshold is 20, 22, 24, 26, 28 and 30.
S220, selecting at least two binarization threshold values from the plurality of binarization threshold values to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image.
Specifically, at least two binarization threshold values are selected from a plurality of binarization threshold values determined according to a preset step length to carry out binarization processing on the image to be detected respectively, so as to generate a corresponding binarization image.
In a specific example, at least two binarization threshold values are selected from the plurality of binarization threshold values, and 22, 26 and 30 may be selected to perform binarization processing on the image to be measured, so as to generate three binarization images, which correspond to the preset binarization threshold values 22, 26 and 30, respectively.
And S230, summing the number of black points in any continuous preset line number in each binarized image, and taking the maximum value obtained by summing each binarized image as the characteristic value of the binarized image.
And S240, judging whether the characteristic value is larger than a preset black point threshold value, if so, executing S250, otherwise, continuing to execute S240.
And S250, calculating the ratio of the characteristic value to the total number of the black points in the corresponding binary image.
And S260, taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value.
In the embodiment of the invention, a plurality of binarization threshold values are obtained by starting from a first end value of a preset binarization threshold value range and taking values according to a preset step length to a second end value of the preset binarization threshold value range, and then at least two binarization threshold values are selected from the binarization threshold values to carry out binarization processing on an image to be detected respectively so as to generate a corresponding binarization image. A plurality of binarization threshold values are obtained through a preset step length, a plurality of binarization images are obtained by applying the plurality of binarization threshold values, and the accuracy of determining the binarization threshold values is improved.
EXAMPLE III
Fig. 3 is a flowchart of an image binarization processing method according to a third embodiment of the present invention, and in this embodiment, based on the foregoing embodiment, "sum the number of black points in each binarized image at any number of consecutive preset rows, and use the maximum value obtained by summing each binarized image as the feature value of the binarized image" is optimized. As shown in fig. 3, the method may specifically include the following steps:
s310, selecting at least two binarization threshold values from the range of the preset binarization threshold values to carry out binarization processing on the images to be detected respectively, and generating corresponding binarization images.
And S320, calculating the number of black points in each row in each binary image.
Specifically, when the number of black dots of any continuous preset line number in each binarized image is summed, the number of black dots of each line in each binarized image can be calculated in units of lines.
S330, summing the number of black points in any continuous preset line number in each binary image to obtain a plurality of summation results.
After the number of black points of each line in each binary image is calculated, summing the number of black points of any continuous preset line number in each binary image to obtain a plurality of summation results. It should be noted that, when the sum of the number of black dots of any continuous preset line number is calculated, the sum of the number of black dots of any continuous preset line number may be directly calculated without calculating the number of black dots of each line in each binarized image; the sum of the number of the black points of a certain row can be calculated and then stored, and the sum is directly applied when the sum of the number of the black points is needed, so that the repeated calculation of the number of the black points of the certain row which is already calculated is avoided, and the calculation amount is saved.
In a specific example, when the sum of the numbers of black dots in rows 1 to 30 is calculated, the number of black dots in each row of rows 1 to 30 (30 rows in total) may be calculated, and the sum of the numbers of black dots in rows 1 to 30 may be calculated from the number of black dots in each row of the 30 rows. When calculating the sum of the numbers of black dots in the rows 2 to 31, the number of black dots in the row 31 may be calculated, and the number of black dots in each row 2 to 30 (29 rows in total) may be calculated and applied as it is.
S340, selecting the maximum value in the summation results as the characteristic value of the binarization image corresponding to the maximum value.
Specifically, the maximum value is selected from the plurality of summation results and is used as the characteristic value of the binarized image corresponding to the maximum value.
And S350, judging whether the characteristic value is larger than a preset black point threshold value or not, if so, executing S360, otherwise, continuing to execute S350.
And S360, calculating the ratio of the characteristic value to the total number of the black points in the corresponding binary image.
And S370, taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value.
In the embodiment of the invention, the number of black points in each row in each binary image is calculated, the number of black points in any continuous preset row number in each binary image is summed, and the maximum value in the summation result is selected as the characteristic value of the binary image corresponding to the maximum value. And the determination of the characteristic value corresponding to the binary image is realized.
Example four
Fig. 4 is a schematic structural diagram of an image binarization processing device provided by a fourth embodiment of the present invention, which is suitable for executing an image binarization processing method provided by the fourth embodiment of the present invention. As shown in fig. 4, the apparatus may specifically include:
the processing module 410 is configured to select at least two binarization threshold values from a preset binarization threshold range to perform binarization processing on the image to be detected, and generate a corresponding binarization image;
the feature value calculation module 420 is configured to sum the number of black points in any continuous preset number of lines in each binarized image, and use a maximum value obtained by summing each binarized image as a feature value of the binarized image;
a judging module 430, configured to judge whether the feature value is greater than a preset threshold of the number of black dots, and if so, calculate a ratio between the feature value and the total number of black dots in the corresponding binarized image;
and a target binarization threshold determining module 440, configured to use the binarization threshold corresponding to the binarization image with the largest ratio as the target binarization threshold.
Further, the processing module 410 is specifically configured to:
obtaining a plurality of binarization threshold values from a first end value of a preset binarization threshold range to a second end value of the preset binarization threshold range according to a preset step length;
and selecting at least two binarization threshold values from the plurality of binarization threshold values to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image.
Further, the feature value calculation module 420 is specifically configured to:
calculating the number of black points of each line in each binary image;
summing the number of black points of any continuous preset line number in each binary image to obtain a plurality of summation results;
and selecting the maximum value in the plurality of summation results as the characteristic value of the binarization image corresponding to the maximum value.
Further, the preset black point threshold value is determined according to the number of pixel points of the sample image and/or the number of black points of the sample image, wherein the black points of the sample image are points of which the gray value is smaller than the sample image binarization threshold value.
The image binarization processing device provided by the embodiment of the invention can execute the image binarization processing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention. The computer device 12 shown in FIG. 5 is only an example and should not bring any limitations to the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 5, computer device 12 is in the form of a general purpose computing device. The components of computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, and commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with computer device 12, and/or with any devices (e.g., network card, modem, etc.) that enable computer device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, computer device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with the other modules of computer device 12 via bus 18. It should be appreciated that although not shown in FIG. 5, other hardware and/or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 16 executes various functional applications and data processing by running a program stored in the system memory 28, for example, implementing an image binarization processing method provided by an embodiment of the present invention.
That is, the processing unit implements, when executing the program: selecting at least two binarization threshold values from a preset binarization threshold value range to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image; summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image; judging whether the characteristic value is larger than a preset black point number threshold value or not, if so, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image; and taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value.
EXAMPLE six
A sixth embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the image binarization processing method according to all the embodiments of the present application:
that is, the program when executed by the processor implements: selecting at least two binarization threshold values from a preset binarization threshold value range to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image; summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image; judging whether the characteristic value is larger than a preset black point number threshold value or not, if so, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image; and taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-to-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (8)

1. An image binarization processing method is characterized by comprising the following steps:
selecting at least two binarization threshold values from a preset binarization threshold value range to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image;
summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image;
judging whether the characteristic value is larger than a preset black point number threshold value or not, if so, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image;
taking the binarization threshold value corresponding to the binarization image with the maximum ratio as a target binarization threshold value;
determining the preset black point threshold according to the number of pixel points of the sample image and/or the number of black points of the sample image, wherein the black points of the sample image are points of which the gray value is smaller than the sample image binarization threshold;
the determining the black point threshold according to the number of the pixel points of the sample image comprises:
and selecting the minimum value of the number of the pixel points of the sample image, and taking the product of the minimum value and a preset proportion as the preset black point threshold value.
2. The method of claim 1, wherein selecting at least two binarization threshold values from a preset binarization threshold range to perform binarization processing on the image to be detected respectively to generate corresponding binarization images comprises:
obtaining a plurality of binarization threshold values from a first end value of a preset binarization threshold range to a second end value of the preset binarization threshold range according to a preset step length;
and selecting at least two binarization threshold values from the plurality of binarization threshold values to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image.
3. The method according to claim 1, wherein the step of summing the number of black dots in each binarized image for any number of consecutive preset rows, and the step of taking the maximum value obtained by summing each binarized image as the feature value of the binarized image comprises the steps of:
calculating the number of black points of each line in each binary image;
summing the number of black points of any continuous preset line number in each binary image to obtain a plurality of summation results;
and selecting the maximum value in the plurality of summation results as the characteristic value of the binarization image corresponding to the maximum value.
4. An image binarization processing device characterized by comprising:
the processing module is used for selecting at least two binarization threshold values from a preset binarization threshold value range to carry out binarization processing on the images to be detected respectively so as to generate corresponding binarization images;
the characteristic value calculation module is used for summing the number of black points in any continuous preset line number in each binary image, and taking the maximum value obtained by summing each binary image as the characteristic value of the binary image;
the judging module is used for judging whether the characteristic value is larger than a preset black point number threshold value or not, and if so, calculating the ratio of the characteristic value to the total number of black points in the corresponding binary image;
a target binarization threshold value determining module, configured to use a binarization threshold value corresponding to the binarization image with the largest ratio as a target binarization threshold value;
determining the preset black point threshold according to the number of pixel points of the sample image and/or the number of black points of the sample image, wherein the black points of the sample image are points of which the gray value is smaller than the sample image binarization threshold;
the determining the black point threshold according to the number of the pixel points of the sample image comprises:
and selecting the minimum value of the number of the pixel points of the sample image, and taking the product of the minimum value and a preset proportion as the preset black point threshold value.
5. The apparatus of claim 4, wherein the processing module is specifically configured to:
obtaining a plurality of binarization threshold values from a first end value of a preset binarization threshold range to a second end value of the preset binarization threshold range according to a preset step length;
and selecting at least two binarization threshold values from the plurality of binarization threshold values to carry out binarization processing on the image to be detected respectively, and generating a corresponding binarization image.
6. The apparatus of claim 4, wherein the eigenvalue calculation module is specifically configured to:
calculating the number of black points of each line in each binary image;
summing the number of black points of any continuous preset line number in each binary image to obtain a plurality of summation results;
and selecting the maximum value in the plurality of summation results as the characteristic value of the binarization image corresponding to the maximum value.
7. A computer device, comprising:
one or more processors;
a memory for storing one or more programs;
the one or more programs are executable by the one or more processors to cause the one or more processors to implement the method of any one of claims 1-4.
8. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-4.
CN201710350947.9A 2017-05-17 2017-05-17 Image binarization processing method, device, equipment and storage medium Active CN107085849B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710350947.9A CN107085849B (en) 2017-05-17 2017-05-17 Image binarization processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710350947.9A CN107085849B (en) 2017-05-17 2017-05-17 Image binarization processing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN107085849A CN107085849A (en) 2017-08-22
CN107085849B true CN107085849B (en) 2020-05-01

Family

ID=59608121

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710350947.9A Active CN107085849B (en) 2017-05-17 2017-05-17 Image binarization processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN107085849B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113724180A (en) * 2020-05-20 2021-11-30 上海微创卜算子医疗科技有限公司 Method and apparatus for calculating porosity, and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106022346A (en) * 2016-05-24 2016-10-12 深圳怡化电脑股份有限公司 Banknote number cutting method and device
CN106203251A (en) * 2015-05-29 2016-12-07 柯尼卡美能达美国研究所有限公司 File and picture binary coding method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8358852B2 (en) * 2008-03-31 2013-01-22 Lexmark International, Inc. Automatic forms identification systems and methods

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106203251A (en) * 2015-05-29 2016-12-07 柯尼卡美能达美国研究所有限公司 File and picture binary coding method
CN106022346A (en) * 2016-05-24 2016-10-12 深圳怡化电脑股份有限公司 Banknote number cutting method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"低质量印刷体字符分割与识别研究";孙强;《中国优秀硕士学位论文全文数据库 信息科技辑》;20140715(第07期);论文第2.1.1.1-2.1.1.2,3.4.2节 *

Also Published As

Publication number Publication date
CN107085849A (en) 2017-08-22

Similar Documents

Publication Publication Date Title
US10769487B2 (en) Method and device for extracting information from pie chart
CN112966742A (en) Model training method, target detection method and device and electronic equipment
US20210201064A1 (en) Method, device, and computer readable storage medium for recognizing mixed typeset texts
CN110363195A (en) Graphical verification code recognition methods, device, readable storage medium storing program for executing and terminal device
CN111724396B (en) Image segmentation method and device, computer readable storage medium and electronic equipment
CN109389110B (en) Region determination method and device
CN108734161B (en) Method, device and equipment for identifying prefix number area and storage medium
CN113344826A (en) Image processing method, image processing device, electronic equipment and storage medium
CN107085849B (en) Image binarization processing method, device, equipment and storage medium
CN113643260A (en) Method, apparatus, device, medium and product for detecting image quality
CN112712181A (en) Model construction optimization method, device, equipment and readable storage medium
US9672299B2 (en) Visualization credibility score
CN116468479A (en) Method for determining page quality evaluation dimension, and page quality evaluation method and device
US20200175690A1 (en) Font family and size aware character segmentation
CN112967191B (en) Image processing method, device, electronic equipment and storage medium
CN113315995B (en) Method and device for improving video quality, readable storage medium and electronic equipment
CN112333155B (en) Abnormal flow detection method and system, electronic equipment and storage medium
CN112559340A (en) Picture testing method, device, equipment and storage medium
CN113516738A (en) Animation processing method and device, storage medium and electronic equipment
CN113780265B (en) Space recognition method and device for English words, storage medium and computer equipment
CN111429399A (en) Straight line detection method and device
US8792714B2 (en) Detecting anti-aliased text in digital images
CN113068043B (en) PNG image compression method and device, electronic equipment and storage medium
CN109376739B (en) Marshalling mode determining method and device
JP2012022359A (en) Image processing device and image processing program

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
GR01 Patent grant
GR01 Patent grant