Picture segmentation method for complex background small package commodity character extraction

By using aspect ratio scores to select text areas and improving the water drop algorithm in the surface text segmentation of small packaging products, the problem of low accuracy of complex backgrounds and diverse font segmentation is solved, and efficient and accurate text segmentation effect is achieved.

CN119888750AInactive Publication Date: 2025-04-25NANTONG UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411808932.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-04-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art when segmenting the text on the surface of small-package products, the accuracy rate is low in the face of complex backgrounds and diverse fonts, which affects the subsequent text recognition effect.

Method used

A single text and multiple text areas are selected using aspect ratio scores for secondary segmentation, and an improved water droplet algorithm is proposed. Through edge detection and minimum external rectangle positioning, combined with water droplet droplet drop rules and permeation operations, efficient segmentation of diverse texts is achieved.

Benefits of technology

It improves the accuracy and efficiency of text segmentation on the surface of small-package products, reduces the amount of calculation, and adapts to the segmentation needs of complex backgrounds and diverse fonts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888750A_ABST
    Figure CN119888750A_ABST
Patent Text Reader

Abstract

The invention discloses a picture segmentation method for complex background small-package commodity character extraction, and the method comprises the steps: reading a small-package commodity picture, and sorting out a single-character region and a multi-character region; carrying out secondary segmentation on the areas of the plurality of characters, outputting a curve graph of the number of characters and the number of black pixels in the areas of the plurality of characters, and determining a falling starting point and a reference point; taking the falling starting point as a starting dripping point, and selecting a corresponding water drop falling rule according to a comparison result of the abscissa of the falling starting point and the abscissa of the reference point so as to carry out segmentation of the water drop on the region of the plurality of characters; and when the drop of the water drops encounters an obstacle, executing penetration operation, and reselecting the drop rule of the water drops according to the comparison result of the abscissa of the penetration point and the abscissa of the reference point until the segmentation of the plurality of character regions is completed. The method can efficiently and accurately complete the segmentation of diversified characters on the surfaces of small-package commodities.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of digital image processing and text segmentation, and in particular relates to an image segmentation method for extracting text from small-packaged commodities in complex backgrounds. Background Art

[0002] Small packaged goods refer to products of relatively small size and weight, which are commonly found in many industries such as food, cosmetics, and medicine. Small packaged goods usually have patterns and text printed on their surface. The text on the surface of small packaged goods has various fonts, sizes, and colors, and the arrangement and layout are irregular. In industries such as warehousing and logistics, it is necessary to extract the text information on the packaging to achieve fast sorting.

[0003] At present, when extracting text information on packaging, the connected domain analysis method is usually used to first segment the connected pixel area in the binary image as the text area, and then perform text recognition on the text area. The accuracy of text segmentation will directly affect the accuracy of subsequent text recognition. However, when faced with complex backgrounds and diverse fonts such as text on the surface of small packaged goods, the accuracy of text segmentation based on the connected domain analysis method is low, which significantly affects the subsequent text recognition effect.

[0004] The invention with publication number CN107480682B discloses a method for detecting the production date of commodity packaging, which uses a dripping algorithm and a run-length smoothing algorithm to segment and extract the extracted production date characters and the extracted production date character labels to obtain a single production date character and a single production date character label. However, this invention requires the use of a recurrent neural network algorithm and a convolutional neural network algorithm, which requires a large amount of calculation. The invention with publication number CN107507334A discloses a method, device, equipment and storage medium for recognizing the denomination of banknotes, and proposes to first divide single characters and multiple characters, and then use a dripping algorithm to segment the multi-character image into single character images, which can reduce the amount of calculation to a certain extent. However, due to the problem of selecting the location of the dripping point, the water droplets are prone to cause incorrect segmentation due to the irregular strokes of the text, and it is difficult to adapt to the segmentation of diversified text. The invention with publication number CN113971803A discloses a method for segmenting connected characters in an image and related equipment, and proposes a method for selecting the starting low drop point of a drip algorithm. However, the invention is mainly intended to avoid the phenomenon that the selected initial drip point may be in the depression of the character or inside the character, which may cause erroneous segmentation. It also cannot solve the technical problem of erroneous segmentation caused by irregular strokes of the characters, and is difficult to adapt to the segmentation of diversified characters. Summary of the invention

