Medicine label number identification method based on multi-feature extraction

文档序号:8534 发布日期:2021-09-17 浏览:28次 中文

1. A medicine label number identification method based on multi-feature extraction is characterized by comprising the following steps:

s1, collecting and preprocessing an image sample to be identified; dividing an image sample to be identified into a plurality of binary character image samples; adjusting the size of the binary image of the binary character image sample to be recognized for further recognition;

step S2, carrying out normalization processing on the preprocessed binary character image sample, and carrying out image turning to obtain a binary image with white characters and black background;

step S3, respectively carrying out image thinning on the binary character image samples;

step S3.1, reading an area of any 3 × 3 pixels in the image, and marking the central point of the area as P1; when a certain pixel point is white, the point is marked as P1, and when the certain pixel point is black, the point is marked as P0; setting P9 to be positioned at the upper left corner of the 3-by-3 pixel region, and arranging P8-P2 in a reverse order along the counterclockwise direction;

when P1 is equal to 1, judging a central point eight neighborhood; when the following 4 conditions are simultaneously met, setting P1 as 0;

under the condition (1), N (P1) is more than or equal to 2 and less than or equal to 6

Wherein N (P1) ═ P2+ P3+ P4+ P5+ P6+ P7+ P8+ P9; the P2-P9 sequentially represent 8 neighborhood points around the point P1;

condition (2), the number of times F of 01-way ligation in the sequential ordering of P2-P9 is 1;

condition (3), P2 × P4 × P6 is 0;

condition (4), P4 × P6 × P8 is 0;

traversing pixel points in each image, and sequentially performing the thinning and deleting operation;

step S3.2, carrying out refining deletion on the refined image obtained in the step S3.1 again:

reading a region of any 3 x 3 pixels in the image, marking the center point of the region as P1; when a certain pixel point is white, the point is marked as P1, and when the certain pixel point is black, the point is marked as P0; setting P9 to be positioned at the upper left corner of the 3-by-3 pixel region, and arranging P8-P2 in a reverse order along the counterclockwise direction;

when P1 is equal to 1, judging a central point eight neighborhood; when the following 4 conditions are simultaneously met, setting P1 as 0;

under the condition (1), N (P1) is more than or equal to 2 and less than or equal to 6

Wherein N (P1) ═ P2+ P3+ P4+ P5+ P6+ P7+ P8+ P9; the P2-P9 sequentially represent 8 neighborhood points around the point P1;

condition (2), the number of times F of 01-way ligation in the sequential ordering of P2-P9 is 1;

condition (3), P2 × P4 × P8 is 0;

condition (4), P2 × P6 × P8 is 0;

traversing pixel points in each image, and sequentially performing the thinning and deleting operation;

s3.3, repeating iteration on the binary character image sample, and executing thinning operation until thinning cannot be performed;

s3.4, respectively performing expansion processing on the binary character image samples by using 4 multiplied by 4 structural elements;

and step S4, performing symbol recognition on the expanded binary character image sample, and finally obtaining a recognition result.

2. The method for identifying label numbers of drugs based on multi-feature extraction as claimed in claim 1, wherein the symbol identification method in step S4 comprises the following steps:

s4.1, subtracting the number of holes in the connected domain from the number of the connected domain in the image sample to be recognized to obtain the Euler number of each character image;

s4.2, dividing the image sample to be identified into A type, B type and 8 type according to the Euler number; the Euler number of the type A sample is 1 and comprises a character set {1, 2, 3, 5 and 7}, and the Euler number of the type B sample is 0 and comprises a character set {0, 4, 6 and 9 }; when the Euler number is-1, judging the character as a number 8;

s4.3, scanning the A-type sample image line by line, and recording the length of white pixel points continuously appearing in each line; when the length of the white pixel point is larger than 0.8 time of the width of the sample image, judging that a transverse line appears;

