CN115909353A - Image binarization processing method and device - Google Patents

Image binarization processing method and device Download PDF

Info

Publication number
CN115909353A
CN115909353A CN202211562829.1A CN202211562829A CN115909353A CN 115909353 A CN115909353 A CN 115909353A CN 202211562829 A CN202211562829 A CN 202211562829A CN 115909353 A CN115909353 A CN 115909353A
Authority
CN
China
Prior art keywords
image
gray
initial
binarization
target
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
CN202211562829.1A
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202211562829.1A priority Critical patent/CN115909353A/en
Publication of CN115909353A publication Critical patent/CN115909353A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Character Input (AREA)

Abstract

The embodiment of the invention provides an image binarization processing method and device, which can be used in the technical field of artificial intelligence, and the method comprises the following steps: acquiring an original image; carrying out image preprocessing on an original image to obtain a target gray-scale image and an initial binarization threshold value; performing self-adaptive binarization on the target gray level image through a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value; the method comprises the steps of conducting binarization processing on a target gray level image according to a target binarization threshold value to obtain a target binarization image, conducting image preprocessing and image binarization on the image in advance, determining the optimal target binarization threshold value through an improved maximum inter-class variance method, and being compatible with a special scene image, so that the accuracy of character segmentation on the image subsequently is improved.

Description