[0005] The present invention discloses an image segmentation method for extracting text from small-packaged goods in complex backgrounds. The method selects a single-text area and a multiple-text area according to the aspect ratio, and then performs secondary segmentation on the multiple-text areas in the binary image. An improved water drop algorithm is proposed, thereby effectively segmenting the text on the surface of small-packaged goods with low calculation amount and high efficiency.

[0006] A method for image segmentation for extracting text from small packaged goods with complex backgrounds, the method comprising the following steps:

[0007] S1, read the small package product image and convert it into a binary image, obtain all the contours of the binary image, process and filter the contours, select the area of ​​single text and the area of ​​multiple texts, and complete the preliminary segmentation;

[0008] S2, performing secondary segmentation on the region of the multiple characters in the binary image, outputting a graph of the number of characters and the number of black pixels in the region of the multiple characters, and determining the falling starting point and the reference point according to the number of characters, the length of the region of the multiple characters and the graph of the number of black pixels;

[0009] S3, taking the falling starting point as the starting dropping point, and selecting a corresponding water drop falling rule to segment the multiple text regions by the water drop according to the comparison result of the horizontal coordinates of the falling starting point and the reference point; wherein, when the water drop encounters an obstacle, a penetration operation is performed, and according to the comparison result of the horizontal coordinates of the penetration point and the reference point, the water drop falling rule is reselected until the segmentation of the multiple text regions is completed;

[0010] S4, checking and screening the segmentation results;

[0011] S5, output the segmented image.

[0012] Step S1 further comprises:

[0013] Read the small package product image and call the cvtColor function in OpenCV to convert the image into a grayscale image;

[0014] Use adaptive thresholding method to convert grayscale image into binary image;

[0015] Call the findContours function in OpenCV to obtain all contours of the binary image, close all contours, and keep the innermost contour;

[0016] Call the boundingRect function in OpenCV to calculate the minimum enclosing rectangle that retains the contour;

[0017] Calculate the aspect ratio of the minimum enclosing rectangle and separate the single-character area and multiple-character area.

[0018] As a preferred example, if the aspect ratio of the minimum circumscribed rectangle of the outline is less than 1.5, the corresponding area is classified as the area of ​​a single character, otherwise it is classified as the area of ​​multiple characters.

[0019] As a preferred example, in step S2, the wide sides of multiple text areas in the binary image are used as the horizontal axis, and the black pixels are vertically projected row by row. The number of black pixels in each row is used as the vertical axis value, and the long sides of the multiple text areas are used as the horizontal axis to generate a black pixel number curve graph.

[0020] As a preferred example, in step S2, the number of characters in the region of multiple characters is determined by the following formula:

[0021]

[0022] Wherein: L represents the length of the area of ​​multiple characters, W represents the width of the area of ​​multiple characters, and NUM represents the number of characters.

[0023] As a preferred example, in step S2, the process of determining the falling starting point and the reference point includes the following steps:

[0024] The long sides of multiple text areas are evenly divided into NUM equal parts, and (NUM-1) division points are obtained. The division points are used as the starting points of the drop. The lowest trough near each starting point of the drop in the black pixel number curve is used as the corresponding reference point. The horizontal coordinate array of the starting point of the drop is set to P{p1, p2, p3..., p n}, n = NUM-1, the corresponding reference point horizontal coordinate array is Q{q1, q2, q3..., q n}, n=NUM-1.

[0025] As a preferred example, the process of selecting corresponding water drop falling rules to segment the regions of multiple characters by water drops includes the following steps:

[0026] Assume that the current water drop position is numbered (x0, y0), and the position numbers of the five pixels around the water drop position are (x0-1, y0), (x0-1, y0+1), (x0, y0+1), (x0+1, y0+1), and (x0+1, y0);