when the horizontal line is positioned on the upper 5 rows, the image is marked as a C-type sample comprising a character set {5, 7}, and when the horizontal line is positioned on the lower 5 rows, the image is marked as a D-type sample comprising a character set {1, 2 }; when no horizontal line appears, judging the character as a number 3; the secondary judgment is performed on the class C and class D samples respectively as follows:

scanning the C-type and D-type sample images row by row, recording the length of white pixel points continuously appearing in each row, and judging that a vertical line appears when the length of the white pixel points exceeds 0.4 time of the height of the image; equally dividing the sample image into 3 columns along the longitudinal direction, wherein the columns comprise a left column, a middle column and a right column;

when the vertical line in the C-type sample image appears in the middle column, judging that the character is a number 1, otherwise, judging that the character is a number 2;

when a vertical line appears in the left column in the D-type sample image, the character is judged to be a numeral 5, and when the vertical line appears in the right column, the character is judged to be a numeral 7;

s4.4, scanning the B-type sample image row by row, recording the length of white pixel points continuously appearing in each row, and judging that a vertical line appears when the length of the white pixel points exceeds 0.4 time of the height of the image; equally dividing the sample image into 3 columns along the longitudinal direction, wherein the columns comprise a left column, a middle column and a right column;

when the vertical line only appears in the left column in the sample image, judging that the character is a numeral 6; when the vertical line only appears in the right column in the sample image, judging that the character is a number 9; when no vertical line exists in the sample image, judging that the character is 4; when the sample image contains the left vertical line and the right vertical line, the sample image is divided into an E-type sample image which comprises a character set {0,6,9 };

for an E-type sample image, detecting row and column coordinates of the hole centroid, scanning the middle column of the image from top to bottom, calculating the times of the scanning line passing through a white pixel area, and recording as the number of vertical middle line intersection points; when the number of the intersecting points of the vertical central lines is 2, judging that the character is a number 0; when the number of the intersecting points of the vertical central lines is more than 2 and the hole mass center is positioned in the upper half area of the image, the character is judged to be a number 9; and when the number of the intersecting points of the vertical central lines is more than 2 and the hole mass center is positioned in the lower half area of the image, judging that the character is a numeral 6.

3. The method for identifying label numbers of drugs based on multi-feature extraction as claimed in claim 1, wherein the step S1 is performed to adjust the binary image of the binary character image sample to be identified to 25 x 50 pixels.

Background

With the rapid development of the recent computer technology, application scenes such as license plate Recognition, electronic document Recognition, business bill management, photographing translation and the like are visible everywhere, if the work of people is reduced by utilizing the Optical Character Recognition (OCR) technology to automatically recognize characters of images, the work efficiency and the life quality of people are greatly improved. Therefore, the OCR technology is one of the important development directions in the computer vision technology.

In a natural scene, the character recognition accuracy is poor due to the problems of inaccurate focusing, insufficient light, too many noise points, inclined angle, imaging distortion and the like in the process of shooting and the problems of dissimilarity of characters with different sizes, fonts, colors, arrangement modes and the like.

Researchers have proposed various algorithms for character recognition, and there are: feature extraction classification method, template matching method, neural network identification and the like. The feature extraction classification method and the template matching method have the advantages of simplicity and effectiveness, but the key of the identification effect is the selection of features and templates, and the selection of the parameters depends on manual experience; the neural network identification method needs to build a network model to be continuously debugged to obtain an optimal network structure, and has high requirements on the operation performance.

The printed numbers have the characteristics of simple structure and fixed font, and the classification result is less, and only 10 numbers from 0 to 9 exist. If the method can be used for identification simply, quickly and with high accuracy, the practicability is higher.

Disclosure of Invention

The purpose of the invention is as follows: based on the problems in the background technology, the invention provides a medicine label number recognition method based on multi-feature extraction, which comprises the steps of preprocessing a binary character image sample, performing thinning and deleting operation on the image through neighborhood judgment, performing expansion to obtain a clear image, and combining three features of Euler number, horizontal line feature and vertical line feature to provide a recognition method for specifically distinguishing 0-9 characters.