Image binarization processing method and device
Technical Field
The invention relates to the technical field of image processing, in particular to the technical field of artificial intelligence, and particularly relates to a method and a device for image binarization processing.
Background
In recent years, the development and popularization of smart devices and optical character recognition software have made character recognition a hot issue in the field of image recognition. In the related art, the method has high recognition and segmentation accuracy mainly for images with single background, character rule, no noise or less interference, and cannot be compatible with special scenes, but in actual production, most images cannot meet the recognition and segmentation standards, so that the accuracy of subsequent character recognition and character segmentation is low.
Disclosure of Invention
The invention aims to provide an image binarization processing method, which can perform image preprocessing and image binarization on an image in advance, determine an optimal target binarization threshold value through an improved maximum inter-class variance method, and can be compatible with a special scene image, thereby improving the accuracy of subsequent character segmentation on the image. Another object of the present invention is to provide an image binarization processing device. It is a further object of this invention to provide such a computer readable medium. It is a further object of this invention to provide a computer apparatus.
In order to achieve the above object, an aspect of the present invention discloses an image binarization processing method, including:
acquiring an original image;
carrying out image preprocessing on an original image to obtain a target gray-scale image and an initial binarization threshold value;
performing self-adaptive binarization on the target gray level image through a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value;
and carrying out binarization processing on the target gray level image according to the target binarization threshold value to obtain a target binarization image.
Preferably, the image preprocessing is performed on the original image to obtain the target gray-scale image and the initial binarization threshold, and the method includes:
carrying out gray level pretreatment on an original image to obtain an initial gray level image and an initial binarization threshold value;
and performing blank removal and frame preprocessing on the initial gray-scale image to obtain a target gray-scale image.
Preferably, the gray level preprocessing is performed on the original image to obtain an initial gray level image and an initial binarization threshold, and the method includes:
carrying out gray level conversion on the original image to obtain an initial gray level image, wherein the initial gray level image comprises a plurality of pixel points and a gray level value corresponding to each pixel point;
and obtaining an initial binarization threshold value according to the plurality of pixel points and the gray value corresponding to each pixel point.
Preferably, obtaining an initial binarization threshold according to the plurality of pixel points and the gray value corresponding to each pixel point includes:
according to the set gray value interval, counting the gray value corresponding to each pixel point through a histogram to obtain a pixel point array, wherein the pixel point array comprises a plurality of gray value intervals and the number of pixel points corresponding to each gray value interval;
turning and judging the initial gray level image according to the pixel point array;
and according to the turning judgment result, calculating the total number of the pixel points, a plurality of gray value intervals and the number of the pixel points corresponding to each gray value interval to obtain an initial binarization threshold.
Preferably, according to the turning judgment result, the total number of the pixel points, the gray value intervals and the number of the pixel points corresponding to each gray value interval are calculated to obtain an initial binary threshold, including:
if the turnover is determined, carrying out turnover processing on each pixel point in the initial gray map according to the designated gray digit to obtain a turned initial gray map, wherein the turned initial gray map comprises a gray value corresponding to each pixel point;
counting the gray value corresponding to each pixel after turning through the histogram according to the gray value interval to obtain a pixel array after turning, wherein the pixel array after turning comprises a plurality of gray value intervals and the number of pixels after turning corresponding to each gray value interval;
obtaining initial binaryzation according to the total number of the pixel points, a plurality of gray value intervals and the number of the turned pixel points corresponding to each gray value interval;
and if the pixel points are determined not to be turned over, obtaining initial binaryzation according to the total number of the pixel points, a plurality of gray value intervals and the number of the pixel points corresponding to each gray value interval.
Preferably, the initial gray-scale map comprises a plurality of pixel points and a gray-scale value corresponding to each pixel point;
blank removal and frame preprocessing are carried out on the initial gray level image to obtain a target gray level image, and the method comprises the following steps:
and performing blank removal and frame preprocessing on the initial gray-scale image according to the pixel point array and the initial binarization threshold value to obtain a target gray-scale image.
Preferably, according to the pixel point array and the initial binarization threshold, blank removal and frame preprocessing are performed on the initial gray-scale image to obtain a target gray-scale image, and the method comprises the following steps:
carrying out binarization processing on the initial gray level image through an initial binarization threshold value to obtain an initial binarization image;
traversing from two ends of the initial binary image according to pixel rows until pixel coordinates of black pixel points at the edge are obtained;
according to the pixel coordinates of the black pixel points positioned at the edge, blank removing processing is carried out on the initial gray level image to obtain the blank-removed initial gray level image;
updating the initial binarization threshold value according to the set intermediate parameter to obtain an intermediate threshold value;
carrying out binarization processing on the blank-removed initial gray level image through an intermediate threshold value to obtain an enhanced binarization image;
traversing from a central pixel point of the enhanced binary image, acquiring row coordinates of all pixel points of a row where the black pixel points are located and being the black pixel points, and/or acquiring column coordinates of all pixel points of a column where the black pixel points are located and being the black pixel points;
and performing frame removing treatment on the blank-removed initial gray-scale image according to the row coordinates and/or the column coordinates to obtain a target gray-scale image.
Preferably, the obtaining the target binarization threshold value by performing adaptive binarization on the target gray level map through a maximum inter-class variance method and an initial binarization threshold value includes:
acquiring a segmentation threshold according to a preset threshold range;
dividing the target gray image into a foreground image and a background image according to a segmentation threshold;
counting the average gray level of the foreground image through the pixel point array;
constructing a constraint condition according to the initial binarization threshold and the average gray level of the foreground image;
and performing maximum variance calculation on the foreground image and the background image through a maximum inter-class variance method and constraint conditions to determine a target binarization threshold corresponding to the maximum variance.
Preferably, the maximum variance calculation is performed on the foreground image and the background image through a maximum inter-class variance method and a constraint condition, and a target binarization threshold corresponding to the maximum variance is determined, including:
counting a first pixel proportion of the number of foreground pixels in the foreground image in the target gray scale image, a second pixel proportion of the number of background pixels in the background image in the target gray scale image and the average gray scale of the background image through the pixel array;
generating total average gray scale of the image according to the first pixel proportion, the second pixel proportion, the average gray scale of the foreground image and the average gray scale of the background image;
and according to the constraint condition, generating a target binarization threshold value according to the total average gray level of the image, the first pixel proportion and the average gray level of the foreground image.
Preferably, the method further comprises:
according to the pixel point array, carrying out enhancement judgment on the initial gray level image;
and if the enhancement is determined, carrying out gray level enhancement on the gray level value of the pixel point meeting the enhancement requirement in the initial gray level image according to a preset enhancement digit to obtain the enhanced initial gray level image.
Preferably, after the binarization processing is performed on the target grayscale image according to the target binarization threshold value to obtain the target binarization image, the method further includes:
and carrying out character segmentation on the target binary image to obtain a segmented character image.
The invention also discloses an image binarization processing device, which comprises:
an acquisition unit configured to acquire an original image;
the image preprocessing unit is used for preprocessing an original image to obtain a target gray-scale image and an initial binary threshold value;
the threshold value optimizing unit is used for carrying out self-adaptive binarization on the target gray level image through a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value;
and the binarization unit is used for carrying out binarization processing on the target gray level image according to the target binarization threshold value to obtain a target binarization image.
The invention also discloses a computer-readable medium, on which a computer program is stored which, when executed by a processor, implements a method as described above.
The invention also discloses a computer device comprising a memory for storing information comprising program instructions and a processor for controlling the execution of the program instructions, the processor implementing the method as described above when executing the program.
The invention also discloses a computer program product comprising computer programs/instructions which, when executed by a processor, implement the method as described above.
The invention obtains an original image; carrying out image preprocessing on an original image to obtain a target gray image and an initial binarization threshold value; carrying out self-adaptive binarization on the target gray level image by a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value; the method comprises the steps of conducting binarization processing on a target gray level image according to a target binarization threshold value to obtain a target binarization image, conducting image preprocessing and image binarization on the image in advance, determining the optimal target binarization threshold value through an improved maximum inter-class variance method, and being compatible with a special scene image, so that the accuracy of character segmentation on the image subsequently is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of an image binarization processing method according to an embodiment of the present invention;
fig. 2 is a flowchart of another image binarization processing method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an initial gray scale image according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an initial gray scale image after blank removal according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a target gray scale map after blank removal and frame removal according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a target binary image according to an embodiment of the present invention;
FIG. 7 is a diagram illustrating a segmented character image according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an image binarization processing device according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the image binarization processing method and apparatus disclosed in the present application may be used in the technical field of artificial intelligence, and may also be used in any field other than the technical field of artificial intelligence.
In order to facilitate understanding of the technical solutions provided in the present application, the following first describes relevant contents of the technical solutions in the present application. In the current image recognition field, no matter the traditional characteristic value extraction algorithm or the convolutional neural network, the accuracy of character segmentation is still the core step for improving the character recognition rate. The method is mainly used for preprocessing the image under the special scene by means of an image processing technology aiming at the condition of a dark background, and suitable threshold selection is carried out on the preprocessed image by utilizing an improved maximum inter-class variance method so as to improve the recognition accuracy of subsequent character segmentation. Simulation results show that the method can effectively process the situation of dark background images. The method processes the image of the special scene based on the image processing technology, is compatible with the special scene, and can improve the accuracy of text segmentation and the accuracy of recognition.
The following describes an implementation process of the image binarization processing method according to the embodiment of the present invention, taking an image binarization processing apparatus as an execution subject. It can be understood that the execution subject of the image binarization processing method provided by the embodiment of the invention includes, but is not limited to, an image binarization processing device.
Fig. 1 is a flowchart of an image binarization processing method according to an embodiment of the present invention, as shown in fig. 1, the method includes:
step 101, acquiring an original image.
And 102, carrying out image preprocessing on the original image to obtain a target gray-scale image and an initial binarization threshold value.
And 103, carrying out self-adaptive binarization on the target gray level map by using a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value.
And step 104, performing binarization processing on the target gray level image according to the target binarization threshold value to obtain a target binarization image.
It should be noted that the technical solution in the present application, such as obtaining, storing, using, and processing of data, all comply with relevant regulations of national laws and regulations. The user information in the embodiment of the application is obtained through legal compliance, and the user information is obtained, stored, used, processed and the like through authorization approval of a client.
According to the technical scheme provided by the embodiment of the invention, an original image is obtained; carrying out image preprocessing on an original image to obtain a target gray-scale image and an initial binarization threshold value; carrying out self-adaptive binarization on the target gray level image by a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value; the method comprises the steps of conducting binarization processing on a target gray level image according to a target binarization threshold value to obtain a target binarization image, conducting image preprocessing and image binarization on the image in advance, determining the optimal target binarization threshold value through an improved maximum inter-class variance method, and being compatible with a special scene image, so that the accuracy of character segmentation on the image subsequently is improved.
Fig. 2 is a flowchart of another image binarization processing method according to an embodiment of the present invention, as shown in fig. 2, the method includes:
step 201, obtaining an original image.
In the embodiment of the present invention, each step is executed by the image binarization processing means.
In the embodiment of the invention, the original image can be a pre-intercepted image or an image sent by other terminals. The embodiment of the invention does not limit the environment and the scene of the original image, namely: the original image can be a light font with a dark background or a dark font with a light background, and noise, blank edges, borders and other interferences can exist in the original image.
Step 202, carrying out gray level preprocessing on the original image to obtain an initial gray level image and an initial binarization threshold value.
In the embodiment of the invention, the original image is a true color (RGB) image, the original image comprises a plurality of pixel points, and each pixel point comprises three-component brightness.
In the embodiment of the present invention, step 202 specifically includes:
step 2021, performing gray level conversion on the original image to obtain an initial gray level image, where the initial gray level image includes a plurality of pixel points and a gray level value corresponding to each pixel point.
Specifically, gray level conversion is carried out on an original image through an average value method, and the three-component brightness of each pixel point in a true color image is averaged to obtain the gray value of the pixel point; and obtaining an initial gray image according to the gray values of the plurality of pixel points. The gray value of any pixel point in the initial gray map can be represented as:
Gray(i,j)=[R(i,j)+G(i,j)+B(i,j)]/3
wherein, gray (i, j) is the Gray value of the pixel point, R (i, j) is the red component brightness, G (i, j) is the green component brightness, and B (i, j) is the blue component brightness.
Fig. 3 is a schematic diagram of an initial gray scale map according to an embodiment of the present invention, as shown in fig. 3, the initial gray scale map includes 88000.00, frames and edge portions, and each pixel is represented by a different gray scale value.
Step 2022, obtaining an initial binarization threshold according to the multiple pixel points and the gray value corresponding to each pixel point.
In the embodiment of the present invention, step 2022 specifically includes:
step 22a, according to the set gray value interval, counting the gray value corresponding to each pixel point through the histogram to obtain a pixel point array, where the pixel point array includes multiple gray value intervals and the number of pixel points corresponding to each gray value interval.
In the embodiment of the invention, because the background pixel points of the initial gray level image are more than the character pixel points, the gray level interval can be set so as to facilitate the subsequent statistics. The gray value interval can be set according to actual requirements, and the gray value interval is not limited in the embodiment of the invention. As an alternative, the range of the gray-scale value is 0 to 255, and the division is performed by taking 10 values as an interval, and the divided gray-scale value interval includes: [0,9], [10, 19], [20, 29] \8230 \ 8230; [250, 255], and 26 groups in total.
In the embodiment of the invention, the histogram can reflect gray distribution information of an initial gray map, and the gray value corresponding to each pixel point is subjected to inductive statistics through the histogram according to the set gray value interval to obtain the number of the pixel points corresponding to each gray value interval; generating a pixel point array according to the gray value intervals and the pixel point number corresponding to each gray value interval, wherein the length of the pixel point array is 26, and the pixel point array is marked as Arr 26
And step 22b, carrying out turnover judgment on the initial gray-scale image according to the pixel point array.
In the embodiment of the invention, the overturning proportion is preset according to actual requirements, and as an alternative, the overturning proportion is 15%. Multiplying the turning proportion by the total number of the pixel points to obtain a turning pixel point threshold; starting accumulation calculation from the number of pixels corresponding to the first gray value interval of the pixel point array until the number of pixels is larger than the turnover pixel point threshold value, and stopping accumulation; acquiring the number of intervals participating in accumulation calculation in the pixel point array when accumulation is stopped; judging whether the interval quantity is larger than a set turning interval threshold value or not, if so, indicating that the gray value of most pixel points in the pixel point array is higher, and if the initial gray image is a dark background, determining that the initial gray image does not turn; if not, the gray value of most of the pixel points in the pixel point array is low, the initial gray image is a light background, and the initial gray image is convenient for subsequent blank and frame removal processing, so that the recognition accuracy of the segmented characters is further improved, and the initial gray image is determined to be turned over.
It should be noted that the threshold of the turning interval may be set according to actual requirements, which is not limited in the embodiment of the present invention. As an alternative, since the array length is 26, the rollover interval threshold is set to 13.
In particular, by
Figure BDA0003985412010000081
The proportion of the turning pixels, the total number of the pixels and the number of the pixels corresponding to a plurality of gray value intervals are calculatedPerforming line accumulation calculation and comparison to obtain the number of intervals participating in the accumulation calculation, wherein N is the total number of pixel points Arr j The pixel point array is defined as f (m) is an accumulation result of the number of pixel points corresponding to the first m gray value intervals of the pixel point array, m is the interval number participating in accumulation calculation, alpha is the proportion of the turning pixel, and alpha N is the threshold of the turning pixel point. It should be noted that m is not any m gray scale value intervals in the pixel point array, but the first m gray scale value intervals in the pixel point array.
And step 22c, calculating the total number of the pixel points, a plurality of gray value intervals and the number of the pixel points corresponding to each gray value interval according to the turnover judgment result to obtain an initial binarization threshold value.
In the embodiment of the present invention, the turning determination result includes determining turning or determining not turning, the initial binarization thresholds calculated by the two results are different, and the two turning determination results are described below respectively.
If the overturn is determined:
and step 22c1, turning over each pixel point in the initial gray-scale image according to the designated gray-scale digit to obtain a turned-over initial gray-scale image, wherein the turned-over initial gray-scale image comprises the gray value corresponding to each pixel point after turning over.
As an alternative, the number of gray scale bits is designated to be 255, and the specific formula is as follows:
Figure BDA0003985412010000082
wherein, I is the gray value corresponding to the pixel point after the turnover, G o And m is the number of intervals participating in accumulation calculation. And generating an initial gray-scale map after turning according to the plurality of turned pixel points and the gray-scale value corresponding to each turned pixel point.
In the embodiment of the invention, the images of the light color background and the deep color font are unified into the light color font with the deep color background, so that the subsequent blank removal and frame processing are facilitated, and the recognition accuracy rate of the segmented characters is further improved.
Further, in order to further strengthen the dark font, thereby further improving the recognition accuracy of the segmented characters, the gray level of the pixel points meeting the strengthening requirements can be strengthened. Specifically, according to the pixel point array, enhancement judgment is carried out on the turned initial gray-scale image; and if the enhancement is determined, carrying out gray enhancement on the gray value of the pixel point meeting the enhancement requirement in the reversed initial gray image according to a preset enhancement digit to obtain the enhanced initial gray image.
Both the enhancement requirement and the enhancement bit number can be set according to actual requirements, which is not limited in the embodiment of the present invention. As an alternative, the enhancement requirement is that the number of pixels corresponding to the next k gray value intervals in the pixel array is greater than the enhancement pixel threshold, where the enhancement pixel threshold is the product of the total number of pixels and the preset enhancement pixel ratio. The proportion of the enhanced pixels can be set according to actual requirements, which is not limited in the embodiment of the present invention, and as an alternative, the proportion of the enhanced pixels is 15%. As an alternative, the number of enhancement bits may be set to 35, i.e.: and adding 35 to the gray value of the pixel point meeting the enhancement requirement to obtain the gray value of the enhanced pixel point.
And step 22c2, counting the gray value corresponding to each pixel after turning through the histogram according to the gray value interval to obtain a pixel array after turning, wherein the pixel array after turning comprises a plurality of gray value intervals and the number of pixels after turning corresponding to each gray value interval.
In the embodiment of the present invention, the step 22c2 is the same as the statistical method of the step 22a, and the difference is only that the step 22c2 is to perform statistics on the gray value corresponding to each pixel after flipping, and the step 22a is to perform statistics on the gray value corresponding to each pixel before flipping, which is not repeated herein.
And step 22c3, obtaining initial binarization according to the total number of the pixel points, the gray value intervals and the number of the pixel points after the turnover corresponding to each gray value interval.
In particular, by
Figure BDA0003985412010000091
And calculating the total number of the pixel points and the number of the turned pixel points corresponding to each gray value interval to obtain initial binarization. Wherein N is the number of pixel points, L is the total number 256 of gray value values, i is the gray value, N (i) is the number of pixel points with the gray value of i, and ThresholdA is the initial binarization.
If the judgment result is that the turning is not carried out:
and obtaining initial binaryzation according to the total number of the pixel points, the gray value intervals and the number of the pixel points corresponding to each gray value interval.
In particular, by
Figure BDA0003985412010000101
And calculating the total number of the pixel points and the number of the pixel points corresponding to each gray value interval to obtain initial binaryzation. Wherein N is the total number of pixel points, L is the total number 256 of gray value values, i is the gray value, N (i) is the number of pixel points with the gray value of i, and ThresholdA is the initial binarization.
Further, if the determination is that the characters are not turned over, before the initial binarization is calculated, in order to further strengthen the dark-color fonts, the recognition accuracy of the segmented characters is further improved, and gray level enhancement can be performed on pixel points meeting enhancement requirements. Specifically, according to the pixel point array, enhancement judgment is carried out on the initial gray level image; and if the enhancement is determined, carrying out gray level enhancement on the gray level value of the pixel point meeting the enhancement requirement in the initial gray level image according to a preset enhancement digit to obtain the enhanced initial gray level image.
In the embodiment of the present invention, the gray scale enhancement in step 22c1 is the same as the enhancement method here, except that in step 22c1, the gray scale enhancement is performed on the turned gray scale value corresponding to the pixel point meeting the enhancement requirement, and here, the gray scale enhancement is performed on the gray scale value corresponding to the pixel point meeting the enhancement requirement before the initial binarization is calculated, which is not repeated herein.
And 203, performing blank removal and frame pretreatment on the initial gray level image to obtain a target gray level image.
In the embodiment of the invention, the initial gray map comprises a plurality of pixel points and a gray value corresponding to each pixel point.
Specifically, according to the pixel point array and the initial binarization threshold, blank removal and frame preprocessing are carried out on the initial gray-scale image to obtain a target gray-scale image.
In the embodiment of the present invention, step 203 specifically includes:
and 2031, performing binarization processing on the initial gray level image through an initial binarization threshold value to obtain an initial binarization image.
Specifically, the gray value corresponding to each pixel point in the initial gray map is compared with the initial binarization threshold, the gray value of the pixel point smaller than the initial binarization threshold is set to be 0, and the gray value of the pixel point larger than or equal to the initial binarization threshold is set to be 255, so that the initial binarization image is obtained.
Step 2032, traversing is started from two ends of the initial binary image according to the pixel rows until pixel coordinates of the black pixel points at the edge are obtained.
Specifically, according to the pixel row, the left end and the right end of the initial binary image are traversed respectively, and whether a black pixel point exists is judged, namely: whether pixel points with the gray value of 255 exist, if yes, the pixel coordinates of the black pixel points are recorded, and next-line traversal is started until all pixel lines in the initial binary image are traversed; and if not, continuously traversing the next pixel point and/or the next line until the black pixel point is obtained. The recorded black pixels are black pixels positioned at the edge.
As another alternative, according to the pixel column, traversing from the upper and lower ends of the initial binarized image respectively, and determining whether a black pixel exists, that is: whether a pixel point with the gray value of 255 exists or not, if yes, recording the pixel coordinate of the black pixel point, and starting traversing the next row until all pixel rows in the initial binary image are traversed; and if not, continuously traversing the next pixel point and/or the next column until the black pixel point is obtained. The recorded black pixels are black pixels positioned at the edge.
And 2033, performing blank removing processing on the initial gray level image according to the pixel coordinates of the black pixel points at the edge to obtain a blank-removed initial gray level image.
Specifically, a gray scale image surrounded by the pixel coordinates of the recorded black pixel points as an outline is screened out from the initial gray scale image, and the initial gray scale image after blank removal is obtained.
Fig. 4 is a schematic diagram of an initial gray scale map after blank removal according to an embodiment of the present invention, and as shown in fig. 4, compared with fig. 3, a blank edge is removed from the initial gray scale map shown in fig. 4.
And step 2034, updating the initial binarization threshold value according to the set intermediate parameters to obtain an intermediate threshold value.
In order to save the noise and the frame information as much as possible, the initial binarization threshold is updated. Specifically, the intermediate parameter and the initial binary Threshold are calculated through Threshold B = Threshold a-C, and the intermediate Threshold is obtained. Wherein Threshold B is the intermediate Threshold, threshold a is the initial binarization Threshold, and C is the intermediate parameter. It should be noted that the intermediate parameter may be set according to actual requirements, which is not limited in the embodiment of the present invention. As an alternative, the intermediate parameter is 20.
And 2035, performing binarization processing on the blank-removed initial gray level image through an intermediate threshold value to obtain an enhanced binarization image.
Specifically, the gray value corresponding to each pixel point in the blank-removed initial gray image is compared with the intermediate threshold, the gray value of the pixel point smaller than the intermediate threshold is set to be 0, and the gray value of the pixel point larger than or equal to the intermediate threshold is set to be 255, so that the enhanced binary image is obtained.
Step 2036, traversing from the central pixel point of the enhanced binary image, acquiring the line coordinates of all the pixel points in the line of the black pixel point which are black pixel points, and/or acquiring the column coordinates of all the pixel points in the column of the black pixel point which are black pixel points.
Specifically, the method starts from a central pixel point of the enhanced binary image, starts to traverse respectively in four directions, namely up, down, left and right, and judges whether an entire row and/or an entire column of black pixel points exist, namely: and if yes, recording the row coordinate of the row and/or the column coordinate of the column, and if not, continuously traversing to the next row and/or the next column until all rows and columns for enhancing binarization are traversed. If the situation that the whole row or the whole column is black pixel points does not exist after traversing all the rows and the columns for enhancing the binaryzation is finished, the image is indicated to be frameless; if the whole row and/or the whole column are black pixel points, the image is indicated to have a frame. And recording the row coordinate and/or the column coordinate as the position of the frame.
And 2037, performing frame removal processing on the blank-removed initial gray-scale image according to the row coordinates and/or the column coordinates to obtain a target gray-scale image.
Specifically, the recorded row coordinates and/or column coordinates are filtered from the initial gray scale image after blank removal, and a target gray scale image is obtained.
Fig. 5 is a schematic diagram of a blank-removed and frame-removed target gray scale image according to an embodiment of the present invention, as shown in fig. 5, compared with fig. 4, the frame of the target gray scale image shown in fig. 5 is removed.
After the image is subjected to fixed binarization processing, errors exist when the text image is segmented, for example, two digital black pixel points are connected and are segmented into the same number. In order to avoid the condition of character adhesion during character segmentation, the segmentation threshold is subjected to self-adaptive binarization by an improved maximum inter-class variance method, and the optimal threshold is selected to maximize the variance between the foreground image and the background image.
And 204, acquiring a segmentation threshold according to a preset threshold range.
In the embodiment of the invention, the image can be divided into the foreground image and the background image according to the gray characteristic of the image, the segmentation threshold value between the foreground image and the background image is recorded as T, and the threshold value range of the segmentation threshold value is 0-255.
And step 205, dividing the target gray image into a foreground image and a background image according to the segmentation threshold.
Specifically, the gray value corresponding to each pixel point in the target gray image is compared with the segmentation threshold T, the gray value of the pixel point smaller than the segmentation threshold T is set to 0, and the gray value of the pixel point larger than or equal to the segmentation threshold T is set to 255, so that the initial binary image is obtained.
And step 206, counting the average gray scale of the foreground image through the pixel point array.
In particular, by
Figure BDA0003985412010000121
And calculating the total number of the pixel points, the gray value and the number of the pixel points with the gray value i to obtain the average gray of the foreground image. Wherein h is 0 The average gray level of the foreground image is represented by i, the gray level is represented by N (i), the number of pixels with the gray level being i is represented by N, the total number of pixels is represented by N, and the division threshold is represented by T.
And step 207, constructing a constraint condition according to the initial binarization threshold value and the average gray level of the foreground image.
When the size ratio of the target to the background is very different (the background is complex, etc., the inter-class variance criterion function may present a bimodal or multimodal situation, and the segmentation effect is poor. On the basis, a maximum inter-class variance method is further optimized, and in order to achieve the purpose that lines of text characters are thin and beneficial to segmentation, constraint conditions are added when the maximum variance between the foreground and the background of the image is obtained.
Specifically, a constraint condition is constructed according to an initial binarization threshold value and the average gray level of the foreground image, and the constructed constraint condition is h 0 -ThreasholdA < 0, wherein, h 0 Threshold a is the initial binarization Threshold value, which is the average gray level of the foreground image.
And 208, performing maximum variance calculation on the foreground image and the background image through a maximum inter-class variance method and constraint conditions to determine a target binarization threshold corresponding to the maximum variance.
In the embodiment of the present invention, step 208 specifically includes:
step 2081, counting a first pixel proportion of the number of foreground pixels in the foreground image in the target gray scale image, a second pixel proportion of the number of background pixels in the background image in the target gray scale image and an average gray scale of the background image through the pixel array.
In particular, by
Figure BDA0003985412010000131
And calculating the total number of the pixel points and the number of the pixel points with the gray value i to obtain a first pixel proportion of the number of the foreground pixel points in the target gray image. Wherein, w 0 In the first pixel proportion, N (i) is the number of pixels with the gray value i, N is the total number of pixels, and T is the segmentation threshold.
In particular, by
Figure BDA0003985412010000132
And calculating the total number of the pixel points and the number of the pixel points with the gray value i to obtain a second pixel proportion of the number of the background pixel points in the target gray image. Wherein, w 1 In the second pixel proportion, N (i) is the number of pixels with the gray value i, N is the total number of pixels, T is the segmentation threshold, and L is the total number of gray value values.
In particular, by
Figure BDA0003985412010000133
And calculating the total number of the pixel points, the gray value and the number of the pixel points with the gray value i to obtain the average gray of the background image. Wherein h is 1 The average gray level of the background image is represented as i, the gray level is the gray level value, N (i) is the number of pixels with the gray level value being i, N is the total number of pixels, T is the segmentation threshold, and L is the total number of gray level values.
And step 2082, generating the total average gray level of the image according to the first pixel proportion, the second pixel proportion, the average gray level of the foreground image and the average gray level of the background image.
Specifically, by h = w 0 ×h 0 +w 1 ×h 1 Calculating the first pixel proportion, the second pixel proportion, the average gray scale of the foreground image and the average gray scale of the background image to obtain the total average gray scale of the imageAnd (4) gray scale. Wherein w 0 Is a first pixel proportion, w 1 Is the second pixel proportion, h 0 Average gray of foreground image, h 1 Is the average gray level of the background image, and h is the total average gray level of the image.
And 2083, generating a target binarization threshold according to the total average gray of the image, the first pixel proportion and the average gray of the foreground image according to the constraint conditions.
In particular, by
Figure BDA0003985412010000141
Determining a target binarization threshold value for the total average gray level of the image, the first pixel proportion and the average gray level of the foreground image, namely: traversing the image matrix to obtain the maximum variance h 0 -a segmentation threshold T corresponding to ThreasholdA < 0; and determining the acquired segmentation threshold value T as a target binarization threshold value.
And 209, performing binarization processing on the target gray level image according to the target binarization threshold value to obtain a target binarization image.
Specifically, comparing the gray value corresponding to each pixel point in the target gray image with the target binarization threshold, setting the gray value of the pixel point smaller than the target binarization threshold to be 0, and setting the gray value of the pixel point larger than or equal to the target binarization threshold to be 255 to obtain the target binarization image.
Fig. 6 is a schematic diagram of a target binary image according to an embodiment of the present invention, and as shown in fig. 6, compared with the character portion shown in fig. 5 where two digital black pixel points are connected (the last two bits are 0), white pixel points exist between two digital black pixel points in the corresponding portion shown in fig. 6, so that an effect that a text character is fine and easy to segment is achieved.
And step 210, performing character segmentation on the target binary image to obtain a segmented character image.
It should be noted that the character segmentation technology is the prior art, and the specific method adopted by the character segmentation in the embodiment of the present invention is not limited.
Fig. 7 is a schematic diagram of a segmented character image according to an embodiment of the present invention, where the segmented character image shown in fig. 7 is an image obtained by performing character segmentation based on fig. 6, and as shown in fig. 7, no adhesion occurs between characters, so that the character recognition accuracy is high.
In the technical scheme of the image binarization processing method provided by the embodiment of the invention, an original image is obtained; carrying out image preprocessing on an original image to obtain a target gray image and an initial binarization threshold value; carrying out self-adaptive binarization on the target gray level image by a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value; the method comprises the steps of conducting binarization processing on a target gray-scale image according to a target binarization threshold value to obtain a target binarization image, conducting image preprocessing and image binarization on the image in advance, determining an optimal target binarization threshold value through an improved maximum inter-class variance method, and being compatible with a special scene image, thereby improving the accuracy of character segmentation on the image subsequently.
Fig. 8 is a schematic structural diagram of an image binarization processing device according to an embodiment of the present invention, the device is used for executing the image binarization processing method, and as shown in fig. 8, the device includes: an acquisition unit 11, an image preprocessing unit 12, a threshold optimization unit 13, and a binarization unit 14.
The acquisition unit 11 is used to acquire an original image.
The image preprocessing unit 12 is configured to perform image preprocessing on the original image to obtain a target grayscale map and an initial binarization threshold.
The threshold optimization unit 13 is configured to perform adaptive binarization on the target grayscale map by using a maximum inter-class variance method and an initial binarization threshold to obtain a target binarization threshold.
The binarization unit 14 is configured to perform binarization processing on the target grayscale image according to the target binarization threshold value to obtain a target binarization image.
In the embodiment of the present invention, the image preprocessing unit 12 is specifically configured to perform gray level preprocessing on an original image to obtain an initial gray level image and an initial binarization threshold; and performing blank removal and frame preprocessing on the initial gray-scale image to obtain a target gray-scale image.
In the embodiment of the present invention, the image preprocessing unit 12 is specifically configured to perform gray scale conversion on an original image to obtain an initial gray scale map, where the initial gray scale map includes a plurality of pixel points and a gray scale value corresponding to each pixel point; and obtaining an initial binarization threshold value according to the plurality of pixel points and the gray value corresponding to each pixel point.
In the embodiment of the present invention, the image preprocessing unit 12 is specifically configured to count the gray value corresponding to each pixel point through a histogram according to the set gray value interval to obtain a pixel point array, where the pixel point array includes a plurality of gray value intervals and the number of pixel points corresponding to each gray value interval; turning and judging the initial gray level image according to the pixel point array; and according to the turning judgment result, calculating the total number of the pixel points, a plurality of gray value intervals and the number of the pixel points corresponding to each gray value interval to obtain an initial binarization threshold.
In the embodiment of the present invention, the image preprocessing unit 12 is specifically configured to, if the turning is determined, turn over each pixel point in the initial gray-scale image according to the specified number of gray-scale bits to obtain a turned initial gray-scale image, where the turned initial gray-scale image includes a gray-scale value corresponding to each pixel point after the turning; counting the gray value corresponding to each pixel after turning through the histogram according to the gray value interval to obtain a pixel array after turning, wherein the pixel array after turning comprises a plurality of gray value intervals and the number of pixels after turning corresponding to each gray value interval; obtaining initial binaryzation according to the total number of the pixel points, a plurality of gray value intervals and the number of the turned pixel points corresponding to each gray value interval; and if the pixel points are determined not to be turned over, obtaining initial binaryzation according to the total number of the pixel points, a plurality of gray value intervals and the number of the pixel points corresponding to each gray value interval.
In the embodiment of the invention, the initial gray level image comprises a plurality of pixel points and a gray level value corresponding to each pixel point; the image preprocessing unit 12 is specifically configured to perform blank removal and border preprocessing on the initial grayscale map according to the pixel point array and the initial binarization threshold, so as to obtain a target grayscale map.
In the embodiment of the present invention, the image preprocessing unit 12 is specifically configured to perform binarization processing on the initial grayscale map by using an initial binarization threshold value to obtain an initial binarization image; traversing from two ends of the initial binary image according to pixel rows until pixel coordinates of black pixel points at the edge are obtained; according to the pixel coordinates of the black pixel points positioned at the edge, blank removing processing is carried out on the initial gray level image to obtain the blank-removed initial gray level image; updating the initial binarization threshold value according to the set intermediate parameter to obtain an intermediate threshold value; performing binarization processing on the blank-removed initial gray level image through an intermediate threshold value to obtain an enhanced binarization image; traversing from a central pixel point of the enhanced binary image, and acquiring row coordinates of all pixel points of a row where the black pixel points are black pixel points, and/or acquiring column coordinates of all pixel points of a column where the black pixel points are black pixel points; and performing frame removing processing on the initial gray-scale image after blank removing according to the row coordinates and/or the column coordinates to obtain a target gray-scale image.
In the embodiment of the present invention, the threshold optimization unit 13 is specifically configured to obtain a segmentation threshold according to a preset threshold range; dividing the target gray level image into a foreground image and a background image according to a segmentation threshold; counting the average gray scale of the foreground image through the pixel point array; constructing a constraint condition according to the initial binarization threshold and the average gray level of the foreground image; and calculating the maximum variance of the foreground image and the background image by a maximum inter-class variance method and constraint conditions to determine a target binarization threshold corresponding to the maximum variance.
In the embodiment of the present invention, the threshold optimization unit 13 is specifically configured to count, through the pixel array, a first pixel proportion of the number of foreground pixels in the foreground image in the target grayscale, a second pixel proportion of the number of background pixels in the background image in the target grayscale, and an average grayscale of the background image; generating total average gray scale of the image according to the first pixel proportion, the second pixel proportion, the average gray scale of the foreground image and the average gray scale of the background image; and according to the constraint condition, generating a target binarization threshold value according to the total average gray level of the image, the first pixel proportion and the average gray level of the foreground image.
In an embodiment of the present invention, the apparatus further includes: an enhancement judgment unit 15 and a gradation enhancement unit 16.
The enhancement judging unit 15 is configured to perform enhancement judgment on the initial gray level image according to the pixel point array.
The gray enhancement unit 16 is configured to, if enhancement is determined, perform gray enhancement on the gray value of the pixel point meeting the enhancement requirement in the initial gray image according to a preset enhancement digit, to obtain an enhanced initial gray image.
In the embodiment of the present invention, the apparatus further includes: a character segmentation unit 17.
The character segmentation unit 17 is configured to perform character segmentation on the target binary image to obtain a segmented character image.
In the scheme of the embodiment of the invention, an original image is obtained; carrying out image preprocessing on an original image to obtain a target gray-scale image and an initial binarization threshold value; performing self-adaptive binarization on the target gray level image through a maximum inter-class variance method and an initial binarization threshold value to obtain a target binarization threshold value; the method comprises the steps of conducting binarization processing on a target gray-scale image according to a target binarization threshold value to obtain a target binarization image, conducting image preprocessing and image binarization on the image in advance, determining an optimal target binarization threshold value through an improved maximum inter-class variance method, and being compatible with a special scene image, thereby improving the accuracy of character segmentation on the image subsequently.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer device, which may be, for example, a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
Embodiments of the present invention provide a computer device, including a memory and a processor, where the memory is used to store information including program instructions, and the processor is used to control execution of the program instructions, and the program instructions are loaded and executed by the processor to implement the steps of the embodiments of the image binarization processing method, and specific descriptions can be found in the embodiments of the image binarization processing method.
Referring now to FIG. 9, shown is a schematic diagram of a computer device 600 suitable for use in implementing embodiments of the present application.
As shown in fig. 9, the computer apparatus 600 includes a Central Processing Unit (CPU) 601 that can execute various appropriate jobs and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the computer apparatus 600 are also stored. The CPU601, ROM602, and RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output section 607 including a Cathode Ray Tube (CRT), a liquid crystal feedback (LCD), and the like, and a speaker and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted as necessary on the storage section 608.
In particular, the processes described above with reference to the flowcharts may be implemented as a computer software program according to an embodiment of the present invention. For example, embodiments of the invention include a computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611.
Computer-readable media, including both permanent and non-permanent, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the various elements may be implemented in the same one or more pieces of software and/or hardware in the practice of the present application.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It should also be noted that 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 other like elements in a process, method, article, or apparatus comprising the element.
According to the technical scheme, the data acquisition, storage, use, processing and the like meet relevant regulations of national laws and regulations.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (15)

1. An image binarization processing method is characterized by comprising the following steps:
acquiring an original image;
carrying out image preprocessing on the original image to obtain a target gray-scale image and an initial binarization threshold value;
performing self-adaptive binarization on the target gray level map by a maximum inter-class variance method and the initial binarization threshold value to obtain a target binarization threshold value;
and carrying out binarization processing on the target gray level image according to the target binarization threshold value to obtain a target binarization image.
2. The image binarization processing method according to claim 1, characterized in that the image preprocessing on the original image to obtain a target gray map and an initial binarization threshold value comprises:
carrying out gray level pretreatment on the original image to obtain an initial gray level image and an initial binarization threshold value;
and performing blank removal and frame pretreatment on the initial gray level image to obtain the target gray level image.
3. The image binarization processing method according to claim 2, characterized in that the performing gray scale preprocessing on the original image to obtain an initial gray scale map and an initial binarization threshold value comprises:
performing gray level conversion on the original image to obtain an initial gray level image, wherein the initial gray level image comprises a plurality of pixel points and a gray level value corresponding to each pixel point;
and obtaining an initial binarization threshold value according to the plurality of pixel points and the gray value corresponding to each pixel point.
4. The image binarization processing method according to claim 3, wherein said obtaining an initial binarization threshold value according to the gray values corresponding to a plurality of pixel points and each pixel point comprises:
according to the set gray value interval, counting the gray value corresponding to each pixel point through a histogram to obtain a pixel point array, wherein the pixel point array comprises a plurality of gray value intervals and the number of pixel points corresponding to each gray value interval;
turning and judging the initial gray level image according to the pixel point array;
and according to the turning judgment result, calculating the total number of the pixel points, a plurality of gray value intervals and the number of the pixel points corresponding to each gray value interval to obtain an initial binarization threshold.
5. The image binarization processing method according to claim 4, wherein the calculating, according to the inversion judgment result, the total number of pixel points, the plurality of gray value intervals and the number of pixel points corresponding to each gray value interval to obtain an initial binarization threshold value comprises:
if the turning is determined, turning each pixel point in the initial gray level image according to the appointed gray level digit to obtain a turned initial gray level image, wherein the turned initial gray level image comprises a gray level value corresponding to each pixel point;
according to the gray value interval, counting the gray value corresponding to each pixel after turning through a histogram to obtain a pixel array after turning, wherein the pixel array after turning comprises a plurality of gray value intervals and the number of pixels after turning corresponding to each gray value interval;
obtaining initial binaryzation according to the total number of the pixel points, a plurality of gray value intervals and the number of the turned pixel points corresponding to each gray value interval;
and if the pixel points are determined not to be turned over, obtaining initial binaryzation according to the total number of the pixel points, a plurality of gray value intervals and the number of the pixel points corresponding to each gray value interval.
6. The image binarization processing method according to claim 4, characterized in that the initial grey-scale map comprises a plurality of pixel points and a grey-scale value corresponding to each pixel point;
the pre-processing of blank removal and frame removal on the initial gray-scale image to obtain the target gray-scale image comprises the following steps:
and performing blank removal and frame pretreatment on the initial grey-scale image according to the pixel point array and the initial binarization threshold value to obtain the target grey-scale image.
7. The image binarization processing method according to claim 6, wherein the obtaining the target gray-scale map by performing blank removal and border preprocessing on the initial gray-scale map according to the pixel point array and an initial binarization threshold value comprises:
performing binarization processing on the initial gray level image through the initial binarization threshold value to obtain an initial binarization image;
traversing from two ends of the initial binary image according to pixel rows until pixel coordinates of black pixel points at the edge are obtained;
according to the pixel coordinates of the black pixel points positioned at the edge, performing blank removing processing on the initial gray-scale image to obtain a blank-removed initial gray-scale image;
updating the initial binarization threshold value according to the set intermediate parameter to obtain an intermediate threshold value;
performing binarization processing on the blank-removed initial gray level image through the intermediate threshold value to obtain an enhanced binarization image;
traversing from a central pixel point of the enhanced binary image to obtain a row coordinate of black pixel points in all pixel points of a row, and/or obtaining a column coordinate of black pixel points in all pixel points of a column;
and according to the row coordinates and/or the column coordinates, performing frame removing treatment on the blank-removed initial gray-scale image to obtain a target gray-scale image.
8. The image binarization processing method according to claim 4, characterized in that the self-adaptive binarization is performed on the target gray scale map through a maximum inter-class variance method and the initial binarization threshold value to obtain a target binarization threshold value, and comprises:
acquiring a segmentation threshold according to a preset threshold range;
dividing the target gray image into a foreground image and a background image according to the segmentation threshold;
counting the average gray scale of the foreground image through the pixel point array;
constructing a constraint condition according to the initial binarization threshold and the average gray level of the foreground image;
and carrying out maximum variance calculation on the foreground image and the background image through the maximum inter-class variance method and the constraint condition to determine a target binarization threshold corresponding to the maximum variance.
9. The image binarization processing method according to claim 8, wherein the performing maximum variance calculation on the foreground image and the background image through the maximum inter-class variance method and the constraint condition to determine a target binarization threshold corresponding to the maximum variance comprises:
counting the ratio of the number of foreground pixels in the foreground image to a first pixel of the target gray scale image, the ratio of the number of background pixels in the background image to a second pixel of the target gray scale image and the average gray scale of the background image through the pixel array;
generating total average gray scale of the image according to the first pixel proportion, the second pixel proportion, the average gray scale of the foreground image and the average gray scale of the background image;
and according to the constraint condition, generating a target binarization threshold value according to the total average gray level of the image, the first pixel proportion and the average gray level of the foreground image.
10. The image binarization processing method according to claim 4, characterized in that the method further comprises:
according to the pixel point array, carrying out enhancement judgment on the initial gray-scale image;
and if the enhancement is determined, carrying out gray level enhancement on the gray level value of the pixel point meeting the enhancement requirement in the initial gray level image according to a preset enhancement digit to obtain the enhanced initial gray level image.
11. The image binarization processing method according to claim 1, characterized in that after the binarization processing is performed on the target gray-scale map according to the target binarization threshold value to obtain a target binarization image, the method further comprises:
and carrying out character segmentation on the target binary image to obtain a segmented character image.
12. An image binarization processing device, characterized in that the device comprises:
an acquisition unit configured to acquire an original image;
the image preprocessing unit is used for preprocessing the original image to obtain a target gray-scale image and an initial binarization threshold value;
the threshold value optimizing unit is used for carrying out self-adaptive binarization on the target gray level image through a maximum inter-class variance method and the initial binarization threshold value to obtain a target binarization threshold value;
and the binarization unit is used for carrying out binarization processing on the target gray level image according to the target binarization threshold value to obtain a target binarization image.
13. A computer-readable medium on which a computer program is stored, characterized in that the program, when executed by a processor, implements the image binarization processing method as recited in any one of claims 1 to 11.
14. A computer device comprising a memory for storing information including program instructions and a processor for controlling the execution of the program instructions, characterized in that the program instructions are loaded and executed by the processor to implement the image binarization processing method according to any one of claims 1 to 11.
15. A computer program product comprising a computer program/instructions, characterized in that said computer program/instructions, when executed by a processor, implement the image binarization processing method according to any one of claims 1 to 11.
CN202211562829.1A 2022-12-07 2022-12-07 Image binarization processing method and device Pending CN115909353A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211562829.1A CN115909353A (en) 2022-12-07 2022-12-07 Image binarization processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211562829.1A CN115909353A (en) 2022-12-07 2022-12-07 Image binarization processing method and device

Publications (1)

Publication Number Publication Date
CN115909353A true CN115909353A (en) 2023-04-04

Family

ID=86476370

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211562829.1A Pending CN115909353A (en) 2022-12-07 2022-12-07 Image binarization processing method and device

Country Status (1)

Country Link
CN (1) CN115909353A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116107394A (en) * 2023-04-06 2023-05-12 合肥联宝信息技术有限公司 Adjustment method, adjustment device, electronic equipment and storage medium
CN116681664A (en) * 2023-05-30 2023-09-01 佛山市明焱科技有限公司 Detection method and device for operation of stamping equipment

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116107394A (en) * 2023-04-06 2023-05-12 合肥联宝信息技术有限公司 Adjustment method, adjustment device, electronic equipment and storage medium
CN116107394B (en) * 2023-04-06 2023-08-04 合肥联宝信息技术有限公司 Adjustment method, adjustment device, electronic equipment and storage medium
CN116681664A (en) * 2023-05-30 2023-09-01 佛山市明焱科技有限公司 Detection method and device for operation of stamping equipment

Similar Documents

Publication Publication Date Title
CN115909353A (en) Image binarization processing method and device
CN110348264B (en) QR two-dimensional code image correction method and system
US20190188528A1 (en) Text detection method and apparatus, and storage medium
CN109427047B (en) Image processing method and device
CN109658424B (en) Improved robust two-dimensional OTSU threshold image segmentation method
CN106846390B (en) Image processing method and device
CN104517110A (en) Binarization method and system of two-dimensional code image
CN110969046B (en) Face recognition method, face recognition device and computer-readable storage medium
CN103402042A (en) Halftone image generation method based on sectioned error diffusion
CN106971399A (en) Image-mosaics detection method and device
CN111680690A (en) Character recognition method and device
CN111145105A (en) Image rapid defogging method and device, terminal and storage medium
CN111597845A (en) Two-dimensional code detection method, device and equipment and readable storage medium
CN108205678B (en) Nameplate character recognition processing method containing bright spot interference
CN116822548B (en) Method for generating high recognition rate AI two-dimensional code and computer readable storage medium
CN110147765B (en) Image processing method and device
CN110930358B (en) Solar panel image processing method based on self-adaptive algorithm
CN114550173A (en) Image preprocessing method and device, electronic equipment and readable storage medium
CN106651944A (en) Algorithm and device for obtaining maximal horizontally inscribed rectangle for any connected domain based on run length encoding
CN110633705A (en) Low-illumination imaging license plate recognition method and device
JP2006270897A (en) Image processing device, method and program
CN110070103A (en) The method and terminal device of identity card identification
CN110580706A (en) Method and device for extracting video background model
CN114267035A (en) Document image processing method and system, electronic device and readable medium
CN115063679A (en) Pavement quality assessment method based on deep learning

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