[0027] Set the first water drop falling rule and the second water drop falling rule; wherein the first water drop falling rule includes: if the five pixels around the water drop position are all white or all black, then drop to the pixel point (x0, y0+1); if the pixel point (x0-1, y0+1) is white and at least one of the other four pixels is black, then drop to the pixel point (x0-1, y0+1); if the pixel point (x0-1, y0+1) is black and the pixel point (x0, y0+1) is white, then drop to the pixel point (x0, y0+1); if If the pixel (x0-1, y0+1) and the pixel (x0, y0+1) are black, and the pixel (x0+1, y0+1) is white, then it will fall to the pixel (x0+1, y0+1); if the pixel (x0-1, y0+1), the pixel (x0, y0+1), and the pixel (x0+1, y0+1) are all black, and the pixel (x0+1, y0) is white, then it will fall to the pixel (x0+1, y0); if the pixel (x0-1, y0) is white and the other four pixels are all black, then it will fall to the pixel (x0+1, y0). The second water drop falling rule includes: if the five pixels around the water drop position are all white or all black, then the water drop falls to the pixel (x0, y0+1); if the pixel (x0+1, y0+1) is white and at least one of the other four pixels is black, then the water drop falls to the pixel (x0+1, y0+1); if the pixel (x0+1, y0+1) is black and the pixel (x0, y0+1) is white, then the water drop falls to the pixel (x0, y0+1); if the pixel (x0+1, y0+1) is black and the pixel (x0, y0+1) is white, then the water drop falls to the pixel (x0, y0+1); 1) If the pixel (x0, y0+1) is black and the pixel (x0-1, y0+1) is white, then it will drop to the pixel (x0-1, y0+1); if the pixel (x0-1, y0+1), the pixel (x0, y0+1), and the pixel (x0+1, y0+1) are all black, and the pixel (x0-1, y0) is white, then it will drop to the pixel (x0-1, y0); if the pixel (x0+1, y0) is white and the other four pixels are all black, then it will drop to the pixel (x0+1, y0);

[0028] When a water drop encounters an obstacle, a penetration operation is performed, the midpoint of the fallen pixel in the current row is selected, and the pixel directly below it is used as the penetration point, and the penetration point is used as the next falling point.

[0029] As a preferred example, according to the comparison result of the horizontal coordinates of the penetration point and the reference point, the process of reselecting the water drop falling rule includes the following steps:

[0030] The horizontal coordinates of the penetration point and the reference point are subtracted. When the difference is non-negative, the water drop follows the first water drop falling rule and continues to segment multiple text areas; when the difference is negative, the water drop follows the second water drop falling rule and continues to segment multiple text areas.

[0031] Step S4 further comprises:

[0032] Check whether there are intersecting segmentation lines in the segmentation result;

[0033] The weight is calculated based on the inclination angle of the line connecting the starting point and the end point of the cross dividing line, and the distance between the end point and the reference point, so as to retain the correct dividing line.

[0034] As a preferred example, the weight calculation formula is as follows:

[0035]

[0036] Among them: w represents the weight of the cross-dividing line, α represents the inclination angle of the line connecting the starting point and the end point of the cross-dividing line, d represents the distance between the end point and the reference point, and L represents the length of the area of ​​multiple characters.

[0037] The beneficial effects of the present invention are:

[0038] The image segmentation method for extracting text from small packaged goods with complex backgrounds of the present invention uses edge detection and the minimum circumscribed rectangle to complete the positioning of the text area and the preliminary segmentation of the text, and then uses the aspect ratio of the minimum circumscribed rectangle as a judgment basis to select the text area that needs to be further segmented, and uses the improved drip algorithm to segment it, and finally accurately obtains the segmentation result of each single word. The present invention can efficiently and accurately complete the segmentation of diversified text on the surface of small packaged goods. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 This is a flow chart of the image segmentation method for extracting text from small packaged goods with complex backgrounds according to the present invention;

[0040] Figure 2 It is a schematic diagram of the original image and binary image of the surface of a small packaged product;

[0041] Figure 3 It is a schematic diagram of an image of a segmented single character area;

[0042] Figure 4 It is a schematic diagram of an image of a plurality of text regions segmented;

[0043] Figure 5 It is a schematic diagram of an image after the secondary segmentation of the regions of multiple characters;

[0044] Figure 6This is a schematic diagram of the current water drop position (x0, y0) and the positions of the five pixels around it;

[0045] Figure 7 Schematic diagram of the six falling priorities of water drop falling rule A. Figure 7 (1) to (6) in the figure correspond to the six falling priorities of the water drop falling rule A;