The technical scheme is as follows: in order to achieve the purpose, the invention adopts the technical scheme that:

a medicine label number identification method based on multi-feature extraction comprises the following steps:

s1, collecting and preprocessing an image sample to be identified; dividing an image sample to be identified into a plurality of binary character image samples; adjusting the size of the binary image of the binary character image sample to be recognized for further recognition;

step S2, carrying out normalization processing on the preprocessed binary character image sample, and carrying out image turning to obtain a binary image with white characters and black background;

step S3, respectively carrying out image thinning on the binary character image samples;

step S3.1, reading an area of any 3 × 3 pixels in the image, and marking the central point of the area as P1; when a certain pixel point is white, the point is marked as P1, and when the certain pixel point is black, the point is marked as P0; setting P9 to be positioned at the upper left corner of the 3-by-3 pixel region, and arranging P8-P2 in a reverse order along the counterclockwise direction;

when P1 is equal to 1, judging a central point eight neighborhood; when the following 4 conditions are simultaneously met, setting P1 as 0;

under the condition (1), N (P1) is more than or equal to 2 and less than or equal to 6

Wherein N (P1) ═ P2+ P3+ P4+ P5+ P6+ P7+ P8+ P9; the P2-P9 sequentially represent 8 neighborhood points around the point P1;

condition (2), the number of times F of 01-way ligation in the sequential ordering of P2-P9 is 1;

condition (3), P2 × P4 × P6 is 0;

condition (4), P4 × P6 × P8 is 0;

traversing pixel points in each image, and sequentially performing the thinning and deleting operation;

step S3.2, carrying out refining deletion on the refined image obtained in the step S3.1 again:

reading a region of any 3 x 3 pixels in the image, marking the center point of the region as P1; when a certain pixel point is white, the point is marked as P1, and when the certain pixel point is black, the point is marked as P0; setting P9 to be positioned at the upper left corner of the 3-by-3 pixel region, and arranging P8-P2 in a reverse order along the counterclockwise direction;

when P1 is equal to 1, judging a central point eight neighborhood; when the following 4 conditions are simultaneously met, setting P1 as 0;

under the condition (1), N (P1) is more than or equal to 2 and less than or equal to 6

Wherein N (P1) ═ P2+ P3+ P4+ P5+ P6+ P7+ P8+ P9; the P2-P9 sequentially represent 8 neighborhood points around the point P1;

condition (2), the number of times F of 01-way ligation in the sequential ordering of P2-P9 is 1;

condition (3), P2 × P4 × P8 is 0;

condition (4), P2 × P6 × P8 is 0;

traversing pixel points in each image, and sequentially performing the thinning and deleting operation;

s3.3, repeating iteration on the binary character image sample, and executing thinning operation until thinning cannot be performed;

s3.4, respectively performing expansion processing on the binary character image samples by using 4 multiplied by 4 structural elements;

and step S4, performing symbol recognition on the expanded binary character image sample, and finally obtaining a recognition result.

Further, the symbol recognition method in step S4 includes the following steps:

s4.1, subtracting the number of holes in the connected domain from the number of the connected domain in the image sample to be recognized to obtain the Euler number of each character image;

s4.2, dividing the image sample to be identified into A type, B type and 8 type according to the Euler number; the Euler number of the type A sample is 1 and comprises a character set {1, 2, 3, 5 and 7}, and the Euler number of the type B sample is 0 and comprises a character set {0, 4, 6 and 9 }; when the Euler number is-1, judging the character as a number 8;

s4.3, scanning the A-type sample image line by line, and recording the length of white pixel points continuously appearing in each line; when the length of the white pixel point is larger than 0.8 time of the width of the sample image, judging that a transverse line appears;

