CN114694162B - Invoice image recognition method and system based on image processing - Google Patents

Invoice image recognition method and system based on image processing Download PDF

Info

Publication number
CN114694162B
CN114694162B CN202210603229.9A CN202210603229A CN114694162B CN 114694162 B CN114694162 B CN 114694162B CN 202210603229 A CN202210603229 A CN 202210603229A CN 114694162 B CN114694162 B CN 114694162B
Authority
CN
China
Prior art keywords
character
corner
corner point
point
structural
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
CN202210603229.9A
Other languages
Chinese (zh)
Other versions
CN114694162A (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 Aisino Corp
Original Assignee
Shenzhen Aisino Corp
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 Aisino Corp filed Critical Shenzhen Aisino Corp
Priority to CN202210603229.9A priority Critical patent/CN114694162B/en
Publication of CN114694162A publication Critical patent/CN114694162A/en
Application granted granted Critical
Publication of CN114694162B publication Critical patent/CN114694162B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Character Input (AREA)

Abstract

The invention relates to the technical field of image processing, in particular to an invoice image identification method and system based on image processing. The method comprises the following steps: obtaining a difference image only containing the machine printing content; according to the gradient histogram of the edge pixel points in the difference image; selecting an edge pixel point in a preset gradient direction as an angular point, and simultaneously screening to obtain a first angular point; obtaining a character area, wherein the character area is a minimum circumscribed rectangle of a complete machine-typed character string; screening first corner points around each character in all the character areas by using the structural parameters among the first corner points to obtain structural corner points of all the characters in the character areas; and segmenting and identifying the characters according to the coordinates of the structural corner points belonging to each character in the character area. Redundant angular points reserved for SIFT angular point detection can be greatly reduced, and repeated operation and judgment of all pixel points are reduced; further reducing the influence of redundant corners on character segmentation and obtaining accurate character segmentation information.

Description

Invoice image recognition method and system based on image processing
Technical Field
The invention relates to the technical field of image processing, in particular to an invoice image identification method and system based on image processing.
Background
With the development of science and technology, commercial invoices are mainly issued by machines at the present stage, and the traditional invoice counting work is to manually check and examine the invoices one by one, so that the efficiency is low, and the invoice counting method is influenced by human factors. In the prior art, a computer is used for identifying an invoice number and an invoice code, and character identification information of a target area is acquired through optical character identification, so that invoice counting and reviewing tasks are greatly reduced.
The problems in the prior art are that: the optical character recognition is utilized to have certain requirements on the image quality of the invoice. When the surface of the invoice has folds, offsets and virtual prints, the problems of wrong optical character recognition, low recognition precision and the like can be caused. Aiming at the problems, the invention provides an invoice image identification method and system based on image processing. And correcting influence factors possibly occurring in the identification process of the optical character by using the characteristics of the corner point structure characteristic and the like of the invoice number.
Disclosure of Invention
In order to solve the above technical problems, an object of the present invention is to provide an invoice image recognition method and system based on image processing, and the adopted technical solution is as follows:
in a first aspect, an embodiment of the present invention provides an invoice image recognition method based on image processing: performing subtraction on the machine-printed invoice image and the standard invoice template image to obtain a difference image only containing machine-printed contents; obtaining edge pixel points in the difference image, and constructing a gradient histogram according to the gradient direction of the edge pixel points; selecting an edge pixel point in a preset gradient direction as an angular point by using the gradient histogram;
obtaining gradient complexity according to the number of different gradient directions of the pixel points in the angular point neighborhood range and the variance of the gradient amplitudes of the pixel points in the angular point neighborhood range and the neighborhood range; setting a gradient threshold, wherein an angular point with the gradient complexity greater than the gradient threshold is a first angular point; carrying out region division on the difference image to obtain a character region, wherein the character region is a minimum external rectangle of a complete machine-typed character string;
obtaining an angular point positioned at the upper left corner in first angular points in the character area as an initial angular point of a first character in the character area, and obtaining structural parameters based on the offset distance in the horizontal direction, the offset distance in the vertical direction and the offset angle of the initial angular point and the first angular point which is most adjacent to the initial angular point; setting a structural threshold value, and removing the nearest first corner point with the structural parameter smaller than the structural threshold value, wherein the process is a corner point removing process; if the first corner point which is closest to the initial corner point is removed, obtaining a first corner point which is second adjacent to the initial corner point, and carrying out a corner point removing process; and segmenting the characters according to the coordinates of the structural corner points belonging to each character in the character area, and identifying the segmented characters.
Preferably, constructing a gradient histogram according to the gradient direction of the edge pixel point includes: and uniformly dividing the 360-degree image into direction ranges with preset quantity, and counting the number of edge pixel points belonging to each direction range to construct a gradient gray histogram.
Preferably, the gradient complexity is:
Figure 230778DEST_PATH_IMAGE002
wherein,
Figure 100002_DEST_PATH_IMAGE003
representing the gradient complexity of the corner points;
Figure 639893DEST_PATH_IMAGE004
representing the number of different gradient directions of pixel points in the neighborhood range of the corner 8;
Figure 100002_DEST_PATH_IMAGE005
representing the gradient amplitude of the ith pixel point in the neighborhood range of the angular point 8;
Figure 366541DEST_PATH_IMAGE006
representing the average value of the gradient amplitudes of the pixel points in the neighborhood range of the angular point 8;
Figure 100002_DEST_PATH_IMAGE007
8 pixel points representing the range of the neighborhood of the corner 8.
Preferably, the region division of the difference image, and the obtaining of the character region includes: and obtaining a minimum circumscribed rectangle of each complete character string according to the first corner points of the top and bottom of each character in each complete character string in the difference image and the first corner points of the left and right of the complete character string, wherein the minimum circumscribed rectangle is a character area.
Preferably, before obtaining the structural parameters, the method further comprises: a rectangular coordinate system is established in the difference image, and the rectangular coordinate system rotates upwards and downwards respectively by taking the x-axis direction as the central direction
Figure 468489DEST_PATH_IMAGE008
The resulting range of angles; rotate left and right respectively with the y-axis direction as the center direction
Figure 178956DEST_PATH_IMAGE008
Obtaining an angular range; and combining the two angle ranges to obtain an angle area, obtaining a first angular point in the angle area, and recording as the angular point to be eliminated.
Preferably, the structural parameters are:
Figure 719659DEST_PATH_IMAGE010
establishing a rectangular coordinate system in the difference image;
Figure 100002_DEST_PATH_IMAGE011
representing a structural parameter;
Figure 300813DEST_PATH_IMAGE012
represents the distance between the starting corner point and the first corner point which is most adjacent to the starting corner point in the x-axis direction, namely the horizontal direction, and is an offset distance;
Figure 100002_DEST_PATH_IMAGE013
the distance between the starting angular point and the nearest first angular point in the y-axis direction, namely the vertical direction, is represented as an offset distance;
Figure 573662DEST_PATH_IMAGE014
indicating the width of the machine-typed character in the horizontal direction of the character when the character is not shifted;
Figure 100002_DEST_PATH_IMAGE015
indicating the height of the typewritten character in the vertical direction of the character when the character is not shifted;
Figure 974688DEST_PATH_IMAGE016
representing the offset angle between the starting corner point and its nearest neighboring corner point
Figure 519414DEST_PATH_IMAGE016
Taking the positive direction of the x-axis as the initial
Figure 100002_DEST_PATH_IMAGE017
And counterclockwise rotation defines the magnitude of the angle.
Preferably, obtaining the structural corner point of the first character comprises: obtaining an initial corner point of a first character in the character area, calculating a structural parameter between the initial corner point and a first corner point which is most adjacent to the initial corner point, if the structural parameter is smaller than a structural threshold value, rejecting the first corner point which is most adjacent to the initial corner point, obtaining the structural parameter between the initial corner point and a second adjacent first corner point, and if the structural parameter is smaller than the structural threshold value, rejecting the second adjacent first corner point;
if the structural parameter is greater than the structural threshold value, reserving a second adjacent first corner point, calculating the structural parameter between a first corner point which is most adjacent to the second adjacent first corner point and the second adjacent first corner point, and if the structural parameter is greater than the structural threshold value, reserving the first corner point which is most adjacent to the second adjacent first corner point;
if the structural parameters between the starting corner point and the first corner point nearest to the starting corner point are larger than the structural threshold value, the first corner point nearest to the starting corner point is reserved, the structural parameters between the first corner point nearest to the starting corner point and the first corner point nearest to the starting corner point are calculated, if the structural parameters are larger than the structural threshold value, the first corner point nearest to the first corner point is reserved, and the eliminated first corner points are all the corner points to be eliminated.
Preferably, after obtaining the structural corner point of the first character, the method further includes: connecting every two structural nodes of the first character by straight lines, and if the straight line corresponding to one structural corner point does not have a straight line intersected with the first character, not belonging the structural corner point of the first character; and obtaining the structural corner points which do not belong to the first character for judging the structural corner points of the second character.
Preferably, the character is segmented according to coordinates of structure corner points belonging to each character in the character region, and the recognizing of the segmented character includes: obtaining the minimum circumscribed rectangle of each character according to the coordinates of the structure corner points of each character in one character area, and completing the segmentation of each character in one character area; and recognizing the segmented characters by utilizing a neural network based on the semantic features of the characters.
In a second aspect, another embodiment of the present invention provides an image processing-based invoice image recognition system, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the image processing-based invoice image recognition method.
The embodiment of the invention at least has the following beneficial effects: based on the invention, the shape characteristics of machine-printed characters are fully considered, redundant filtering is carried out on angular points, edge pixel points are filtered by utilizing the non-principal direction of a gradient histogram, and meanwhile, the angular points with reference values are screened by means of the gradient complexity in the range of 8 neighborhoods; the method and the device have the advantages that the influence of redundant corners on character segmentation can be further reduced, and meanwhile accurate character segmentation information can be obtained through the self-adaptive window.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of 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 other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a method for identifying invoice images based on image processing.
Detailed Description
To further illustrate the technical means and effects of the present invention adopted to achieve the predetermined objects, the following detailed description will be given to an invoice image recognition method and system based on image processing according to the present invention, and the specific implementation, structure, features and effects thereof with reference to the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" refers to not necessarily the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
The following describes a specific scheme of an invoice image recognition method and system based on image processing in detail with reference to the accompanying drawings.
Example 1:
the main application scenarios of the invention are as follows: the invoice image recognition scene is that the invoice surface image is collected through the camera, the camera adopts the overlooking visual angle, the invoice is kept at a fixed position, the image collection is carried out one by one, and in the image collection process, optical influences such as light reflection and the like caused by a light source do not exist.
Referring to fig. 1, a flowchart of a method for identifying an invoice image based on image processing according to an embodiment of the present invention is shown, where the method includes the following steps:
step one, carrying out subtraction on the machine printing invoice image and the standard invoice template image to obtain a difference image only containing machine printing contents; obtaining edge pixel points in the difference image, and constructing a gradient histogram according to the gradient direction of the edge pixel points; and selecting an edge pixel point in a preset gradient direction as an angular point by using the gradient histogram.
Firstly, all invoice images to be identified are acquired through a camera, and the invoice images are stored through a computer. And then, carrying out graying processing on the invoice image to obtain the invoice image grayscale image. And carrying out noise filtering on the image, wherein the noise filtering is realized by adopting a nonlinear median filter, and finally obtaining the preprocessed image.
It should be noted that the machine-printed content of the machine-printed invoice and the invoice template are fixed, and the range of the corresponding machine-printed characters and the characters of the invoice template is also fixed, so that the difference image is obtained by performing image subtraction on the machine-printed invoice image and the standard invoice template image. The information retained by the difference image is machine-made content information. When the machine printing content has wrinkles and offsets, the machine printing content is offset, but because the standard invoice template image does not include the machine printing content, the difference image still retains the machine printing content information, and the problem that the offset machine printing content is overlapped with the character information in the standard invoice template image is not considered in the embodiment. Meanwhile, the contents of the machine typing include characters such as numbers, Chinese characters, English letters, special symbols and the like.
Further, the angular point detection algorithm is used for carrying out angular point detection on the obtained difference image, and position coordinates of all angular points in all the difference images are obtained. Conventional corner detection algorithms generally include: SIFT corner detection, Harris corner detection, etc. The SIFT corner point detection algorithm is to perform Gaussian convolution through a scale space to obtain extreme points of different scale spaces, and set a threshold value to select key points; and then, constructing description feature vectors of the selected key points in different gradient directions, selecting the key points with rotation invariance, and finally obtaining an SIFT corner point detection result.
However, the SIFT corner detection algorithm is to detect pixel by pixel, and the calculation amount is large, so that the pixel in the local area is generally required to be screened, and the redundant calculation is reduced; meanwhile, 128-dimensional descriptor feature vectors adopted by SIFT corner detection can detect partial redundant corners in a local area, the partial redundant corners can be regarded as pseudo corners, so that the digital identification cannot be greatly influenced, the pseudo corners need to be further screened in combination with the characteristics of the structural features of the contents printed by the printer and the like, the SIFT detection speed and the identification precision are improved, and the structural features of the digital corners are changed due to the fact that partial pseudo corners are possibly caused by inclination and possibly caused by redundant corners.
Therefore, the angular points need to be screened, redundant angular points are removed, the difference image is analyzed integrally to screen the preliminary angular points, and a part of redundant angular points are removed, and the specific process is as follows:
the Canny edge detection algorithm is used for obtaining the position of an edge pixel point in the difference image, and because the scene of the embodiment is a fixed camera position and a fixed parameter, the change of a scale space does not exist. The conventional SIFT corner detection is based on the idea of a conventional algorithm, wherein a circle is divided into 360-degree angular ranges by uniform angles to obtain a preset number of directional ranges, preferably, in this embodiment, every 10 degrees is one directional range, a gradient histogram is constructed, and a main direction analysis is performed by using a peak position of the gradient histogram. However, the main direction of the gradient histogram often represents the gradient direction of most edge pixel points, and the edge pixel points except the corner point pixel points in the part of the edge pixel points contain a large number of redundant edge pixel points. Therefore, in this implementation, edge pixel points in a preset gradient direction are selected as corner points of the character, specifically, edge pixel points in a Top K-th direction range except for the main direction and the auxiliary direction are selected as characterization directions of the corner points, that is, the edge pixel points in the Top K-th direction range are used as the corner points, the Top K-th direction range represents that the number of the edge pixel points corresponding to each direction range in the gradient histogram is arranged from large to small, and the edge pixel points in the K-th direction range are arranged in sequence. The value of K in Top K needs to be adaptively adjusted through the structural characteristics of subsequent corner points, and the preset gradient direction may be set to the direction range corresponding to K = 10. This now obtains the corner points in the difference image.
Finally, most of the invoice machine printing contents are digital characters, the optimal corner positions of the digital characters are generally at corners, and radians generally exist at the corners due to the particularity of machine printing numbers, so that more gradient directions are possible to be included, and a wider range is possible to be distributed on a gradient histogram, so that a large number of redundant edge corners can be filtered by selecting preset gradient directions, namely the Top K =10 direction ranges in the gradient histogram as the representation directions of the corners.
Step two, obtaining gradient complexity according to the number of different gradient directions of the pixel points in the angular point neighborhood range and the variance of the gradient amplitudes of the pixel points in the angular point neighborhood range and the neighborhood range; setting a gradient threshold, wherein an angular point with the gradient complexity greater than the gradient threshold is a first angular point; and carrying out region division on the difference image to obtain a character region, wherein the character region is a minimum circumscribed rectangle of a complete machine-typed character string.
Firstly, in order to further judge redundant pixel points in the corner points obtained in the first step, gradient direction statistics is carried out on pixel points in an 8-neighborhood range of each corner point, the number m of different gradient directions in the 8-neighborhood range of each corner point is obtained, and meanwhile, the gradient amplitude of the pixel points in the 8-neighborhood of each corner point is obtained; calculating the gradient complexity of each corner:
Figure 751812DEST_PATH_IMAGE002
wherein,
Figure 992301DEST_PATH_IMAGE003
representing the gradient complexity of the corner points;
Figure 411781DEST_PATH_IMAGE004
representing the number of different gradient directions of pixel points in the neighborhood range of the angular point 8;
Figure 763128DEST_PATH_IMAGE005
representing the gradient amplitude of the ith pixel point in the neighborhood range of the angular point 8;
Figure 584453DEST_PATH_IMAGE006
representing the average value of the gradient amplitudes of the pixel points in the neighborhood range of the angular point 8;
Figure 730264DEST_PATH_IMAGE007
8 pixel points representing the range of the neighborhood of the corner 8. And normalizing the gradient complexity of the corner points.
Further, a gradient threshold is set
Figure 637040DEST_PATH_IMAGE018
When the gradient complexity of a corner is greater than the gradient threshold, the corner is reserved, when the gradient complexity is less than the gradient threshold, the corner is removed, and the reserved corner is marked as a first corner.
And finally, carrying out region division on the difference image to obtain a plurality of character regions, wherein each character region comprises a machine-typed complete character string, one machine-typed complete character string represents a character string representing the same meaning in the invoice, for example, the printing date of the invoice is a complete character string, and obtaining a minimum circumscribed rectangle of each complete character string according to the uppermost and lowermost first corner points of each character in each complete character string in the difference image and the leftmost and rightmost first corner points in the complete character string, and the minimum circumscribed rectangle is a character region.
Step three, obtaining an angular point positioned at the upper left corner in first angular points in the character area as an initial angular point of a first character in the character area, and obtaining structural parameters based on the offset distance in the horizontal direction, the offset distance in the vertical direction and the offset angle of the initial angular point and the first angular point which is most adjacent to the initial angular point; setting a structural threshold value, and rejecting the nearest first corner with the structural parameter smaller than the structural threshold value, wherein the process is a corner rejection process; if the first corner point which is closest to the initial corner point is removed, obtaining a first corner point which is second adjacent to the initial corner point, and carrying out a corner point removing process; and segmenting the characters according to the coordinates of the structural corner points belonging to each character in the character area, and identifying the segmented characters.
Firstly, after each character area is obtained, each character needs to be analyzed in each character area to obtain the corner points capable of representing each character in all the first corner points. Obtaining a first corner point of the character area, which is positioned at the upper left corner, and marking the corner point as an initial corner point of a first character in the character area; meanwhile, a rectangular coordinate system is established in the difference image, and the rectangular coordinate system rotates upwards and downwards respectively by taking the x-axis direction as the central direction
Figure 526499DEST_PATH_IMAGE008
The resulting range of angles; rotate left and right respectively with the y-axis direction as the center direction
Figure 467910DEST_PATH_IMAGE008
Obtaining an angular range; and combining the two angle ranges to obtain an angle area, obtaining a first angular point in the angle area, and recording as the angular point to be eliminated.
Removing the first corner points to be removed by utilizing the relation between the initial corner point of the first character and the corner points to be removed, obtaining the corner points capable of representing the first character, obtaining the coordinates of the first corner point a closest to the initial corner point of the first character, and calculating the structural parameters of the initial corner point and the first corner point a closest to the initial corner point of the first character:
Figure 846938DEST_PATH_IMAGE010
establishing a rectangular coordinate system in the difference image;
Figure 241011DEST_PATH_IMAGE011
representing a structural parameter;
Figure 934160DEST_PATH_IMAGE012
represents the distance between the starting corner point and the first corner point which is most adjacent to the starting corner point in the x-axis direction, namely the horizontal direction, and is an offset distance;
Figure 198919DEST_PATH_IMAGE013
the distance between the starting angular point and the nearest first angular point in the y-axis direction, namely the vertical direction, is represented as an offset distance;
Figure 952112DEST_PATH_IMAGE014
indicating the width of the typewritten character in the horizontal direction of the character when the character is not shifted;
Figure 833480DEST_PATH_IMAGE015
indicating the height of the typewritten character in the vertical direction of the character when the character is not shifted;
Figure 127058DEST_PATH_IMAGE016
representing the offset angle between the starting corner point and its nearest neighboring corner point
Figure 777482DEST_PATH_IMAGE016
Taking the positive direction of the x-axis as the initial
Figure 438927DEST_PATH_IMAGE017
And counterclockwise rotation defines the magnitude of the angle. While the structural parameters are normalized.
Further, setting a structural threshold
Figure DEST_PATH_IMAGE019
The process of eliminating the first corner point from the corner points to be eliminated is an iterative process, which specifically comprises the following steps:if the structural parameters are smaller than the structural threshold, the nearest first corner point a is removed, if the structural parameters are larger than the structural threshold, the nearest first corner point a is reserved as the structural corner point of the first character, and the process is a corner point removing process; and when the first corner a which is the nearest neighbor is removed, obtaining a first corner b which is second neighbor to the initial corner, performing a corner removing process on the initial corner and the first corner b which is second neighbor, judging whether the first corner b which is second neighbor needs to be removed, and if so, continuously searching a first corner c which is third neighbor to the initial corner to perform the corner removing process.
Meanwhile, when the structural parameter is greater than the structural threshold value, the most adjacent first corner point a is reserved as the structural corner point of the first character, the most adjacent first corner point A of the most adjacent first corner point a is obtained, a corner point removing process is carried out on the two corner points, and whether the most adjacent first corner point A of the most adjacent first corner point a needs to be removed or not is judged; if the nearest first corner point a of the nearest first corner point a remains, the nearest first corner point B of the nearest first corner point a is obtained, and a corner point elimination process is performed on the two corner points to determine whether the nearest first corner point B of the nearest first corner point a needs to be eliminated.
After the above process is completed, obtaining a structural corner point of the first character, and reserving the structural corner point as an adjacent first corner point with a larger distance offset or angle offset from the position of the initial corner point; the structural corners of the first character can represent information of the first character, but structural corners which do not belong to the first character exist in the structural corners, and further the structural corners of the first character need to be found out for obtaining structural corners of a second character later. Connecting every two structural nodes of the first character by straight lines, and if the straight line corresponding to one structural corner point does not have a straight line intersected with the first character, not belonging the structural corner point of the first character; and obtaining the structural corner points which do not belong to the first character for judging the structural corner points of the second character. Similarly, after the structural corner point of the second character is obtained, the structural corner points are connected in pairs for judgment, and the structural corner point which does not belong to the second character is obtained for judgment of the structural corner point of the third character.
When the structure of the first character is judged, the finishing condition is that the first corner points meeting the condition do not appear any more, the screening of the structure corner points of the first character is finished at the moment, and then the judgment is carried out by connecting the structure corner points pairwise. It should be noted that, when the structural corner point of the second character is obtained, an initial corner point corresponding to the second character is still needed, and at this time, because the structural corner point of the first character is already obtained, the first corner point of the upper left corner of the second character adjacent to the structural corner point of the first character is used as the initial corner point of the second character to screen the structural corner points of the second character; for a character region, the structure corner points of all characters in the character region need to be screened out.
The structural corner points of the typed characters in all the character areas are obtained.
In addition, for the preset gradient direction in the first step, that is, the TOP K gradient directions in the gradient histogram, the K value may be continuously optimized and updated along with the identification process of the invoice image, data statistics is performed to obtain the structure corner points of each character of the multiple difference images in each character region, and the gradient direction in which the occurrence frequency of the character structure corner points of the machine printing is the largest is selected as the value of K in the TOP K.
And finally, after obtaining the structural corner point of each character, obtaining the size of a self-adaptive window of each character by using the coordinates of the structural corner point of each character, specifically, selecting all the structural corner points in each character to construct a maximum rectangular frame as the size of the self-adaptive window, setting the self-adaptive window to slide, dividing a character area, identifying the character according to the divided image to obtain the semantic features of each character, wherein the character identification can be realized by a character identification neural network, and the character identification network is the prior art and is not described in more detail herein, such as a CNN network.
Example 2:
the embodiment provides an invoice image recognition system embodiment based on image processing, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the computer program is used for realizing the steps of a scrap steel crushing stock ground inventory method when being executed by the processor. Since embodiment 1 has already described a detailed description of an invoice recognition method based on image processing, it will not be described more here.
It should be noted that: the precedence order of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
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.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. An invoice image recognition method based on image processing is characterized by comprising the following steps: performing subtraction on the machine-printed invoice image and the standard invoice template image to obtain a difference image only containing machine-printed contents; obtaining edge pixel points in the difference image, and constructing a gradient histogram according to the gradient direction of the edge pixel points; selecting an edge pixel point in a preset gradient direction as an angular point by using the gradient histogram;
obtaining gradient complexity according to the number of different gradient directions of the pixel points in the angular point neighborhood range and the variance of the gradient amplitudes of the pixel points in the angular point neighborhood range and the neighborhood range; setting a gradient threshold, wherein an angular point with the gradient complexity greater than the gradient threshold is a first angular point; carrying out region division on the difference image to obtain a character region, wherein the character region is a minimum external rectangle of a complete machine-typed character string;
obtaining a corner point positioned at the upper left corner in first corner points in the character area as an initial corner point of a first character in the character area, and obtaining structural parameters based on the offset distance in the horizontal direction, the offset distance in the vertical direction and the offset angle of the initial corner point and the first corner point which is most adjacent to the initial corner point; setting a structural threshold value, and removing the nearest first corner point with the structural parameter smaller than the structural threshold value, wherein the process is a corner point removing process; if the first corner point which is closest to the initial corner point is removed, obtaining a first corner point which is second adjacent to the initial corner point, and carrying out a corner point removing process; and segmenting the characters according to the coordinates of the structural corner points belonging to each character in the character area, and identifying the segmented characters.
2. The method for image recognition of an invoice based on image processing as claimed in claim 1, wherein said constructing a gradient histogram according to gradient direction of edge pixel points comprises: and uniformly dividing 360 degrees into direction ranges with preset quantity, and counting the number of edge pixel points belonging to each direction range to construct a gradient gray level histogram.
3. The invoice image recognition method based on image processing as claimed in claim 1, wherein the gradient complexity is:
Figure 909139DEST_PATH_IMAGE002
wherein,
Figure DEST_PATH_IMAGE003
representing the gradient complexity of the corner points;
Figure 710873DEST_PATH_IMAGE004
representing the number of different gradient directions of pixel points in the neighborhood range of the angular point 8;
Figure DEST_PATH_IMAGE005
representing the gradient amplitude of the ith pixel point in the neighborhood range of the angular point 8;
Figure 164726DEST_PATH_IMAGE006
representing the average value of the gradient amplitudes of the pixel points in the neighborhood range of the angular point 8;
Figure DEST_PATH_IMAGE007
8 pixel points representing the range of the neighborhood of the corner 8.
4. The invoice image recognition method based on image processing as claimed in claim 1, wherein the region division of the difference image to obtain the character region comprises: and obtaining a minimum circumscribed rectangle of each complete character string according to the first corner point of the top and the bottom of each character in each complete character string in the difference image and the first corner points of the left and the right of the complete character string, wherein the minimum circumscribed rectangle is a character area.
5. The invoice image recognition method based on image processing as claimed in claim 1,the method is characterized by further comprising the following steps before the structural parameters are obtained: a rectangular coordinate system is established in the difference image, and the rectangular coordinate system rotates upwards and downwards respectively by taking the x-axis direction as the central direction
Figure 502035DEST_PATH_IMAGE008
The resulting range of angles; rotate left and right respectively with the y-axis direction as the center direction
Figure 706751DEST_PATH_IMAGE008
Obtaining an angular range; and combining the two angle ranges to obtain an angle area, obtaining a first angular point in the angle area, and recording as the angular point to be eliminated.
6. The image recognition method for invoices based on image processing as claimed in claim 1, wherein the structural parameters are:
Figure 436810DEST_PATH_IMAGE010
establishing a rectangular coordinate system in the difference image;
Figure DEST_PATH_IMAGE011
representing a structural parameter;
Figure 449897DEST_PATH_IMAGE012
the distance between the starting corner point and the first corner point which is most adjacent to the starting corner point in the x-axis direction, namely the horizontal direction, is represented as an offset distance;
Figure DEST_PATH_IMAGE013
the distance between the starting angular point and the nearest first angular point in the y-axis direction, namely the vertical direction, is represented as an offset distance;
Figure 811302DEST_PATH_IMAGE014
to representThe width of the typed character in the horizontal direction of the character when the character is not deviated;
Figure DEST_PATH_IMAGE015
indicating the height of the typewritten character in the vertical direction of the character when the character is not shifted;
Figure 503315DEST_PATH_IMAGE016
representing the offset angle between the starting corner point and its nearest neighboring corner point
Figure 37064DEST_PATH_IMAGE016
Taking the positive direction of the x-axis as the initial
Figure DEST_PATH_IMAGE017
And counterclockwise rotation defines the magnitude of the angle.
7. The image recognition method for invoices based on image processing as claimed in claim 1, wherein the obtaining the structural corner point of the first character comprises: obtaining an initial corner point of a first character in the character area, calculating a structural parameter between the initial corner point and a first corner point which is most adjacent to the initial corner point, if the structural parameter is smaller than a structural threshold value, rejecting the first corner point which is most adjacent to the initial corner point, obtaining the structural parameter between the initial corner point and a second adjacent first corner point, and if the structural parameter is smaller than the structural threshold value, rejecting the second adjacent first corner point;
if the structural parameter is greater than the structural threshold value, reserving a second adjacent first corner point, calculating the structural parameter between a first corner point which is most adjacent to the second adjacent first corner point and the second adjacent first corner point, and if the structural parameter is greater than the structural threshold value, reserving the first corner point which is most adjacent to the second adjacent first corner point;
if the structural parameters between the starting corner point and the first corner point closest to the starting corner point are larger than the structural threshold value, the first corner point closest to the starting corner point is reserved, the structural parameters between the first corner point closest to the starting corner point and the first corner point closest to the starting corner point are calculated, if the structural parameters are larger than the structural threshold value, the first corner point closest to the starting corner point is reserved, and the removed first corner points are all the corner points in the corner points to be removed.
8. The image recognition method for invoices based on image processing as claimed in claim 1, further comprising after said obtaining the structural corner point of the first character: connecting every two structural angular points of the first character by using straight lines, wherein if a straight line which is intersected with the first character does not exist in a straight line corresponding to one structural angular point, the structural angular point does not belong to the structural angular point of the first character; and obtaining the structural corner points which do not belong to the first character for judging the structural corner points of the second character.
9. The invoice image recognition method based on image processing as claimed in claim 1, wherein the character is segmented according to the coordinates of the structure corner points belonging to each character in the character area, and the recognition of the segmented character comprises: obtaining the minimum circumscribed rectangle of each character according to the coordinates of the structure corner points of each character in one character area, and completing the segmentation of each character in one character area; and recognizing the segmented characters by utilizing a neural network based on the semantic features of the characters.
10. An image processing based invoice image recognition system comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterised in that the computer program, when executed by the processor, implements the steps of an image processing based invoice image recognition method as claimed in any one of claims 1 to 9.
CN202210603229.9A 2022-05-31 2022-05-31 Invoice image recognition method and system based on image processing Active CN114694162B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210603229.9A CN114694162B (en) 2022-05-31 2022-05-31 Invoice image recognition method and system based on image processing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210603229.9A CN114694162B (en) 2022-05-31 2022-05-31 Invoice image recognition method and system based on image processing

Publications (2)

Publication Number Publication Date
CN114694162A CN114694162A (en) 2022-07-01
CN114694162B true CN114694162B (en) 2022-08-16

Family

ID=82130951

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210603229.9A Active CN114694162B (en) 2022-05-31 2022-05-31 Invoice image recognition method and system based on image processing

Country Status (1)

Country Link
CN (1) CN114694162B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117252886A (en) * 2023-09-11 2023-12-19 广东源恒软件科技有限公司 Invoice identification method and system based on image segmentation

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103049750B (en) * 2013-01-11 2016-06-15 广州广电运通金融电子股份有限公司 Character identifying method
US9786039B2 (en) * 2016-01-26 2017-10-10 Wipro Limited Method and system for processing an image extracted from a document
CN111444948B (en) * 2020-03-21 2022-11-18 哈尔滨工程大学 Image feature extraction and matching method
CN114120051B (en) * 2021-11-11 2024-06-04 易思维(杭州)科技股份有限公司 Method for screening edge points of adhesive tapes

Also Published As

Publication number Publication date
CN114694162A (en) 2022-07-01

Similar Documents

Publication Publication Date Title
CN107609549B (en) Text detection method for certificate image in natural scene
CN112686812B (en) Bank card inclination correction detection method and device, readable storage medium and terminal
US9158986B2 (en) Character segmentation device and character segmentation method
CN112183038A (en) Form identification and typing method, computer equipment and computer readable storage medium
CN110298376B (en) Bank bill image classification method based on improved B-CNN
CN111832659B (en) Laser marking system and method based on feature point extraction algorithm detection
CN111353961B (en) Document curved surface correction method and device
CN110647882A (en) Image correction method, device, equipment and storage medium
CN116071763B (en) Teaching book intelligent correction system based on character recognition
CN110598566A (en) Image processing method, device, terminal and computer readable storage medium
CN112507782A (en) Text image recognition method and device
CN114694162B (en) Invoice image recognition method and system based on image processing
CN113971792A (en) Character recognition method, device, equipment and storage medium for traffic sign board
CN108256518B (en) Character area detection method and device
CN109753981B (en) Image recognition method and device
CN112699704B (en) Method, device, equipment and storage device for detecting bar code
CN114140794A (en) General image correction method based on OCR
CN117612179A (en) Method and device for recognizing characters in image, electronic equipment and storage medium
CN112418210B (en) Intelligent classification method for tower inspection information
CN113537216B (en) Dot matrix font text line inclination correction method and device
Bhaskar et al. Implementing optical character recognition on the android operating system for business cards
Jia et al. Grayscale-projection based optimal character segmentation for camera-captured faint text recognition
Lu et al. Directed assistance for ink-bleed reduction in old documents
CN114332108B (en) Method for extracting virtual-real line local area in picture
Martyshkin et al. Research of the Handwriting Recognition Methods

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