[0046] Figure 8 This is a schematic diagram of the six falling priorities of the water drop falling rule B. Figure 8 (1) to (6) in FIG. 5 correspond to the six falling priorities of the water drop falling rule B respectively. DETAILED DESCRIPTION

[0047] The following examples will enable those skilled in the art to more fully understand the present invention, but are not intended to limit the present invention in any way.

[0048] This embodiment discloses a method for image segmentation for extracting text from small packaged goods with complex backgrounds, the method comprising the following steps:

[0049] S1, read the small package product image and convert it into a binary image, obtain all the contours of the binary image, process and filter the contours, select the area of ​​single text and the area of ​​multiple texts, and complete the preliminary segmentation;

[0050] S2, performing secondary segmentation on the region of the multiple characters in the binary image, outputting a graph of the number of characters and the number of black pixels in the region of the multiple characters, and determining the falling starting point and the reference point according to the number of characters, the length of the region of the multiple characters and the graph of the number of black pixels;

[0051] S3, taking the falling starting point as the starting dropping point, and selecting a corresponding water drop falling rule to segment the multiple text regions by the water drop according to the comparison result of the horizontal coordinates of the falling starting point and the reference point; wherein, when the water drop encounters an obstacle, a penetration operation is performed, and according to the comparison result of the horizontal coordinates of the penetration point and the reference point, the water drop falling rule is reselected until the segmentation of the multiple text regions is completed;

[0052] S4, checking and screening the segmentation results;

[0053] S5, output the segmented image.

[0054] like Figure 1 The method for segmenting text on the surface of a small packaged commodity shown includes:

[0055] S110, read the small package product image and convert it into a binary image, such as Figure 2 shown.

[0056] Specifically, read the picture of small package goods, call the cvtColor function in OpenCV to convert the picture into a grayscale image, use the adaptive threshold method to convert the grayscale image into a binary image, set the Gaussian convolution kernel size to 99*99, and then subtract 2 from the calculated Gaussian mean of the field as the binarization threshold, set the pixel values ​​in the image whose grayscale values ​​are less than the threshold to 0, and set the pixel values ​​greater than the threshold to 255, and obtain a binary image; this step removes the noise in the image through binarization with an adaptive threshold, significantly enhances the contrast between text and background, and improves the efficiency of subsequent image processing.

[0057] S120, obtaining all contours of the binary image, and processing and screening the contours.

[0058] Specifically, use the findContours function in OpenCV to find all contours, define the kernel size of the closing operation as 5*5, and perform a closing operation on each contour. The closing operation can connect some discontinuous contours due to noise interference, thereby improving the accuracy and efficiency of subsequent contour screening and minimum enclosing rectangle calculation. The contours after the closing operation are screened and the innermost contour is retained.

[0059] S130, calculating the aspect ratio of the minimum bounding rectangle of the retained outline and the minimum bounding rectangle, selecting the single character area and the multiple character area according to the aspect ratio, and completing the preliminary segmentation, such as Figure 3 and Figure 4 shown.

[0060] Specifically, the boundingRect function in OpenCV is used to calculate the minimum enclosing rectangle that retains the outline, and the length and width of the minimum enclosing rectangle are obtained. The ratio of the length to the width of the minimum enclosing rectangle is calculated, and the area with a ratio less than 1.5 is classified as the area of ​​a single character, and the remaining area is classified as the area of ​​multiple characters that require secondary segmentation. This step completes the preliminary segmentation, obtains the area of ​​a single character that has been segmented and the area of ​​multiple characters that require secondary segmentation, avoids repeated segmentation, and ensures the efficiency of the program.

[0061] S140, performing secondary segmentation on the regions of the multiple characters in the binary image, and outputting the segmented images, such as Figure 5 shown.

[0062] Specifically, the ratio of the length to the width of the region of multiple characters is calculated, and the number of characters is determined based on this value. The formula is as follows:

[0063]

[0064] Wherein: L represents the length of the area of ​​multiple characters, W represents the width of the area of ​​multiple characters, and NUM represents the number of characters.

[0065] With the wide sides of multiple text areas in the binary image as the horizontal axis, the black pixels are projected vertically row by row, the number of black pixels in each row is used as the vertical axis value, and the long sides of the multiple text areas are used as the horizontal axis to generate a black pixel number curve graph.