when the horizontal line is positioned on the upper 5 rows, the image is marked as a C-type sample comprising a character set {5, 7}, and when the horizontal line is positioned on the lower 5 rows, the image is marked as a D-type sample comprising a character set {1, 2 }; when no horizontal line appears, judging the character as a number 3; the secondary judgment is performed on the class C and class D samples respectively as follows:

scanning the C-type and D-type sample images row by row, recording the length of white pixel points continuously appearing in each row, and judging that a vertical line appears when the length of the white pixel points exceeds 0.4 time of the height of the image; equally dividing the sample image into 3 columns along the longitudinal direction, wherein the columns comprise a left column, a middle column and a right column;

when the vertical line in the C-type sample image appears in the middle column, judging that the character is a number 1, otherwise, judging that the character is a number 2;

when a vertical line appears in the left column in the D-type sample image, the character is judged to be a numeral 5, and when the vertical line appears in the right column, the character is judged to be a numeral 7;

s4.4, scanning the B-type sample image row by row, recording the length of white pixel points continuously appearing in each row, and judging that a vertical line appears when the length of the white pixel points exceeds 0.4 time of the height of the image; equally dividing the sample image into 3 columns along the longitudinal direction, wherein the columns comprise a left column, a middle column and a right column;

when the vertical line only appears in the left column in the sample image, judging that the character is a numeral 6; when the vertical line only appears in the right column in the sample image, judging that the character is a number 9; when no vertical line exists in the sample image, judging that the character is 4; when the sample image contains the left vertical line and the right vertical line, the sample image is divided into an E-type sample image which comprises a character set {0,6,9 };

for an E-type sample image, detecting row and column coordinates of the hole centroid, scanning the middle column of the image from top to bottom, calculating the times of the scanning line passing through a white pixel area, and recording as the number of vertical middle line intersection points; when the number of the intersecting points of the vertical central lines is 2, judging that the character is a number 0; when the number of the intersecting points of the vertical central lines is more than 2 and the hole mass center is positioned in the upper half area of the image, the character is judged to be a number 9; and when the number of the intersecting points of the vertical central lines is more than 2 and the hole mass center is positioned in the lower half area of the image, judging that the character is a numeral 6.

Further, in step S1, the binary image of the binary character image sample to be recognized is adjusted to 25 × 50 pixels.

Has the advantages that:

the invention firstly provides a detailed image preprocessing scheme, carries out a series of judgments on the pixel neighborhood of a binary character image sample, further carries out thinning and deleting operations on the central point of a partial pixel area, and obtains a clearer image through iterative thinning and expansion processing. And then, a detailed symbol recognition scheme is provided, ten characters from 0 to 9 are divided in detail according to the features by combining three features of the Euler number, the horizontal line feature and the vertical line feature, each character can be rapidly recognized through a small calculation amount, and finally, the rapid and accurate recognition of the medicine label number can be realized. Compared with a method for identifying by single extracted feature, the method can effectively distinguish ten different numbers, and has higher identification precision.

Drawings

FIG. 1a is a schematic diagram of a standard character template provided by the present invention;

FIG. 1b is a schematic diagram of an image sample to be recognized according to the present invention;

FIG. 2 is a schematic diagram of a pixel region mark provided by the present invention;

fig. 3a to 3d are schematic diagrams of pixel regions when N (P1) is 0, 1, 7, and 8, respectively, according to an embodiment of the present invention;

fig. 4a-4b are schematic diagrams of a pixel region when F is 1 and 3, respectively, according to an embodiment of the present invention;

FIG. 5a is a diagram of a refined standard character template according to an embodiment of the present invention;

FIG. 5b is a schematic diagram of a sample of an image to be identified after refinement in an embodiment of the present invention;

FIG. 6a is a schematic diagram of an image after performing dilation processing on a refined standard character template according to an embodiment of the present invention;

FIG. 6b is a schematic diagram of an image obtained by performing dilation processing on a refined image sample to be recognized according to an embodiment of the present invention;

