CN109598271B - Character segmentation method and device - Google Patents
Character segmentation method and device Download PDFInfo
- Publication number
- CN109598271B CN109598271B CN201811504027.9A CN201811504027A CN109598271B CN 109598271 B CN109598271 B CN 109598271B CN 201811504027 A CN201811504027 A CN 201811504027A CN 109598271 B CN109598271 B CN 109598271B
- Authority
- CN
- China
- Prior art keywords
- character
- image
- array
- area
- segmentation
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V30/00—Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
- G06V30/10—Character recognition
- G06V30/14—Image acquisition
- G06V30/148—Segmentation of character regions
- G06V30/153—Segmentation of character regions using recognition of characters or words
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/22—Matching criteria, e.g. proximity measures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/11—Region-based segmentation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/20—Image preprocessing
- G06V10/30—Noise filtering
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
- G06V10/44—Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Multimedia (AREA)
- Data Mining & Analysis (AREA)
- Bioinformatics & Computational Biology (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Evolutionary Biology (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- General Engineering & Computer Science (AREA)
- Life Sciences & Earth Sciences (AREA)
- Character Input (AREA)
Abstract
The application discloses a character segmentation method, which comprises the following steps: acquiring a character area image, and generating a gray scale image corresponding to the character area image, wherein the character area image is an image corresponding to a character area in a printing card; processing the gray level image based on a canny edge detection algorithm to obtain a binary image; projecting the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array; performing linear transformation on the statistical array to normalize elements in the statistical array; and matching the normalized statistical array with a preset multi-character template array, and performing character segmentation according to a matching result to obtain a single-character rectangular string. The method adopts the canny edge detection algorithm to process the gray level image of the character area, can overcome the interference of background color blocks, and adopts the elastic template to match, thereby improving the character segmentation precision. The application also discloses a character segmentation device.
Description
Technical Field
The present application relates to the field of image processing, and in particular, to a method and an apparatus for character segmentation.
Background
With the development of science and technology, printed bank cards gradually become a bank card type with wider application. In some cases, the characters on the bank card are automatically identified, so that the situation that a user manually inputs the card number, the verification code and the like of the bank card can be avoided, on one hand, the situation that the input information is wrong due to human errors can be avoided, the accuracy of the input information is improved, on the other hand, the user operation is simplified, and the user experience is provided.
In order to identify the characters on the bank card, the characters on the bank card need to be segmented first. Currently, a method for segmenting a character based on morphological gradient is provided in the industry. For a printed bank card, the background of the printed bank card is usually various color blocks, and when the character edge features are acquired by adopting morphological gradients, the color blocks are easily interfered, so that a large error occurs during template matching, and further the segmentation is inaccurate.
Therefore, it is desirable to provide a character segmentation method for a printed bank card to solve the technical problem of inaccurate segmentation caused by segmenting characters based on morphological gradients.
Disclosure of Invention
In view of this, the present application provides a character segmentation method, which uses a canny edge detection algorithm to process a gray level map of a character region, and can overcome the interference of background color blocks, and uses an elastic template for matching, thereby improving the character segmentation precision. Correspondingly, the application also provides a character segmentation device.
A first aspect of the present application provides a character segmentation method, including:
acquiring a character area image, and generating a gray scale image corresponding to the character area image, wherein the character area image is an image corresponding to a character area in a printing card;
processing the gray level image based on a canny edge detection algorithm to obtain a binary image;
projecting the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array;
performing linear transformation on the statistical array to normalize elements in the statistical array;
and matching the normalized statistical array with a preset multi-character template array, and segmenting the character region image according to a matching result to obtain a single-character rectangular string, wherein the single-character rectangular string comprises a rectangular region corresponding to each character in the character region.
Optionally, the multi-character template array includes a template array corresponding to at least one character combination, and the length of the multi-character template array is determined according to the number of character groups in the character combination, the number of characters, the character width, and the proportionality coefficient between the group interval and the character width.
Optionally, the printed card comprises a printed bank card; the character area comprises any one or more of a bank card number area, a verification code area or a validity period area.
Optionally, before the processing the gray scale map based on the canny edge detection algorithm, the method further includes:
and carrying out Gaussian noise reduction on the gray-scale image.
Optionally, the processing the gray scale map based on the canny edge detection algorithm to obtain a binary map includes:
calculating gradient amplitude values by utilizing first-order partial derivative finite difference aiming at the gray-scale map;
and carrying out maximum suppression processing according to the gradient amplitude to obtain a binary image.
Optionally, before projecting the binarized map along a direction perpendicular to a preset segmentation direction, the method further includes:
and performing closed operation processing on the binary image according to a dual-threshold algorithm so as to close the image edge in the binary image.
A second aspect of the present application provides a character segmentation apparatus, the apparatus comprising:
the generating module is used for acquiring a character area image and generating a gray scale image corresponding to the character area image, wherein the character area image is an image corresponding to a character area in a printing card;
the edge detection module is used for processing the gray level image based on a canny edge detection algorithm to obtain a binary image;
the projection module is used for projecting the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array;
the transformation module is used for carrying out linear transformation on the statistical array so as to normalize elements in the statistical array;
and the segmentation module is used for matching the normalized statistical array with a preset multi-character template array, and segmenting the character image according to a matching result to obtain a single-character rectangular string, wherein the single-character rectangular string comprises a rectangular region corresponding to each character in the character region.
Optionally, the multi-character template array includes a template array corresponding to at least one character combination, and the length of the multi-character template array is determined according to the number of character groups in the character combination, the number of characters, the character width, and the proportionality coefficient between the group interval and the character width.
Optionally, the printed card comprises a printed bank card; the character area comprises any one or more of a bank card number area, a verification code area or a validity period area.
Optionally, the apparatus further comprises:
and the noise reduction module is used for carrying out Gaussian noise reduction on the gray-scale image before the processing of the gray-scale image based on the canny edge detection algorithm.
Optionally, the edge detection module is specifically configured to:
calculating gradient amplitude values by utilizing first-order partial derivative finite difference aiming at the gray-scale map;
carrying out maximum suppression processing according to the gradient amplitude to obtain a binary image
Optionally, the apparatus further comprises:
and the operation module is used for performing closed operation processing on the binary image according to a dual-threshold algorithm before the binary image is projected in a direction vertical to a preset segmentation direction so as to close the image edge in the binary image.
According to the technical scheme, the embodiment of the application has the following advantages:
the embodiment of the application provides a character segmentation method, firstly obtains the character region image, and the character region image specifically refers to the image that the character region corresponds in the printing card, then generates the grey map that the character region image corresponds, then, it is right based on canny edge detection algorithm the grey map is handled and is obtained the binary map, will the projection of binary map along the direction perpendicular with preset segmentation direction obtains the statistics array, and is right again statistics array carries out linear transformation, makes the element normalization in the statistics array, matches the statistics array after the normalization with preset multi-character template array, cuts apart the character region image according to the matching result and obtains single character rectangular string, single character rectangular string includes the rectangular region that every character in the character region corresponds. The method adopts the canny edge detection algorithm to process the gray level image of the character area, can overcome the interference of background color blocks, and adopts the elastic template to match, thereby improving the character segmentation precision.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a scene architecture diagram of a character segmentation method in an embodiment of the present application;
FIG. 2 is a flowchart illustrating a character segmentation method according to an embodiment of the present disclosure;
FIG. 3A is a diagram illustrating the result of template matching using morphological gradient to obtain edge features in the present embodiment;
FIG. 3B is a diagram illustrating the result of template matching using canny edge detection to obtain edge features in the present embodiment;
FIG. 4 is a schematic structural diagram of a character segmentation apparatus according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, 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 application.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims of the present application and in the drawings described above, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The method comprises the steps of firstly, obtaining a character area image, wherein the character area image is specifically an image corresponding to a character area in a printing card, then generating a gray scale image corresponding to the character area image, then processing the gray scale image based on a canny edge detection algorithm to obtain a binary image, projecting the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array, then carrying out linear transformation on the statistical array to normalize elements in the statistical array, matching the normalized statistical array with a preset multi-character template array, and segmenting the character area image according to a matching result to obtain a single-character rectangular string, the single character rectangular string includes a rectangular region corresponding to each character in the character region.
The method adopts a canny edge detection algorithm to process the gray level image of the character region, can overcome the interference of background color blocks, adopts an elastic template to carry out matching, and adopts the elastic template to carry out matching, wherein the elastic template comprises templates formed by combining characters in different styles and different classes, and the character region image is segmented according to the matching result with higher matching degree by comparing the matching results corresponding to the templates in different styles and different classes, so that the character segmentation precision can be improved.
It will be appreciated that the method can be applied to any data processing apparatus having image processing capabilities. The data processing device may be a terminal or a server, where the terminal may be any user device now known, developing or later developed that is capable of interacting via any form of wired and/or wireless connection (e.g., Wi-Fi, LAN, cellular, coaxial cable, etc.), including but not limited to: existing, developing or future developing smartphones, tablet computers, laptop personal computers, desktop personal computers, etc., the server is a device that provides computing services. In this embodiment, the data processing devices may be independent, or may be a cluster formed by a plurality of data processing devices.
In specific implementation, the character segmentation method provided by the application is stored in the data processing device in the form of an application program, and the data processing device executes the application program to implement the character segmentation method provided by the application. The application program may be a stand-alone application program, or may be a functional module, a plug-in, an applet, and the like, which are integrated with other application programs.
For convenience of description, the server is taken as an example hereinafter to describe the character segmentation method provided in the present application. The following describes a character segmentation method provided in the embodiment of the present application with reference to a specific scenario.
Referring to a scene architecture diagram of the character segmentation method shown in fig. 1, the application scene includes a server 10 and a terminal 20, the terminal 20 scans a printed card to generate an image of the printed card, and then uploads the image of the printed card to the server 10, the server 10 can obtain a character area image from the image of the printed card and convert the character area image into a gray scale image, then, the gray scale image is processed based on a canny edge detection algorithm to obtain a binary image, and then, the binary image is projected along a direction perpendicular to a preset segmentation direction to obtain a statistical array; performing linear transformation on the statistical array to normalize elements in the statistical array; and matching the normalized statistical array with a preset multi-character template array, and segmenting the character region image according to a matching result to obtain a single-character rectangular string, wherein the single-character rectangular string comprises a rectangular region corresponding to each character in the character region, so that the character segmentation of the character region is realized, and the segmentation precision is high.
In order to make the technical solution of the present application clearer and easier to understand, the following describes a character segmentation method provided in the embodiments of the present application with reference to the drawings.
Referring to a flow chart of a character segmentation method shown in fig. 2, the method is applied to a server and comprises the following steps:
s201, acquiring a character area image and generating a gray scale image corresponding to the character area image.
And the character area image is an image corresponding to the character area in the printed card. The printed card refers to a card manufactured in a printing manner, and in some possible implementation manners, the printed card may be a bank card manufactured in a printing manner, that is, a printed bank card, and may also be a certificate such as an identity card manufactured in a printing manner. For convenience of understanding, the character area image will be described hereinafter by taking a bank card as an example. Aiming at the printed bank card, the character area comprises a bank card number area, a verification code area or a valid period area, the embodiment of the application can execute character segmentation on any one or more character areas to realize character recognition.
Because the colors of the character areas of the printed cards are generally different from the colors of other areas, such as the printed bank cards, the server can convert the images into gray-scale images or binary images, determine the character areas of the printed bank card images based on the difference of color blocks in the gray-scale images or the binary images, and further obtain the character area images. After the character area image is obtained, the server obtains pixel values of different channels of each pixel point in the character area image, processes the character area image based on the pixel values, and generates a corresponding gray-scale image.
The server may generate the grayscale map in a variety of implementations. For example, the server may determine the gray value of each pixel point based on any one of floating point algorithm, integer method, shift method, average value method, and method of taking only green, and replace the pixel value of three channels red, green, and blue in the pixel point with the gray value, thereby obtaining a gray map.
S202: and processing the gray level image based on a canny edge detection algorithm to obtain a binary image.
Image edge information is mainly concentrated in the high frequency band, so edge detection is essentially high frequency filtering. Wherein differentiating the signal enhances the high frequency components, the signal of the digital image being a discrete signal, and thus differentiating it is a calculation of the difference or gradient. The Canny edge detection algorithm is implemented by solving the gradient.
The processing of the gray scale map based on the canny edge detection algorithm may specifically include the following steps:
in the first step, the gradient amplitude is calculated by using the first-order finite difference of partial derivatives.
And secondly, performing non-maximum suppression processing according to the gradient amplitude to obtain a binary image.
For the first step, the gradient of the gray value of the image can be approximated by a first-order finite difference, and in specific implementation, a first-order partial derivative matrix, a gradient magnitude matrix and a gradient direction matrix of the gray image in the x and y directions can be obtained through calculation of a convolution operator.
And aiming at the second step, if the element value in the gradient amplitude matrix is larger, the gradient value of the point in the gray scale image is larger, the point with non-maximum value is restrained, specifically, the local maximum value of the pixel point is searched, the gray scale value corresponding to the point with non-maximum value is set as 0, and thus, most of the points with non-edge can be eliminated. Since the gradation value corresponding to the non-maximum value point is 0, the image after the non-maximum value suppression processing is a binarized map.
It should be noted that, noise often exists in an image, and noise is concentrated in a high frequency band and is easily recognized as a false edge, so that the server performs gaussian noise reduction on the gray-scale image by using a filter before performing edge detection based on the canny edge detection algorithm, so that the noise in the gray-scale image can be filtered, the influence of the noise on gradient calculation is reduced, and the probability that the noise is recognized as a false edge is reduced. When high-speed noise reduction is carried out, the server selects a proper radius according to the requirement, and the weak edge is prevented from being difficult to detect due to the fact that the radius is too large.
After the non-maximum value is suppressed, the edge of the image can be obtained, and the server can also perform closed operation processing on the binary image in order to close the edge. In particular implementations, the server may detect and connect edges through a dual threshold algorithm, such that the image edges are closed. The dual threshold algorithm sets a high threshold by which false edges in the image can be reduced and a low threshold by which edges in the image can be closed. Specifically, the server links the edges into the contour in the high threshold, when the breakpoint of the contour is reached, the algorithm searches for a point satisfying the low threshold in 8 neighborhood points of the breakpoint, and then collects new edges according to the point until the edge of the whole image is closed.
S203: and projecting the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array.
The preset dividing direction refers to a preset image dividing direction. Specifically, the preset dividing direction may be determined based on a direction in which characters are displayed in the character region image, which may specifically be the same direction as the direction in which the characters are displayed. For example, if the direction of character display is horizontal, the preset division direction is horizontal, and if the direction of character display is vertical, the preset division direction may be vertical.
After canny edge detection is carried out, the server projects the binary image along the direction vertical to the preset segmentation direction to obtain a statistical array. Specifically, the binary image is a two-dimensional image, and for convenience of subsequent character segmentation, the binary image may be converted into a one-dimensional statistical array in a manner of projecting in a direction perpendicular to a preset segmentation direction.
The projection process is described below with reference to specific examples. For example, the size of the binarized map is 428 × 27, that is, the binarized map has 428 pixels in the horizontal direction and 27 pixels in the vertical direction, and the gray value of each pixel is 0 or 1, and the display direction of the character in the binarized map is the horizontal direction, so that the preset dividing direction is the horizontal direction, and the binarized map is projected in the vertical direction, that is, the vertical direction, which is the direction perpendicular to the preset dividing direction, that is, the gray values of the pixels in the vertical direction are accumulated, and thus, a statistical array of length 428 may be formed, which is denoted as [0, 427 ]. The element value corresponding to the element in the array is the gray level accumulated value of the corresponding row of pixels in the vertical direction, for example, a row of pixels in the binary image includes 15 pixels with gray level value 1 and 12 pixels with gray level value 0, and the gray level accumulation result is 15, so the element value corresponding to the row of elements in the array is 15.
S204: and performing linear transformation on the statistical array so as to normalize elements in the statistical array.
The server performs linear transformation on the statistical array, specifically, the server sums up the element values of each element in the statistical array to obtain an element value sum, and then divides each element by the element value sum as the element value of each element, so that the sum of the element values of each element in the statistical array is one, and the element normalization in the statistical array is realized.
S205: and matching the normalized statistical array with a preset multi-character template array, and segmenting the character region image according to a matching result to obtain a single-character rectangular string.
Wherein the single character rectangular string includes a rectangular region corresponding to each character in the character region. The character area image is divided into rectangular strings formed by a plurality of rectangular areas, wherein each rectangular area corresponds to one character, and thus character segmentation is realized.
In this embodiment, the server matches the statistical array with a preset multi-character template array, marks the segmentation position according to the matching result, and then segments the character region image based on the marked segmentation position, so as to obtain a single-character rectangular string. The multi-character template array comprises a template array corresponding to at least one character combination, and the length of the multi-character template array is determined according to the number of character groups in the character combination, the number of characters, the width of the characters and the proportion coefficient of the group spacing to the width of the characters. Because the character combinations in the character area have diversity, template arrays corresponding to various character combinations are preset for matching, so that the matching accuracy can be improved, and the character segmentation accuracy is improved.
The template matching will be described in detail below in connection with a printed bank card.
For printed bank cards, the character area may have a variety of formats. Specifically, the character area may include a bank card number area, and bank cards issued by different banks may be 16-digit or 19-digit. The 16-bit bank card number is generally divided into 4 groups, each group has 4 characters, each group has a certain interval, the corresponding template array can be marked as group ═ 1,1,1,1,0,1,1,1,1,0,1,1,1, based on which the length len ═ ch _ width 16+3 × -coef _ ch _ width of the multi-character template array corresponding to the 16-bit bank card number, wherein ch _ width represents the character width, and coef represents the proportionality coefficient of the group spacing and the character width. The 19 is that the bank card number is divided into 2 groups, one group is 6 characters, one group is 13 characters, the corresponding template array can be marked as group ═ 1,1,1,1,1,0,1,1,1,11,1,1,1,1,1,1,1,1, and based on this, 19 is the length len ═ ch _ width 19+1 ═ coef _ ch _ width of the multi-character template array corresponding to the bank card number.
The server can match the statistical array with a multi-character template array corresponding to the 16-bit bank card number and a multi-character template array corresponding to the 19-bit bank card number in sequence. When the statistical array is matched with any multi-character template group, the statistical array can be gradually matched according to the grouping condition of the multi-character template array. Taking 16 as an example of a multi-character template array corresponding to a bank card number, the statistical array may be matched with array elements corresponding to a first group of characters in the multi-character template array, and when a result is matched, the array elements corresponding to a second group of characters are continuously matched; if the results do not match, the statistical array can be directly matched with another multi-character template array.
Fig. 3A and 3B respectively show a template matching result diagram after the edge feature is acquired by using the morphological gradient, and a template matching result diagram after the edge feature is acquired by using canny edge detection. As shown in fig. 3A, due to interference of background color blocks, the obtained edge features are inaccurate, which causes errors when template array matching is performed, thus resulting in low accuracy of character segmentation, while in fig. 3B, the canny edge detection algorithm can overcome the interference of background color blocks, and obtain more accurate edge features, so that the accuracy is higher when template array matching is performed, and the accuracy is higher when characters are segmented.
According to the character segmentation method, firstly, a character region image is obtained, the character region image specifically refers to an image corresponding to a character region in a printed card, then a gray scale image corresponding to the character region image is generated, then the gray scale image is processed based on a canny edge detection algorithm to obtain a binary image, the binary image is projected along a direction perpendicular to a preset segmentation direction to obtain a statistical array, then the statistical array is subjected to linear transformation, so that elements in the statistical array are normalized, the normalized statistical array is matched with a preset multi-character template array, and the character region image is segmented according to a matching result to obtain a single-character rectangular string. The method adopts the canny edge detection algorithm to process the gray level image of the character area, can overcome the interference of background color blocks, and adopts the elastic template to match, thereby improving the character segmentation precision.
The foregoing is a specific implementation manner of the character segmentation method provided in the embodiments of the present application, and based on this, the embodiments of the present application further provide a corresponding character segmentation device. Next, the character segmentation apparatus provided in the embodiment of the present application will be described from the viewpoint of functional modularization.
Referring to fig. 4, the device for dividing characters includes:
the generating module 410 is configured to obtain a character area image, and generate a grayscale map corresponding to the character area image, where the character area image is an image corresponding to a character area in a printed card;
the edge detection module 420 is used for processing the gray level map based on a canny edge detection algorithm to obtain a binary map;
the projection module 430 is configured to project the binarized map in a direction perpendicular to a preset segmentation direction to obtain a statistical array;
a transformation module 440, configured to perform linear transformation on the statistical array, so that elements in the statistical array are normalized;
the dividing module 450 is configured to match the normalized statistical array with a preset multi-character template array, and divide the character region image according to a matching result to obtain a single-character rectangular string, where the single-character rectangular string includes a rectangular region corresponding to each character in the character region.
Optionally, the multi-character template array includes a template array corresponding to at least one character combination, and the length of the multi-character template array is determined according to the number of character groups in the character combination, the number of characters, the character width, and the proportionality coefficient between the group interval and the character width.
Optionally, the printed card comprises a printed bank card; the character area comprises any one or more of a bank card number area, a verification code area or a validity period area.
Optionally, the apparatus further comprises:
and the noise reduction module is used for carrying out Gaussian noise reduction on the gray-scale image before the processing of the gray-scale image based on the canny edge detection algorithm.
Optionally, the processing the gray scale map based on the canny edge detection algorithm to obtain a binary map includes:
calculating gradient amplitude values by utilizing first-order partial derivative finite difference aiming at the gray-scale map;
and carrying out maximum suppression processing according to the gradient amplitude to obtain a binary image.
Optionally, the apparatus further comprises:
and the operation module is used for performing closed operation processing on the binary image before the binary image is projected along a direction vertical to a preset segmentation direction so as to close the image edge in the binary image.
According to the character segmentation device, the device firstly obtains a character region image, then generates a gray scale image corresponding to the character region image, then processes the gray scale image based on a canny edge detection algorithm to obtain a binary image, projects the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array, then linearly transforms the statistical array to normalize elements in the statistical array, matches the normalized statistical array with a preset multi-character template array, and segments the character region image according to a matching result to obtain a single-character rectangular string. The device adopts the canny edge detection algorithm to process the gray level image of the character area, can overcome the interference of background color blocks, and adopts an elastic template to match, thereby improving the character segmentation precision.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions in the embodiments of the present application.
Claims (8)
1. A method for character segmentation, the method comprising:
acquiring a character area image, and generating a gray scale image corresponding to the character area image, wherein the character area image is an image corresponding to a character area in a printing card;
processing the gray level image based on a canny edge detection algorithm to obtain a binary image;
projecting the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array;
performing linear transformation on the statistical array to normalize elements in the statistical array;
matching the normalized statistical array with a preset multi-character template array, and segmenting the character region image according to a matching result to obtain a single-character rectangular string, wherein the single-character rectangular string comprises a rectangular region corresponding to each character in the character region; the multi-character template array comprises a template array corresponding to at least one character combination, and the length of the multi-character template array is determined according to the number of character groups in the character combination, the number of characters, the width of the characters and the proportion coefficient of the group spacing to the width of the characters.
2. The method of claim 1, wherein the printed card comprises a printed bank card; the character area comprises any one or more of a bank card number area, a verification code area or a validity period area.
3. The method according to claim 1, wherein the processing the gray map based on canny edge detection algorithm to obtain a binary map comprises:
calculating gradient amplitude values by utilizing first-order partial derivative finite difference aiming at the gray-scale map;
and carrying out maximum suppression processing according to the gradient amplitude to obtain a binary image.
4. The method according to any one of claims 1 to 3, wherein before projecting the binarized map in a direction perpendicular to a preset segmentation direction, the method further comprises:
and performing closed operation processing on the binary image according to a dual-threshold algorithm so as to close the image edge in the binary image.
5. An apparatus for character segmentation, the apparatus comprising:
the generating module is used for acquiring a character area image and generating a gray scale image corresponding to the character area image, wherein the character area image is an image corresponding to a character area in a printing card;
the edge detection module is used for processing the gray level image based on a canny edge detection algorithm to obtain a binary image;
the projection module is used for projecting the binary image along a direction vertical to a preset segmentation direction to obtain a statistical array;
the transformation module is used for carrying out linear transformation on the statistical array so as to normalize elements in the statistical array;
the segmentation module is used for matching the normalized statistical array with a preset multi-character template array and segmenting the character region image according to a matching result to obtain a single-character rectangular string, wherein the single-character rectangular string comprises a rectangular region corresponding to each character in the character region; the multi-character template array comprises a template array corresponding to at least one character combination, and the length of the multi-character template array is determined according to the number of character groups in the character combination, the number of characters, the width of the characters and the proportion coefficient of the group spacing to the width of the characters.
6. The apparatus of claim 5, wherein the printed card comprises a printed bank card; the character area comprises any one or more of a bank card number area, a verification code area or a validity period area.
7. The apparatus according to any one of claims 5 to 6, wherein the edge detection module is specifically configured to:
calculating gradient amplitude values by utilizing first-order partial derivative finite difference aiming at the gray-scale map;
and carrying out maximum suppression processing according to the gradient amplitude to obtain a binary image.
8. The apparatus of any one of claims 5 to 6, further comprising:
and the operation module is used for performing closed operation processing on the binary image according to a dual-threshold algorithm before the binary image is projected in a direction vertical to a preset segmentation direction so as to close the image edge in the binary image.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811504027.9A CN109598271B (en) | 2018-12-10 | 2018-12-10 | Character segmentation method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811504027.9A CN109598271B (en) | 2018-12-10 | 2018-12-10 | Character segmentation method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109598271A CN109598271A (en) | 2019-04-09 |
CN109598271B true CN109598271B (en) | 2021-02-09 |
Family
ID=65962208
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811504027.9A Active CN109598271B (en) | 2018-12-10 | 2018-12-10 | Character segmentation method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109598271B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110705989B (en) * | 2019-09-17 | 2021-03-16 | 创新先进技术有限公司 | Identity authentication method, method for realizing login-free authorization component and respective devices |
CN111027546B (en) * | 2019-12-05 | 2024-03-26 | 嘉楠明芯(北京)科技有限公司 | Character segmentation method, device and computer readable storage medium |
CN111046862B (en) * | 2019-12-05 | 2023-10-27 | 嘉楠明芯(北京)科技有限公司 | Character segmentation method, device and computer readable storage medium |
JP7508556B2 (en) * | 2019-12-05 | 2024-07-01 | 嘉楠明芯(北京)科技有限公司 | Character segmentation method, device, and computer-readable storage medium |
CN111060527B (en) * | 2019-12-30 | 2021-10-29 | 歌尔股份有限公司 | Character defect detection method and device |
CN111866254B (en) * | 2020-07-31 | 2021-08-31 | 广东佳米科技有限公司 | Speed dialing system for intelligently identifying word stroke and implementation method thereof |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7302098B2 (en) * | 2004-12-03 | 2007-11-27 | Motorola, Inc. | Character segmentation method and apparatus |
CN101567041A (en) * | 2009-05-25 | 2009-10-28 | 公安部交通管理科学研究所 | Method for recognizing characters of number plate images of motor vehicles based on trimetric projection |
CN102043959B (en) * | 2010-12-28 | 2012-09-26 | 青岛海信网络科技股份有限公司 | License plate character segmentation method |
CN104408454B (en) * | 2014-06-30 | 2017-10-17 | 电子科技大学 | Registration number character dividing method based on Elastic forming board matching algorithm |
CN105095860B (en) * | 2015-06-30 | 2018-05-29 | 小米科技有限责任公司 | character segmentation method and device |
CN106650553A (en) * | 2015-10-30 | 2017-05-10 | 比亚迪股份有限公司 | License plate recognition method and system |
CN108615034A (en) * | 2017-12-14 | 2018-10-02 | 燕山大学 | A kind of licence plate recognition method that template matches are combined with neural network algorithm |
-
2018
- 2018-12-10 CN CN201811504027.9A patent/CN109598271B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN109598271A (en) | 2019-04-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109598271B (en) | Character segmentation method and device | |
CN109348731B (en) | Image matching method and device | |
CN109117773B (en) | Image feature point detection method, terminal device and storage medium | |
CN105631449B (en) | A kind of picture segmentation method, device and equipment | |
CN110189341B (en) | Image segmentation model training method, image segmentation method and device | |
CN109919992B (en) | Method for estimating depth in image | |
CN105096347A (en) | Image processing device and method | |
CN110490190A (en) | A kind of structured image character recognition method and system | |
CN105678301B (en) | method, system and device for automatically identifying and segmenting text image | |
CN111062927A (en) | Method, system and equipment for detecting image quality of unmanned aerial vehicle | |
CN110135288B (en) | Method and device for quickly checking electronic certificate | |
CN111614959B (en) | Video coding method and device and electronic equipment | |
CN108268868B (en) | Method and device for acquiring inclination value of identity card image, terminal and storage medium | |
CN108510636B (en) | Image segmentation method, image segmentation device and terminal equipment | |
CN109145879B (en) | Method, equipment and storage medium for identifying printing font | |
Nasiri et al. | A new binarization method for high accuracy handwritten digit recognition of slabs in steel companies | |
CN114972540A (en) | Target positioning method and device, electronic equipment and storage medium | |
CN112364835B (en) | Video information frame taking method, device, equipment and storage medium | |
CN114862870A (en) | Speckle pattern partitioning method, device, equipment and medium | |
CN116414321A (en) | Color block color data acquisition method, device, equipment and storage medium | |
CN112308062A (en) | Medical image access number identification method in complex background image | |
CN112734813A (en) | Registration method, registration device, electronic equipment and computer-readable storage medium | |
CN112149675B (en) | Method for acquiring chart information data, electronic equipment and readable storage medium | |
CN113658101B (en) | Method and device for detecting landmark points in image, terminal equipment and storage medium | |
US9202097B2 (en) | Information processing apparatus, information processing method, and computer program product |
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 |