[0066] The long sides of multiple text areas are evenly divided into NUM equal parts, and (NUM-1) division points are obtained. The division points are used as the starting points of the drop. The lowest trough near each starting point of the drop in the black pixel number curve is used as the corresponding reference point. The horizontal coordinate array of the starting point of the drop is set to P{p1, p2, p3..., p n}, n = NUM-1, the corresponding reference point horizontal coordinate array is Q{q1, q2, q3..., q n}, n=NUM-1.

[0067] Defines droplet rule A, droplet rule B, and penetration rule. Figure 6 , Figure 7 and Figure 8 Assuming that the current position of the water drop is (x0, y0), its falling rule is to determine the next falling position of the water drop based on the information of the five pixels around (x0, y0).

[0068] Assume that the five pixels around (x0, y0) are pixel (x0-1, y0), pixel (x0-1, y0+1), pixel (x0, y0+1), pixel (x0+1, y0+1) and pixel (x0+1, y0), such as Figure 6 Specifically, Figure 7 As shown, the water drop rule A consists of six drop priorities, the current priority takes precedence over the next priority, and the six drop priorities are as follows:

[0069] Priority 1: If all five pixels are white or all black, then they fall to (x0, y0+1);

[0070] Priority 2: (x0-1, y0 + 1) is white, and at least one of the other four pixels is black, then it falls to (x0-1, y0+1);

[0071] Priority three: (x0-1, y0+1) is black, and (x0, y0+1) is white, then it falls to (x0, y0+1);

[0072] Priority 4: (x0-1, y0+1) and (x0, y0+1) are black, and (x0+1, y0+1) is white, then it falls to (x0+1, y0+1);

[0073] Priority 5: (x0-1, y0+1)(x0, y0+1)(x0+1, y0+1) are all black, and (x0+1, y0) is white, then it falls to (x0+1, y0);

[0074] Priority six: (x0-1, y0) is white, and the other four pixels are all black, then it falls to (x0-1, y0).

[0075] Specifically, Figure 8 As shown, the water drop rule B consists of six drop priorities, the current priority takes precedence over the next priority, and the six drop priorities are as follows:

[0076] Priority 1: If all five pixels are white or all black, then they fall to (x0, y0+1);

[0077] Priority 2: (x0+1, y0+1) is white, and at least one of the other four pixels is black, then it falls to (x0+1, y0+1);

[0078] Priority three: (x0+1, y0+1) is black, and (x0, y0+1) is white, then it falls to (x0, y0+1);

[0079] Priority 4: (x0+1, y0+1) and (x0, y0+1) are black, and (x0-1, y0+1) is white, then it falls to (x0-1, y0+1);

[0080] Priority 5: (x0-1, y0+1)(x0, y0+1)(x0+1, y0+1) are all black, and (x0-1, y0) is white, then it falls to (x0-1, y0);

[0081] Priority six: (x0+1, y0) is white, and the other four pixels are all black, then it falls to (x0+1, y0).

[0082] exist Figure 7 and Figure 8 In the figure, ● represents the coordinate point of the current water drop, w represents a white pixel, b represents a black pixel, * represents a pixel that may be white or black, w / b represents a pixel that is white or black in different situations, and w(b) represents a pixel that may be white or black in different situations.

[0083] Specifically, the penetration rule is to select the midpoint of the pixels that have fallen in the current row, and then use the pixel directly below it as the penetration point, that is, the next falling point. Assuming that the pixels that have fallen in the current row are (x0-n, y0), ... (x0-2, y0), (x0-1, y0), (x0, y0), then the penetration point is

[0084] Take the falling starting point as the starting drop point, and set the horizontal coordinate array P{p1, p2, p3..., pn } , n = NUM-1 and the corresponding reference point abscissa array Q {q1, q2, q3..., q n}, n = NUM-1, and obtain the difference array S{s1, s2, s3..., s n}, n = NUM-1. When s n When s ≥ 0, the water drop follows the water drop falling rule A to segment multiple text areas; when s n When <0, the water drop follows the water drop falling rule B to divide multiple text areas.