fig. 7 is a schematic diagram of a character recognition method provided by the present invention.

Detailed Description

The present invention will be further described with reference to the accompanying drawings.

The invention provides a medicine label number identification method based on multi-feature extraction, which is specifically divided into two parts; firstly, processing the acquired image; the method specifically comprises the following steps:

s1, collecting and preprocessing an image sample to be identified; dividing an image sample to be identified into a plurality of binary character image samples; and adjusting the size of the binary image of the binary character image sample to be recognized to be 25 × 50 pixels, as shown in fig. 1a-1 b.

And step S2, carrying out normalization processing on the preprocessed binary character image sample, and carrying out image turning to obtain a binary image with white characters and black background.

Step S3, respectively thinning the binary character image sample and the standard character template;

step S3.1, reading an area of any 3 × 3 pixels in the image, and marking the central point of the area as P1; when a certain pixel point is white, the point is marked as P1, and when the certain pixel point is black, the point is marked as P0; setting P9 to be at the upper left corner of the 3 × 3 pixel region, P8-P2 are arranged in reverse order in the counterclockwise direction, as shown in fig. 2.

When P1 is equal to 1, the center point eight neighborhood is determined. When the following 4 conditions are satisfied simultaneously, P1 is set to 0.

Under the condition (1), N (P1) is more than or equal to 2 and less than or equal to 6

Wherein N (P1) ═ P2+ P3+ P4+ P5+ P6+ P7+ P8+ P9; the P2-P9 sequentially represent 8 neighborhood points around the point P1.

When N (P1) is 0, P1 is an isolated point; when N (P1) is 1, P1 is an endpoint; when N (P1) is 7 or 8, P1 is the interior point, as shown in FIGS. 3a-3 d. In all of these four cases, P1 cannot be deleted, and therefore the above condition (1) is restricted.

Condition (2), the number of times F of 01-way connection in the sequential ordering of P2-P9 is 1.

As shown in fig. 4a, only P5-P6 are connected in a 01 manner, so F is 1, and as shown in fig. 4b, P3-P4, P5-P6, and P8-P9 are all connected in a 01 manner, so F is 3. This condition is set to ensure continuity of the image line after the deletion of P1, and as shown in fig. 4b, when F is 3, the image line is cut when the deletion of P1 is performed.

Condition (3), P2 × P4 × P6 is 0;

condition (4), P4 × P6 × P8 is 0.

As is clear from the conditions (3) and (4), the conditions (3) and (4) are satisfied as long as P4 is 0 or P6 is 0. The thinning operation is only to delete the boundary point of the pixel in the southeast direction.

And traversing pixel points in each image, and sequentially carrying out the thinning and deleting operation.

Step S3.2, carrying out refining deletion on the refined image obtained in the step S3.1 again:

reading a region of any 3 x 3 pixels in the image, marking the center point of the region as P1; when a certain pixel point is white, the point is marked as P1, and when the certain pixel point is black, the point is marked as P0; setting P9 to be positioned at the upper left corner of the 3-by-3 pixel region, and arranging P8-P2 in a reverse order along the counterclockwise direction;

when P1 is equal to 1, judging a central point eight neighborhood; when the following 4 conditions are simultaneously met, setting P1 as 0;

under the condition (1), N (P1) is more than or equal to 2 and less than or equal to 6

Wherein N (P1) ═ P2+ P3+ P4+ P5+ P6+ P7+ P8+ P9; the P2-P9 sequentially represent 8 neighborhood points around the point P1;

condition (2), the number of times F of 01-way ligation in the sequential ordering of P2-P9 is 1;

condition (3), P2 × P4 × P8 is 0;

condition (4), P2 × P6 × P8 is 0.

The present refinement is different from the previous refinement in that the conditions (3) and (4) are changed so that the conditions are satisfied as long as P2 or P8 is 0. It shows that the refinement is to delete the boundary point on the northwest of the object.

