Dot-matrix character feature extraction method based on corner pixels
By using a dot matrix character feature extraction method based on corner pixels, the problems of poor robustness and high computational cost in dot matrix inkjet character detection are solved. An eight-dimensional feature vector is extracted, which improves detection accuracy and efficiency.
Patent Information
- Application Number
- CN202310673744.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-07
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2043-06-07
AI Technical Summary
Existing technologies for dot matrix inkjet character detection and recognition in industrial production suffer from poor feature extraction robustness, high computational load, and susceptibility to noise and stroke adhesion interference, which affects detection accuracy.
A dot matrix character feature extraction method based on corner pixels is adopted. The original image of the dot matrix character is obtained and preprocessed. The four corners of the image are cropped, the proportion of corner pixels is counted and the stroke slope is calculated, and an eight-dimensional feature vector is extracted, including pixel position statistical features and stroke curvature structure features.
It effectively overcomes the problems of internal character adhesion and noise interference, reduces the amount of computation, improves the robustness and accuracy of feature extraction, has a low feature vector dimension, and has high algorithm efficiency.
Smart Images

Figure CN116721428B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of image processing, and particularly relates to a dot matrix character feature extraction method based on corner pixels. BACKGROUND
[0002] In industrial production, dot matrix code spraying technology has been widely used in product packaging printing. The production date, production batch and production location information of food and medicine are generally sprayed on the outer packaging bag using dot matrix code characters. However, in the actual production line, due to the limitations of production equipment and production environment, the dot matrix code characters often appear to be missed or misprinted, and there are problems such as character bending, blurring, wrinkling, and adhesion between adjacent characters. Therefore, based on the dot matrix code character detection and recognition in complex scenes has become an important task, and extracting effective character features is the most important.
[0003] Character feature extraction refers to extracting key features of characters from a character binary image after scale normalization. Meanwhile, it needs to meet the following requirements: the features are independent of each other, the differences between the same features are as small as possible, the differences between different features are as large as possible, the dimension of the feature vector is as small as possible, and the accuracy of correct classification is as high as possible. Generally, character features are mainly divided into structural features and statistical features. Structural features refer to the shape, structure and stroke of characters, and structural features are easy to distinguish for characters with similar stroke structures. The disadvantage is that it is difficult to extract and has poor anti-interference ability. Statistical features are extracted by statistics of pixel values of characters in an image, such as mean, variance and median. Statistical features are more robust than structural features, but cannot well describe the shape and structure information of characters.
[0004] So far, character feature extraction methods can be mainly divided into traditional methods and deep learning-based methods. The traditional method needs to design and extract features manually, and the deep learning-based method can realize automatic feature extraction. Although the deep learning method has many advantages, it needs a large amount of computing resources to realize efficient training and inference, so it has a high requirement for the GPU or TPU of the device and needs a large amount of data for training. However, under actual industrial conditions, the device and the amount of data samples are difficult to meet such high requirements. Therefore, the artificial feature extraction method can better adapt to the device conditions under most industrial production conditions.
[0005] In the traditional method, the commonly used algorithms for extracting character features include crossing feature extraction, projection feature extraction, grid feature extraction and the like. These algorithms are susceptible to noise interference or internal stroke adhesion, and have the problem of large amount of calculation. For example, the crossing feature extraction method is to scan and count the number of times of pixels from white to black and then from black to white by row and column. In actual environment and equipment conditions, the noise in the middle of the character and the stroke adhesion will affect the extraction effect, and the feature vector dimension extracted by the method is high. The projection feature extraction method is to obtain the features reflecting the stroke density of the character by projecting the image in the vertical and horizontal directions. Although this method is simple and easy to implement, it is also affected by character adhesion and noise and is difficult to fully express the feature information of the character. The grid feature extraction method is to divide the character image into a plurality of small grids, and then count and describe the pixel values in each grid. However, this feature has poor anti-stroke interference ability and limited expression of feature information. The four-edge feature extraction method derived from the grid feature extraction method is to extract the pixel features of the four edges of the character image. This method can reduce the interference of character adhesion and internal noise on feature extraction, but there is an overlapping area between the four edges of the character image. A large number of overlapping areas increase the calculation amount during feature extraction, and only using the pixel information of the four edges of the character is difficult to represent all the features of the character.
[0006] In summary, it is difficult to fully represent all the feature information of a single character by extracting a single feature of the character, and it is susceptible to noise and internal stroke adhesion. In actual industrial production, character detection and recognition, this will inevitably affect the final effect and accuracy. SUMMARY
[0007] The purpose of the present application is to provide a dot matrix character feature extraction method based on edge and corner pixels, which solves the problems of poor robustness and large amount of calculation in the current dot matrix character feature extraction.
[0008] The technical solution adopted by the present application is as follows:
[0009] A dot matrix character feature extraction method based on edge and corner pixels, comprising:
[0010] (1) obtaining the original image of the dot matrix character, wherein the original image can contain one or more dot matrix characters;
[0011] (2) pre-processing the original image, which includes binarization processing, inclination correction, image segmentation and character normalization, to obtain the image of all single dot matrix characters;
[0012] (3) according to the actual size and aspect ratio of the single character image after pre-processing, the four corners of the image are cut according to a certain size;
[0013] (4) Counting the number of character pixel points in each corner, and calculating the proportion of the number of pixel points in each corner in the total number of character pixels, to obtain the pixel position statistical characteristics of the character;
[0014] (5) Calculating the slope of the character stroke outline pixels in each corner image, and based on the slope of each pixel, calculating the average slope and standard deviation of the character stroke in each corner image, to obtain the stroke curvature structural characteristics of the character.
[0015] Preferably, the original image can contain multiple rows of dot matrix characters composed of Chinese, English, numerical characters and symbols.
[0016] Preferably, the specific implementation method of step (2) is as follows:
[0017] If the original image is an 8-bit grayscale image, the image is divided into black and white colors by global threshold binarization. If the original image is a 24-bit RGB color image, the image is first grayed, then global threshold binarization is performed, tilt correction is performed, and a single character is segmented. The segmented single character is subjected to position normalization and size normalization operations.
[0018] Preferably, the specific method of normalization in step (2) is as follows:
[0019] Position normalization: calculating the centroid of the character and moving the centroid to a specified position on the image;
[0020] Size normalization: performing size normalization according to the distribution of character pixels in the horizontal and vertical directions.
[0021] Preferably, the specific implementation method of step (3) is as follows:
[0022] First, the size and aspect ratio of the single character image are calculated. Under the premise of ensuring that most dot matrix characters can extract as many character features as possible and introducing as little character internal adhesion information as possible, a certain size ratio is selected to extract the four corners of the character, and the corners can overlap each other.
[0023] Preferably, the specific implementation method of step (4) is as follows:
[0024] First, the total number of black pixel points in the image, i.e., the number of character pixels in the entire character image, is counted. Then, the number of black pixel points in each corner, i.e., the number of corner character pixel points, is counted. Thus, a four-dimensional feature vector S1, denoted as {s1, s2, s3, s4}, is obtained. Next, the proportion of the number of pixel points in each corner in the total number of character pixels is calculated, to obtain the pixel position statistical characteristics of the character.
[0025] Preferably, the specific implementation method of step (5) is as follows:
[0026] For each pixel of the character stroke path in the four corner images, the slope between it and its adjacent pixel is calculated. i+1 The coordinate of the current statistical point P i+1 is (x i+1 , y i ), the coordinate of the last statistical point P i is (x i , y i+1 ), and the calculation formula is as follows:
[0027]
[0028] Where k i represents the slope of the current statistical point, and the average slope and the standard deviation of the character stroke in each corner image are calculated based on the slope of each pixel after calculation, so that a four-dimensional feature vector S2, denoted as {s5, s6, s7, s8}, is obtained, and the stroke curvature structure feature of the character is obtained.
[0029] The specific calculation method of the average slope and the standard deviation of the character stroke is as follows:
[0030] The average slope of the character stroke is calculated as follows:
[0031]
[0032] Where m represents the number of pixel points participating in the slope calculation in each corner, and k avg represents the slope of the i-th pixel point participating in the slope calculation.
[0033] The standard deviation of the character stroke is calculated as follows:
[0034]
[0035] Where k avg represents the average slope of the character stroke.
[0036] Preferably, the method can extract two four-dimensional feature vectors, totaling eight-dimensional feature vectors {s1, s2, s3, s4, s5, s6, s7, s8}, which include the pixel position statistical feature vector {s1, s2, s3, s4} and the stroke curvature structure feature vector {s5, s6, s7, s8}.
[0037] Preferably, the method further comprises the steps of:
[0038] S6, identifying the dot matrix character according to the pixel position statistical feature and the stroke curvature structure feature.
[0039] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0040] The present application combines character structure features and statistical features, extracts features of a character image according to character pixels and stroke curvature of a character corner part, effectively overcomes the defects that a single extraction of character pixel statistical features cannot well describe the shape and structure information of a character and a single extraction of character stroke structure features is difficult to extract and has poor robustness, and more importantly, the present application extracts features of four corner parts of a character instead of the entire character image, so that only eight-dimensional features of four-dimensional pixel position statistical features and four-dimensional stroke curvature structure features are extracted, and the situation of internal adhesion and noise interference of a dot matrix character can be effectively coped with, so that the extracted features have strong anti-interference ability, the dimension of a feature vector is small, and the amount of algorithm calculation is small. Compared with a four-edge area feature extraction method of a dot matrix character image, the corner feature extraction can remove or reduce the overlapping area between each feature area, reduce the amount of calculation, and improve the efficiency. The method has the advantages of strong robustness, small dimension of a feature vector, high correct classification precision, and the like. BRIEF DESCRIPTION OF DRAWINGS
[0041] Figure 1 is a flowchart of a dot matrix character feature extraction method based on edge corner pixels provided by an embodiment of the present application;
[0042] Figure 2 is a flowchart of a character image preprocessing process provided by an embodiment of the present application;
[0043] Figure 3 is a diagram of a corner feature extraction area provided by an embodiment of the present application;
[0044] Figure 4 is another diagram of a corner feature extraction area provided by an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application. In addition, the technical features involved in each embodiment of the present application described below can be combined with each other as long as they do not conflict with each other.
[0046] The present application provides a dot matrix character feature extraction method based on edge corner pixels. This method extracts the pixel and curvature information in the four corners of a preprocessed dot matrix character image to complete the feature extraction of the character, effectively overcomes the problem of poor extraction effect caused by internal adhesion and noise interference of the character, and also reduces the amount of calculation to a certain extent. This method has good robustness and high precision.
[0047] The embodiment of the present invention provides a method for extracting dot matrix character features based on corner pixels, such as Figure 1 As shown, the following steps are included:
[0048] S1: Acquire an original image of a dot matrix character, wherein the original image may contain at least one dot matrix character;
[0049] S2: Preprocessing the original image, including binarization, tilt correction, image segmentation, and character normalization, to obtain images of all single dot matrix characters;
[0050] S3: According to the actual size and aspect ratio of the pre-processed single character image, the four corners of the image are cut off at a certain size;
[0051] S4: Counting the number of character pixels in each corner, and calculating the ratio of the number of pixels in each corner to the total number of character pixels, to obtain pixel position statistical features of the character;
[0052] S5: Calculate the slope of the outer contour pixels of the character strokes in each corner image, and then calculate the average slope and standard deviation of the character strokes in each corner image based on the slope of each pixel to obtain the stroke curvature structure characteristics of the character.
[0053] The dot matrix characters include any characters such as Chinese characters, English characters, numeric characters, and symbols. Symbols can be special symbols, Greek letters, punctuation marks, graphic symbols, etc.
[0054] The following is combined with Figures 2 to 4 The implementation process of the present invention is described in detail. It should be noted that the image preprocessing method adopted in the following embodiment is only an optional implementation method and should not be understood as limiting the present invention.
[0055] (1) Image preprocessing
[0056] Figure 2It is a flow chart of the image preprocessing provided by an embodiment of the present invention. If the original image is an 8-bit grayscale image, global threshold binarization is used to divide the image into black and white colors. If the original image is a 24-bit RGB color image, the image is first grayscaled and then subjected to global threshold binarization. After binarization, the image is tilt-corrected. The present invention adopts a projection method. The specific operation steps are: first, the image is horizontally projected to calculate the variance of the projection, and then the image is rotated by a certain angle, and then projected and the variance is calculated. This process is repeated to calculate the variance corresponding to each step of the image in a certain positive and negative angle range. The angle corresponding to the largest variance is the angle that needs to be corrected. After correction, the character image is segmented. The segmentation can be performed by the projection method, the connected region method, etc. The specific method is not described here. It is sufficient to segment a single dot matrix character. Finally, the position and size normalization operations must be performed on individual characters. The specific steps are: first calculate the horizontal and vertical center of mass of the character, then move the center of mass to the specified position to complete position normalization, and then perform size normalization based on the distribution of character pixels in the horizontal and vertical directions to make the image size of all individual dot matrix characters consistent.
[0057] The horizontal centroid is calculated as:
[0058]
[0059] Among them, i and j represent the horizontal and vertical positions of the pixel respectively, and c(i, j) represents the grayscale value of the pixel at the corresponding position.
[0060] The vertical centroid is calculated as:
[0061]
[0062] (2) Feature extraction area
[0063] The corner feature extraction area is based on the actual size and aspect ratio of the single character rectangular image after preprocessing, and the four corners of the image are intercepted at a certain size, such as Figure 3 As shown in the figure, the character image is intercepted into four regions: 1, 2, 3, and 4 (upper left, upper right, lower left, and lower right). Subsequent feature extraction will also be performed based on these four regions. When the intercepted portion is too small, although the interference of internally adhered characters can be eliminated, key information is likely to be missed. Therefore, the selected corner range should include the key information of the character as much as possible. Regions 1, 2, 3, and 4 can overlap, as shown in the following example. Figure 4 As shown, feature extraction is also performed on respective triangular regions.
[0064] It should be noted that the intercepting line can be a straight line, a broken line, an arc line or a curve, etc. For example, the four corners of the character rectangular image can be taken as the centers of the circles, and four corners are obtained by drawing circles respectively, or four regions are directly intercepted by four intercepting lines which are symmetric to the center of the image.
[0065] In the embodiment, the intercepting line is a straight line, the length-width ratio of the image is taken as the slope of the straight line, and the actual size of the image and the proportion of the corner region in the whole image are combined to determine the position of the intercepting line.
[0066] (3) Extraction of feature information
[0067] The character pixel and stroke curvature information of the corner region are extracted in the present application. The specific steps of the character pixel feature extraction are as follows: the number of character pixels in the whole image and each corner image is counted respectively, and the proportion of the number of each corner pixel in the total character pixels is calculated, so that a four-dimensional feature vector, i.e. the pixel feature of the character, is obtained.
[0068] The specific steps of the curvature feature extraction are as follows: the slope between the character stroke contour pixel and the adjacent pixel in each corner image is calculated, the coordinates of the current statistical point P i+1 are (x i+1 , y i+1 ), the coordinates of the last statistical point P i are (x i , y i ), and the calculation formula is as follows:
[0069]
[0070] Wherein k i+1 represents the slope of the current statistical point, and the average slope and the standard deviation of the character stroke in each corner image are calculated based on the slope of each pixel after calculation, so that the curvature feature of the character is obtained. Thus, a four-dimensional feature vector, i.e. the curvature feature of the character, is also obtained.
[0071] For the case that the character structure is relatively simple and the character amount is small, the calculation method of the curvature can also be simplified, for example, the number of continuous pixels with equal pixel slope and the variation range of the slope can be used to represent the curvature feature.
[0072] After the pixel position statistical feature and the stroke curvature structural feature are extracted, the dot matrix character can be detected and recognized according to the pixel position statistical feature and the stroke curvature structural feature.
[0073] According to the above, the application discloses a dot-matrix character feature extraction method based on corner pixels, and belongs to the field of image processing, which comprises the following steps: obtaining an original image of dot-matrix characters, wherein the original image can contain one or more dot-matrix characters; pre-processing the original image, which comprises binarization processing, inclination correction, image segmentation and character normalization, to obtain images of all single dot-matrix characters; according to the actual size and the length-width ratio of the single character image after pre-processing, cutting the image at four corners according to a certain size; counting the number of character pixel points in each corner, and calculating the proportion of the number of pixel points in each corner in the total character pixel points to obtain the pixel position statistical feature of the character; calculating the slope of the character stroke contour pixel in each corner image, and calculating the average slope and the standard deviation of the character stroke in each corner image based on the slope of each pixel to obtain the stroke curvature structural feature of the character. The application extracts the structural and statistical features of the character image by counting the character pixels and calculating the stroke curvature in the four corner regions of the single dot-matrix character image, and obtains an eight-dimensional feature vector. Since the method extracts the corner information of single characters, the interference of character internal information adhesion and noise in the extraction of statistical features and structural features by the existing algorithm is avoided, and the dimension and the calculation amount of the invalid feature vector in the existing algorithm are reduced. The dot-matrix character features extracted by the application are typical, easy to distinguish from other characters, and not easy to be affected by character internal stroke adhesion and noise interference.
[0074] It should be noted that, according to the needs of implementation, each step / component described in the present application can be split into more steps / components, or two or more steps / components or part of the operation of the steps / components can be combined into a new step / component, so as to achieve the purpose of the present application.
[0075] Those skilled in the art will easily understand that the above is only a preferred embodiment of the present application, and is not intended to limit the present application, and any modification, equivalent replacement and improvement made within the spirit and principle of the present application should be included in the protection scope of the present application.
Claims
1. A dot matrix character feature extraction method based on corner pixels, characterized in that: The method comprises the following steps: S1. Obtaining an original image of a dot matrix character, wherein the original image contains at least one dot matrix character; S2. Preprocessing the original image, including binarization, tilt correction, image segmentation, and character normalization, to obtain images of all single dot matrix characters; S3, cutting off the four corners of the dot matrix character image according to a certain size ratio; S4. Counting the number of pixels of the dot matrix character in each corner, and calculating the ratio of the number of pixels of the dot matrix character in each corner to the total number of pixels of the dot matrix character, to obtain pixel position statistical features of the dot matrix character; S5. Calculate the slope of the pixels of the outer contour of the dot matrix character strokes in each corner, obtain the average slope of the dot matrix character strokes in each corner based on the slope of each pixel, and then calculate the standard deviation of the slope of the dot matrix character strokes in each corner to obtain the stroke curvature structure characteristics of the dot matrix character, specifically including: For each pixel of the dot matrix character stroke path in the four corners, calculate the slope between it and the adjacent pixels; let the current pixel point P i+1 The coordinates are (x i+1 ,y i+1 ), the previous pixel P i The coordinates are (x i ,y i ), the slope calculation formula is: in, Indicates the slope of the current pixel; Calculate the average slope of the dot matrix character strokes in each corner based on the calculated slope of each pixel for: Among them, m represents the number of pixels in each corner that participate in the slope calculation. Indicates the first i The slope of each pixel; Then calculate the slope standard deviation of the dot matrix character strokes in each corner for: The standard deviation of the slope of the dot matrix character strokes in the four corners is the stroke curvature structure feature of the dot matrix character.
2. The method for extracting dot matrix character features based on corner pixels according to claim 1, characterized in that: Dot matrix characters include Chinese characters, English characters, numeric characters and symbols.
3. The method for extracting dot matrix character features based on corner pixels according to claim 1, characterized in that: Step S2 specifically includes: If the original image is a grayscale image, the image is subjected to global threshold binarization processing. If the original image is a color image, the image is first grayscaled and then subjected to global threshold binarization processing. After that, tilt correction is performed. The image is segmented to obtain all individual characters, and then all the segmented individual characters are positionally normalized and size normalized to obtain images of all individual dot matrix characters.
4. The method for extracting dot matrix character features based on corner pixels according to claim 3, characterized in that: Normalization is specifically: Position normalization: calculate the center of mass of the character and move it to the specified position; Size normalization: Normalize the size of the character based on the distribution of its pixels in both horizontal and vertical directions.
5. The method for extracting dot matrix character features based on corner pixels according to claim 1, characterized in that: Step S3 specifically includes: On the premise of ensuring that most character features are extracted as much as possible from most dot matrix characters and less internal adhesion information of the characters is introduced, the four corners of the dot matrix character image are intercepted according to a certain size ratio.
6. The method for extracting dot matrix character features based on corner pixels according to claim 1 or 5, characterized in that: According to the size and aspect ratio of a single dot matrix character image, the four corners of the dot matrix character image are intercepted according to a certain size ratio.
7. The method for extracting dot matrix character features based on corner pixels according to claim 1 or 5, characterized in that: The intercept line is a straight line, a broken line, an arc or a curve.
8. The method for extracting dot matrix character features based on corner pixels according to claim 1, characterized in that: The pixel position statistical feature of the dot matrix character is a four-dimensional feature vector S1, recorded as {s1, s2, s3, s4}; where s1, s2, s3 and s4 are the ratios of the number of pixels of the dot matrix character in the four corners to the number of pixels of the entire dot matrix character; The stroke curvature structure feature of the dot matrix character is a four-dimensional feature vector S2, denoted as {s5, s6, s7, s8}; among them, s5, s6, s7 and s8 are the standard deviations of the slopes of the dot matrix character strokes in the four corners; or the number of consecutive pixels with equal pixel slopes in the four corners and the range of variation of the slope are counted to characterize the stroke curvature structure feature of the dot matrix character.
9. The method for extracting dot matrix character features based on corner pixels according to claim 1 or 8, characterized in that: The method further comprises the steps of: S6. Identify the dot matrix character based on pixel position statistical features and stroke curvature structural features.
Citation Information
Patent Citations
Character feature extraction method based on stroke shape of boundary point and application thereof
CN102629322A
Character noise reduction method in character recognition process
CN106022329A