[0085] When a water drop encounters an obstacle, that is, the next falling point is a pixel point that has been passed, the above-mentioned penetration operation is performed, and the horizontal coordinates of the penetration point and the reference point are subtracted; when the difference is non-negative, the water drop follows the water drop falling rule A and continues to segment multiple text areas; when the difference is negative, the water drop follows the water drop falling rule B and continues to segment multiple text areas. In summary, choosing a more appropriate water drop falling rule at the beginning of dripping and after penetration avoids incorrect segmentation of water drops due to irregular strokes of text.

[0086] S150: After completing the segmentation of the plurality of text regions, check the segmentation results, and if there are intersecting segmentation lines, screen the segmentation lines based on two indicators.

[0087] Specifically, the above two indicators include the inclination angle of the line connecting the starting point and the end point of the cross dividing line, and the distance between the end point and the reference point. The weight formula of the two indicators is as follows:

[0088]

[0089] Among them: w represents the weight of the cross-dividing line, α represents the inclination angle of the line connecting the starting point and the end point of the cross-dividing line, d represents the distance between the end point and the reference point, and L represents the length of the area of ​​multiple characters.

[0090] Finally, the segmentation lines with larger weights among the cross segmentation lines are retained, and the segmented image is output.

[0091] In summary, by checking and screening the segmentation results of multiple text regions, the accuracy of segmentation can be significantly improved.

[0092] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.

Claims

1. A method for image segmentation for extracting text from small packaged goods with complex backgrounds, characterized in that: The method comprises the following steps: S1, read the small package product image and convert it into a binary image, obtain all the contours of the binary image, process and filter the contours, select the area of ​​single text and the area of ​​multiple texts, and complete the preliminary segmentation; S2, performing secondary segmentation on the region of the multiple characters in the binary image, outputting a graph of the number of characters and the number of black pixels in the region of the multiple characters, and determining the falling starting point and the reference point according to the number of characters, the length of the region of the multiple characters and the graph of the number of black pixels; S3, taking the falling starting point as the starting dropping point, and selecting a corresponding water drop falling rule to segment the multiple text regions by the water drop according to the comparison result of the horizontal coordinates of the falling starting point and the reference point; wherein, when the water drop encounters an obstacle, a penetration operation is performed, and according to the comparison result of the horizontal coordinates of the penetration point and the reference point, the water drop falling rule is reselected until the segmentation of the multiple text regions is completed; S4, checking and screening the segmentation results; S5, output the segmented image.

2. The image segmentation method for extracting text from small packaged goods in complex background according to claim 1 is characterized in that: Step S1 further comprises: Read the small package product image and call the cvtColor function in OpenCV to convert the image into a grayscale image; Use adaptive thresholding method to convert grayscale image into binary image; Call the findContours function in OpenCV to obtain all contours of the binary image, close all contours, and keep the innermost contour; Call the boundingRect function in OpenCV to calculate the minimum enclosing rectangle that retains the contour; Calculate the aspect ratio of the minimum enclosing rectangle and separate the single-character area and multiple-character area.

3. The image segmentation method for extracting text from small packaged goods in complex background according to claim 2 is characterized in that: If the aspect ratio of the minimum circumscribed rectangle of the outline is less than 1.5, the corresponding area is classified as a single character area, otherwise it is classified as a multiple character area.

4. The image segmentation method for extracting text from small packaged goods in complex background according to claim 1 is characterized in that: In step S2, the black pixels are vertically projected row by row with the wide sides of the multiple text areas in the binary image as the horizontal axis, the number of black pixels in each row is used as the vertical axis value, and the long sides of the multiple text areas are used as the horizontal axis to generate a black pixel number curve graph.

5. The image segmentation method for extracting text from small packaged goods in complex background according to claim 1 is characterized in that: In step S2, the number of characters in the region of multiple characters is determined using the following formula: Wherein: L represents the length of the area of ​​multiple characters, W represents the width of the area of ​​multiple characters, and NUM represents the number of characters.

6. The image segmentation method for extracting text from small packaged goods in complex background according to claim 1 is characterized in that: In step S2, the process of determining the falling starting point and the reference point includes the following steps: The long sides of multiple text areas are evenly divided into NUM equal parts, and (NUM-1) division points are obtained. The division points are used as the starting points of the drop. The lowest trough near each starting point of the drop in the black pixel number curve is used as the corresponding reference point. The horizontal coordinate array of the starting point of the drop is set to P{p1, p2, p3..., p n }, n = NUM-1, the corresponding reference point abscissa array is Q{q1,q2,q3...,q n },n=NUM-1.