Traversing pixel points in each image, and sequentially performing the thinning and deleting operation;

s3.3, repeating iteration on the binary character image sample, and executing thinning operation until thinning cannot be performed; the resulting image sample images to be recognized are shown in fig. 5a-5 b.

And S3.4, expanding the binary character image samples by using the 4 multiplied by 4 structural elements respectively. The processed images are shown in fig. 6a-6 b.

The second part is to identify the processed image, and the flow is shown in fig. 7. The method specifically comprises the following steps:

firstly, subtracting the number of holes in the connected domain from the number of the connected domain in the image sample to be recognized to obtain the Euler number of each character image.

Then, dividing the image sample to be identified into A type, B type and 8 type according to the Euler number; the Euler number of the type A sample is 1 and comprises a character set {1, 2, 3, 5 and 7}, and the Euler number of the type B sample is 0 and comprises a character set {0, 4, 6 and 9 }; when the Euler number is-1, the character is judged to be the number 8.

Then, scanning the A-type sample image line by line, and recording the length of white pixel points continuously appearing in each line; when the length of the white pixel point is larger than 0.8 time of the width of the sample image, judging that a transverse line appears;

when the horizontal line is positioned on the upper 5 rows, the image is marked as a C-type sample comprising a character set {5, 7}, and when the horizontal line is positioned on the lower 5 rows, the image is marked as a D-type sample comprising a character set {1, 2 }; when no horizontal line appears, judging the character as a number 3; the secondary judgment is performed on the class C and class D samples respectively as follows:

scanning the C-type and D-type sample images row by row, recording the length of white pixel points continuously appearing in each row, and judging that a vertical line appears when the length of the white pixel points exceeds 0.4 time of the height of the image; equally dividing the sample image into 3 columns along the longitudinal direction, wherein the columns comprise a left column, a middle column and a right column;

when the vertical line in the C-type sample image appears in the middle column, judging that the character is a number 1, otherwise, judging that the character is a number 2;

when a vertical line appears in the left column in the D-type sample image, the character is judged to be a numeral 5, and when the vertical line appears in the right column, the character is judged to be a numeral 7;

scanning the B-type sample image row by row, recording the length of white pixel points continuously appearing in each row, and judging that a vertical line appears when the length of the white pixel points exceeds 0.4 time of the height of the image; equally dividing the sample image into 3 columns along the longitudinal direction, wherein the columns comprise a left column, a middle column and a right column;

when the vertical line only appears in the left column in the sample image, judging that the character is a numeral 6; when the vertical line only appears in the right column in the sample image, judging that the character is a number 9; when no vertical line exists in the sample image, judging that the character is 4; when the sample image contains the left vertical line and the right vertical line, the sample image is divided into an E-type sample image which comprises a character set {0,6,9 };

for an E-type sample image, detecting row and column coordinates of the hole centroid, scanning the middle column of the image from top to bottom, calculating the times of the scanning line passing through a white pixel area, and recording as the number of vertical middle line intersection points; when the number of the intersecting points of the vertical central lines is 2, judging that the character is a number 0; when the number of the intersecting points of the vertical central lines is more than 2 and the hole mass center is positioned in the upper half area of the image, the character is judged to be a number 9; and when the number of the intersecting points of the vertical central lines is more than 2 and the hole mass center is positioned in the lower half area of the image, judging that the character is a numeral 6.

The method classifies 10 characters into A, B, C three character sets by Euler number of character image, then uses horizontal line characteristic to divide A character set into C and D character sets, uses vertical line characteristic to distinguish specific digit and confusable E character set for B, C and D character sets, and finally distinguishes specific digit category for E character set by detecting hole centroid position and vertical central line intersection number.

The above description is only of the preferred embodiments of the present invention, and it should be noted that: it will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the principles of the invention and these are intended to be within the scope of the invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:基于胎儿超声影像特征组学的染色体异常预测模型的构建方法及诊断设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!