7. The image segmentation method for extracting text from small packaged goods in complex background according to claim 1 is characterized in that: The process of selecting corresponding water drop falling rules to segment the water droplets on the regions of multiple characters includes the following steps: Assume that the current water drop position is numbered (x0, y0), and the position numbers of the five pixels around the water drop position are (x0-1, y0), (x0-1, y0+1), (x0, y0+1), (x0+1, y0+1), and (x0+1, y0); Set the first water drop falling rule and the second water drop falling rule; wherein the first water drop falling rule includes: if the five pixels around the water drop position are all white or all black, then drop to the pixel point (x0, y0+1); if the pixel point (x0-1, y0+1) is white and at least one of the other four pixels is black, then drop to the pixel point (x0-1, y0+1); if the pixel point (x0-1, y0+1) is black and the pixel point (x0, y0+1) is white, then drop to the pixel point (x0, y0+1); if If the pixel points (x0-1, y0+1) and the pixel point (x0, y0+1) are black, and the pixel point (x0+1, y0+1) is white, then it will fall to the pixel point (x0+1, y0+1); if the pixel points (x0-1, y0+1), the pixel point (x0, y0+1), and the pixel point (x0+1, y0+1) are all black, and the pixel point (x0+1, y0) is white, then it will fall to the pixel point (x0+1, y0); if the pixel point (x0-1, y0) is white and the other four pixels are all black, then it will fall to the pixel point (x0+1, y0). The second water drop falling rule includes: if the five pixels around the water drop position are all white or all black, then the water drop falls to the pixel (x0, y0+10; if the pixel (x0+1, y0+1) is white and at least one of the other four pixels is black, then the water drop falls to the pixel (x0+1, y0+1); if the pixel (x0+1, y0+1) is black and the pixel (x0, y0+1) is white, then the water drop falls to the pixel (x0, y0+1); if the pixel (x0+1, y0+1) is black and the pixel (x0, y0+1) is white, then the water drop falls to the pixel (x0, y0+1); 1) If the pixel (x0, y0+1) is black and the pixel (x0-1, y0+1) is white, then it will drop to the pixel (x0-1, y0+1); if the pixel (x0-1, y0+1), the pixel (x0, y0+1), and the pixel (x0+1, y0+1) are all black, and the pixel (x0-1, y0) is white, then it will drop to the pixel (x0-1, y0); if the pixel (x0+1, y0) is white and the other four pixels are all black, then it will drop to the pixel (x0+1, y0); When a water drop encounters an obstacle, a penetration operation is performed, the midpoint of the fallen pixel in the current row is selected, and the pixel directly below it is used as the penetration point, and the penetration point is used as the next falling point.

8. The image segmentation method for extracting text from small packaged goods in complex background according to claim 7, characterized in that: According to the comparison result of the horizontal coordinates of the penetration point and the reference point, the process of reselecting the water drop falling rule includes the following steps: The horizontal coordinates of the penetration point and the reference point are subtracted. When the difference is non-negative, the water drop follows the first water drop falling rule and continues to segment multiple text areas; when the difference is negative, the water drop follows the second water drop falling rule and continues to segment multiple text areas.

9. The image segmentation method for extracting text from small packaged goods in complex background according to claim 1, characterized in that: Step S4 further comprises: Check whether there are intersecting segmentation lines in the segmentation result; The weight is calculated based on the inclination angle of the line connecting the starting point and the end point of the cross dividing line, and the distance between the end point and the reference point, so as to retain the correct dividing line.

10. The image segmentation method for extracting text from small packaged goods in complex background according to claim 9, characterized in that: The weight is calculated as follows: Among them: w represents the weight of the cross-dividing line, α represents the inclination angle of the line connecting the starting point and the end point of the cross-dividing line, d represents the distance between the end point and the reference point, and L represents the length of the area of ​​multiple characters.

Citation Information

Patent Citations

  • A method for detecting the production date of commodity packaging

    CN107480682B

  • Note denomination identification method and device, equipment and storage medium

    CN107507334A

  • Method for segmenting adhered characters in image and related equipment

    CN113971803A