An image segmentation method, a target detection device and a computer readable storage medium
By extracting and processing the points to be segmented on the contour in material image segmentation, the problem of low segmentation accuracy caused by linear connection is solved, and more efficient and accurate image segmentation is achieved.
Patent Information
- Application Number
- CN202410542690.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2044-04-30
AI Technical Summary
Existing material image segmentation technology has difficulty in accurately handling the problem of linear connections, resulting in low accuracy of segmentation results, which seriously affects the accuracy and efficiency of segmentation.
By extracting the image contour, traversing the information and occurrence frequency of each point on the contour, determining the points with an occurrence frequency greater than 1 as the points to be segmented, and performing image segmentation based on the information of the points to be segmented, including the processing of relative position information.
It improves the accuracy and efficiency of image segmentation, reduces the amount of calculation, ensures the accuracy and real-time performance of segmentation, and is suitable for a variety of materials and sorting environments.
Smart Images

Figure CN119919424B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of material sorting, and particularly to an image segmentation method, a target detection device and a computer readable storage medium. BACKGROUND
[0002] In the process of material sorting, it is necessary to segment the overlapped or adhered material images in order to facilitate subsequent identification and classification of the materials. In the process of image segmentation, the problem of line connection between materials is often encountered. Such line connection can be manifested as only a few pixel connections between two materials or a line segment connection composed of multiple points. Current material image segmentation techniques are difficult to segment two materials with line connection, require a large amount of calculation, have low segmentation result accuracy, and seriously affect the accuracy, precision and efficiency of segmentation. SUMMARY
[0003] To overcome the problems in the related art, an exemplary embodiment of a first aspect of the present disclosure provides an image segmentation method, comprising: extracting an outline of an image according to the image; sequentially traversing the outline according to each point on the outline to determine information and occurrence frequency of each point on the outline; determining points with an occurrence frequency greater than 1 as to-be-segmented points according to the occurrence frequency of each point on the outline; and performing image segmentation according to to-be-segmented point information, wherein the to-be-segmented point information comprises relative position information of the to-be-segmented points.
[0004] In some embodiments, the image segmentation according to the to-be-segmented point information comprises: for a first to-be-segmented point that is not adjacent to other to-be-segmented points, segmenting at the first to-be-segmented point to make the first to-be-segmented point belong to one of the contours after segmentation; and for two second to-be-segmented points that are adjacent to each other, segmenting between the two second to-be-segmented points to make the two second to-be-segmented points belong to different contours after segmentation, respectively.
[0005] In some embodiments, the to-be-segmented point information further comprises a to-be-segmented point quantity, and the image segmentation according to the to-be-segmented point information further comprises: determining a current unsegmented to-be-segmented point quantity; if the current unsegmented to-be-segmented point quantity is 1, performing the segmentation on the current unsegmented to-be-segmented point according to the segmentation on the first to-be-segmented point not adjacent to other to-be-segmented points, segmenting at the first to-be-segmented point on the contour where the first to-be-segmented point is located, and attributing the first to-be-segmented point to one of the contours after segmentation; if the current unsegmented to-be-segmented point quantity is greater than or equal to 2, confirming relative positions between the two closest to-be-segmented points; if the two to-be-segmented points are adjacent, performing the segmentation on the two to-be-segmented points according to the segmentation on the second to-be-segmented point adjacent to other to-be-segmented points, segmenting at the second to-be-segmented point on the contour where the second to-be-segmented point is located, and attributing the two second to-be-segmented points to different contours after segmentation respectively; if the two to-be-segmented points are not adjacent, performing the segmentation on the two to-be-segmented points respectively according to the segmentation on the first to-be-segmented point not adjacent to other to-be-segmented points, segmenting at the first to-be-segmented point on the contour where the first to-be-segmented point is located, and attributing the first to-be-segmented point to one of the contours after segmentation; and if the current unsegmented to-be-segmented point quantity is not 0, returning to perform the determination of the current unsegmented to-be-segmented point quantity.
[0006] In some embodiments, the image segmentation according to the to-be-segmented point information further comprises: if the current unsegmented to-be-segmented point quantity is 1, confirming a contour where the current unsegmented to-be-segmented point is located; and if the current unsegmented to-be-segmented point quantity is greater than or equal to 2, confirming contours where the two closest to-be-segmented points are located respectively.
[0007] In some embodiments, the image segmentation according to the to-be-segmented point information further comprises: according to the current to-be-segmented point, confirming whether the to-be-segmented point is adjacent to other to-be-segmented points; if the to-be-segmented point is not adjacent to other to-be-segmented points, performing the segmentation on the first to-be-segmented point not adjacent to other to-be-segmented points, segmenting at the first to-be-segmented point on the contour where the first to-be-segmented point is located, and attributing the first to-be-segmented point to one of the contours after segmentation; and if the to-be-segmented point is adjacent to other to-be-segmented points, performing the segmentation on the second to-be-segmented point adjacent to other to-be-segmented points, segmenting at the second to-be-segmented point on the contour where the second to-be-segmented point is located, and attributing the two second to-be-segmented points to different contours after segmentation respectively.
[0008] In some embodiments, the image segmentation according to the to-be-segmented point information further comprises: for three or more adjacent third to-be-segmented points, the contour in which the third to-be-segmented points are located is segmented into two contours, and part of the third to-be-segmented points belong to one of the segmented contours, and the other part of the third to-be-segmented points belong to the other segmented contour.
[0009] In some embodiments, the extracting the contour of the image according to the image comprises: performing a binaryzation process on the image to obtain a binary image; and extracting the contour of the binary image according to the binary image.
[0010] In some embodiments, the image segmentation method further comprises: detecting concave points in the image to obtain a plurality of concave points; pairing the concave points two by two to form one or more pairs of concave points, wherein each concave point belongs to only one pair of concave points; connecting the two concave points corresponding to each pair of concave points to form the segmentation line; and performing image segmentation according to the segmentation line.
[0011] In a second aspect, the disclosure also provides a target detection device, wherein the target detection device comprises an image segmentation module that executes the image segmentation method of the first aspect.
[0012] In a third aspect, the disclosure also provides a computer-readable storage medium storing a program for executing the image segmentation method of any one of the first aspect.
[0013] The technical solution provided by the embodiments of the disclosure can have the following beneficial effects: through the image segmentation method, the to-be-segmented points are determined according to the frequency of each point on the image contour by traversing the image contour, the part of the image connected in a line shape can be accurately extracted, and the part connected in a line shape can be accurately segmented, the to-be-segmented points are determined through the contour extraction and contour traversal method, the calculation amount is smaller, the efficiency of image segmentation can be improved, the accuracy of image segmentation is effectively improved, and the segmentation accuracy is higher.
[0014] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0015] The disclosure can be better understood by describing the exemplary embodiments of the disclosure in conjunction with the accompanying drawings, in which:
[0016] Figure 1 is a structure schematic diagram of a sorting device according to an exemplary embodiment of the disclosure;
[0017] Figure 2is a diagram of an image to which linear connection occurs according to an exemplary embodiment of the present disclosure;
[0018] Figure 3 is a flowchart of an image segmentation method according to an exemplary embodiment of the present disclosure
[0019] Figure 4 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure
[0020] Figure 5 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure
[0021] Figure 6 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure
[0022] Figure 7 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure
[0023] Figure 8 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure
[0024] Figure 9 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure
[0025] Figure 10 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure
[0026] Figure 11 is a schematic block diagram of a material sorting system according to an exemplary embodiment of the present disclosure
[0027] Figure 12 is a schematic block diagram of an electronic device according to an exemplary embodiment of the present disclosure DETAILED DESCRIPTION
[0028] The specific embodiments of the present disclosure will be described below. It should be noted that in the specific description of these embodiments, in order to provide a concise description, this specification cannot provide a detailed description of all the features of the actual embodiments. It should be understood that in the actual implementation of any embodiment, just as in the process of any engineering project or design project, in order to achieve the specific goals of the developer and to meet system-related or business-related restrictions, various specific decisions are often made, and this will also change from one embodiment to another. In addition, it is also understandable that although the efforts made in this development process may be complex and lengthy, for ordinary technicians in the field related to the content disclosed by this disclosure, some design, manufacturing or production changes based on the technical content disclosed by this disclosure are just conventional technical means and should not be understood as the content of this disclosure being insufficient.
[0029] Unless otherwise defined, the technical or scientific terms used in the claims and description shall have the usual meaning understood by persons of ordinary skill in the technical field to which the present disclosure belongs. The words "first", "second" and similar terms used in the patent application description and claims of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Words such as "one" or "a" do not indicate a quantity limitation, but rather indicate the existence of at least one. Words such as "include" or "comprising" mean that the elements or objects appearing before "include" or "comprising" cover the elements or objects listed after "include" or "comprising" and their equivalents, and do not exclude other elements or objects. Words such as "connected" or "connected" and similar terms are not limited to physical or mechanical connections, nor are they limited to direct or indirect connections.
[0030] like Figure 1 As shown, the material sorting equipment can be used to sort materials, and may include a feeding mechanism 110, a transmission mechanism 120, a detection mechanism 130 and a sorting device 140. The feeding mechanism 110 is used to feed the material to be sorted into the transmission mechanism 120. The transmission mechanism 120 may be a structure such as a conveyor belt or a chute, which is used to transport the material to be sorted fed by the feeding mechanism 110. The detection mechanism 130 is used to detect the material transported on the transmission mechanism 120 to detect whether the material is material to be rejected; the material to be rejected refers to the material to be separated by the sorting equipment. The material to be rejected may be the required material or the unrequired material, as long as the material can be sorted. The sorting device 140 is used to reject the material to be rejected. The material sorting equipment can be used for sorting ores, and can also be used for tasks such as food sorting or waste sorting.
[0031] In the process of sorting by the material sorting device, the target materials to be sorted are close to each other, and line connection occurs. The line connection refers to a case where only a few pixels are connected between two targets, such as Figure 2 (a), (b), (e), and (f) show that the two targets are close to each other, but there is no actual overlap or adhesion. It may be due to the low image clarity and poor imaging effect of the image acquisition device during the image acquisition process, which causes the image edge of the part where the two target materials are close to each other to be blurred, such as Figure 2 (c), (d), (g), and (h) show that a few pixel points of the two target materials are connected in the image, and line connection occurs. After the target material image is acquired, the image generally needs to be binarized to reduce the image data volume and facilitate detection and recognition. For multiple targets close to each other, the binarization may incorrectly classify the gray gradient region of the target edge as black, resulting in pixel connection between the target images and line connection. This line connection causes the originally independent targets to appear connected in the image, which causes the detection mechanism 130 to incorrectly identify multiple target materials as one material during the detection of the target materials, and the materials cannot be correctly identified and sorted. In addition, generally, for the images of the target materials that overlap or adhere, a concave point detection method is used for segmentation. For the line-connected materials, the concave point detection method cannot extract the concave points or the concave points cannot be registered, which reduces the sorting accuracy. Therefore, the detection mechanism 130 of the material sorting device needs to segment multiple targets that are line-connected when detecting the materials, so as to distinguish the multiple line-connected targets.
[0032] In some related technologies, the line-connected targets are segmented by traditional algorithms, such as extracting image concave points for segmentation by concave point detection, or eliminating or weakening the influence of line connection by morphological operation or filtering technology. However, the current technical method has a large error in image processing of line-connected targets, and segmentation errors often occur. Since the line-connected targets are connected by only a few pixel points, the concave point detection method cannot accurately extract the concave points or cannot register the extracted concave points, thereby causing the multiple line-connected targets to be unable to be segmented or causing segmentation errors, which reduces the accuracy and efficiency of image segmentation. Since the image segmentation technology is mainly used in the sorting process of the material sorting device, the process of processing the line-connected targets by morphological operation or filtering technology needs to be adjusted and optimized for different materials and material sorting environments, which has poor universality and flexibility, and can only weaken the influence of line connection, but cannot completely eliminate the line connection between the targets.
[0033] To solve the above problems, as Figure 3As shown, the exemplary embodiments of the present disclosure provide an image segmentation method, which can include steps S110 to S140, which are described below in detail:
[0034] In step S110, the contour of the image is extracted according to the image. The image can be obtained by an image acquisition device, or can be obtained by reading a storage containing multiple targets in the memory. In some cases, the image containing multiple targets can also be obtained by generating an image, and the image can contain multiple targets, and there can be a linear connection between the multiple targets.
[0035] In step S120, the contour is sequentially and completely traversed according to each point on the contour, and the information and frequency of each point on the contour are determined. A point on the contour can be taken as a starting point, and all points on the contour can be sequentially traversed until the starting point is returned. The contour can be an external contour common to all targets in the image. In some cases, there are two linear connections between two targets in the image, and the contour is traversed, and only the external contour common to the two targets is traversed, and the contour of each target between the two linear connections is not traversed. Therefore, only the external contour of the image is traversed during the traversal of the contour, and the information and frequency of each point are recorded. The order of traversing the contour can be determined according to the order of extracting the contour in step S110, and the points on the contour can be traversed in a clockwise or counterclockwise order. During the traversal of the contour, the coordinates of each point on the contour in the image and the frequency of each point can be recorded. The points on the contour can be counted by key-value pairs, the key being the coordinates of each point on the contour, and the value being the frequency of each point. During the traversal of the contour, each point appears once, and the value is added once, until all points on the contour are traversed and the starting point is returned. After the traversal of the contour is completed, the coordinates of each point on the contour and the corresponding frequency can be obtained.
[0036] In step S130, the points with a frequency greater than 1 are determined as the points to be segmented according to the frequency of each point on the contour. According to the coordinates and frequency of each point on the contour determined in step S120, the information of the points to be segmented can be determined. For the target image without linear connection, after the traversal of the contour is completed, the frequency of each point obtained is 1, that is, each point is recorded only once during the traversal of the contour. For the image with linear connection, such as Figure 2 、 Figure 2As shown, in the process of traversing the contour, due to the linear connection between the two targets, the points at the linear connection appear multiple times in the process of sequentially traversing the image contour, and the recorded frequency of appearance is greater than 1. Therefore, the points with an appearance frequency greater than 1 are located at the linear connection and need to be segmented, and the points with an appearance frequency greater than 1 can be identified as the points to be segmented. Taking any point on the contour as a starting point, sequentially traverse each point on the contour, take any point on the contour as a starting point, visit each point on the contour, visit each point, record the coordinates of the visited point, and the visit frequency of each visited point, which is the appearance frequency of each point in the process of traversing the contour. For the target with linear connection, there are very few pixel points connected at the linear connection, which are the points to be segmented. Since the points to be segmented are connected to the external contours of the two targets with linear connection, in the process of traversing the contour, starting from any point on one target, sequentially traversing the image contour, visiting the linear connection, then traversing the contour of the other target, then sequentially visiting the linear connection again, until the last visit to the starting point, the traversal of the contour is completed. After completing the contour traversal, the points on the contours of the two targets have an appearance frequency of 1, and the points at the linear connection have an appearance frequency of 2, so the points with an appearance frequency greater than 1 can be identified as the points to be segmented.
[0037] In step S140, image segmentation is performed according to the information of the points to be segmented, wherein the information of the points to be segmented includes relative position information of the points to be segmented. For the points on the contour with an appearance frequency greater than 1, it can be determined that the point is located at the linear connection, and therefore the points with an appearance frequency greater than 1 are determined as the points to be segmented for segmentation. Since the points to be segmented are pixel points at the linear connection, the image can be segmented at the points to be segmented. The attribution of the points to be segmented can be determined according to the information of the points to be segmented, so as to determine the position for image segmentation, so that the points to be segmented belong to the contour of one of the targets after segmentation, and one contour containing multiple targets in the image is segmented into multiple contours. Each contour obtained after segmentation corresponds to one target. According to the points to be segmented, the position of linear connection can be accurately and quickly determined, and image segmentation according to the points to be segmented can make the segmentation more accurate. The information of the points to be segmented can include relative position information of the points to be segmented. The absolute position information of the points to be segmented, i.e. the coordinates of the points to be segmented in the image, can be obtained according to steps S120 and S130. The relative position information of the points to be segmented can be determined through the absolute position information of the points to be segmented. The relative position information of the points to be segmented can include the relative position of the current points to be segmented and other points to be segmented, which can be the relative position coordinates of the current points to be segmented and other points to be segmented, or the distance between the current points to be segmented and other points to be segmented.
[0038] By the image segmentation method of the present disclosure, the contour of the target can be quickly and accurately determined by extracting the contour of the image, the position of the target is located, and the efficiency of image segmentation can be effectively improved. When applied to a material sorting device, it can meet the real-time processing needs of the material sorting device, has good real-time performance, and the contour extraction can be suitable for a variety of different. By traversing the points on the contour, the information and frequency of each point are determined, and the segmentation point is determined. The segmentation point can be accurately obtained, the position of the linear connection between the targets is located, and the accuracy is high, thereby effectively improving the accuracy of image segmentation. By traversing each point on the contour, each point on the image can be recorded and processed, and the data analysis accuracy is higher, which can effectively avoid the decision risk caused by inaccurate data, reduce the error rate of data processing, and improve the accuracy of image segmentation. According to the information of the segmentation point, only one or more pixel points need to be calculated, the data calculation amount is smaller, the data processing time is short, the image segmentation method of the present disclosure has a faster response speed, can meet the real-time processing needs of the material sorting device, and has good real-time performance. In addition, the image segmentation method of the present disclosure has good expansibility and adaptability, can adapt to a variety of different materials and sorting environments, and can meet the data processing needs in different fields and different scenarios.
[0039] In some embodiments, as shown in FIG. 1 4, the step S140 of performing image segmentation according to the information of the segmentation point can include steps S141 and S142. Figure 4
[0040] In step S141, for a first segmentation point 10 that is not adjacent to other segmentation points, the contour in which the first segmentation point 10 is located is segmented at the first segmentation point 10, and the first segmentation point 10 is attributed to one of the contours after segmentation. As shown in FIG. 1 4 (a), the first segmentation point 10 can be adjacent to other segmentation points, and the contour in which the first segmentation point 10 is located can be segmented at the first segmentation point 10, and the first segmentation point 10 is attributed to one of the contours after segmentation. Figure 2 (c), the first segmentation point 10 can be adjacent to other segmentation points, and the contour in which the first segmentation point 10 is located can be segmented at the first segmentation point 10, and the first segmentation point 10 is attributed to one of the contours after segmentation.
[0041] In step S142, for two adjacent second segmentation points 20, the contour in which the two second segmentation points 20 are located is segmented between the two second segmentation points 20, and the two second segmentation points 20 are attributed to different contours after segmentation. As shown in FIG. 1 4 (b), the two second segmentation points 20 can be adjacent to each other, and the contour in which the two second segmentation points 20 are located can be segmented between the two second segmentation points 20, and the two second segmentation points 20 are attributed to different contours after segmentation. Figure 2 (g)As shown, the second segmentation point 20 can be adjacent to other segmentation points. For two adjacent second segmentation points 20, segmentation can be performed on the contour in which the two second segmentation points 20 are located, and the segmentation position can be located between the two second segmentation points 20, so that the two second segmentation points 20 can belong to different contours after segmentation. After the contour in which the two second segmentation points 20 are located is segmented, two contours are obtained, the second segmentation point 20 is attributed to the contour closest to its location, and the two second segmentation points 20 are attributed to two different contours.
[0042] In some embodiments, an arbitrary segmentation point can be selected, and whether the current segmentation point is adjacent to other segmentation points can be determined according to the relative position relationship of the current segmentation point and other segmentation points, so as to distinguish the segmentation points and determine the specific method of image segmentation. Whether the segmentation points are adjacent can be determined according to the position information of the segmentation points. A distance threshold of the segmentation points can be set, and the distance threshold can be 2 pixels. According to the position information of the segmentation points, the distance between the current segmentation point and other segmentation points is calculated. When the distance is less than or equal to the distance threshold, the two segmentation points are considered to be adjacent. When the distance is greater than the distance threshold, the two segmentation points are considered to be not adjacent.
[0043] In other embodiments, whether the segmentation points are adjacent can also be determined by 8-neighborhood. An arbitrary segmentation point can be selected, and the 8-neighborhood of the current segmentation point is determined, which includes the 8 points around the current segmentation point, i.e., the upper, lower, left, right, upper left, upper right, lower left, and lower right of the current segmentation point. If the 8-neighborhood of the current segmentation point does not contain other segmentation points, the current segmentation point is not adjacent to other segmentation points. If other segmentation points are located in the 8-neighborhood of the current segmentation point, the current segmentation point is adjacent to the segmentation points in the 8-neighborhood.
[0044] By steps S141 and S142, the segmentation points can be distinguished into first segmentation points 10 and second segmentation points 20 according to the relative position information of the segmentation points, and different segmentation processing can be performed on the contours in which different segmentation points are located. This can adapt to various line connection conditions, can perform differential processing according to different image line connection conditions through a single algorithm, has higher image segmentation accuracy, and has higher universality and flexibility.
[0045] In some embodiments, the segmentation point information can also include the number of segmentation points, such as Figure 5 As shown, step S140 of performing image segmentation according to the segmentation point information can also include steps S143 to S145.
[0046] Step S143, determine the number of current unsegmented points to be segmented. First, the number of current unsegmented points to be segmented can be determined, which can be determined according to the points to be segmented determined in step S130, for the case that at least one image segmentation has been performed, the number of current unsegmented points to be segmented can be determined according to the number of points to be segmented determined in step S130 and the number of segmentations, or the new points to be segmented information can be obtained by traversing each contour again in the segmented image.
[0047] If the number of current unsegmented points to be segmented is 1, step S141 can be performed on the current unsegmented point to be segmented, for the first point to be segmented 10 which is not adjacent to other points to be segmented, for the contour where the first point to be segmented 10 is located, segmentation is performed at the first point to be segmented 10, so that the first point to be segmented 10 belongs to one of the contours after segmentation. In the case that the number of current unsegmented points to be segmented is 1, the current unsegmented point to be segmented is not adjacent to other points to be segmented, so the current unsegmented point to be segmented can be the first point to be segmented 10, and the image can be segmented at the first point to be segmented 10, so that the first point to be segmented 10 belongs to one of the two contours after segmentation. After completing the segmentation, the number of current unsegmented points to be segmented can be confirmed again, and it can be determined that the number of current unsegmented points to be segmented is 0, which can indicate that the image segmentation has been completed.
[0048] If the number of current unsegmented points to be segmented is greater than or equal to 2, step S144 can be performed to confirm the relative positions between the two closest points to be segmented. If the two points to be segmented are adjacent, step S142 is performed on the two points to be segmented, and for the two adjacent second points to be segmented 20, segmentation is performed at the second points to be segmented 20 for the contour in which the second points to be segmented 20 are located, so that the two second points to be segmented 20 are respectively attributed to different contours after segmentation. If the two points to be segmented are not adjacent, step S141 is performed for the first point to be segmented 10 that is not adjacent to other points to be segmented, and for the contour in which the first point to be segmented 10 is located, segmentation is performed at the first point to be segmented 10, so that the first point to be segmented 10 is attributed to one of the contours after segmentation. The number of current unsegmented points to be segmented can be determined, and in the case that the number of current unsegmented points to be segmented is 2, the relative position information between the two points to be segmented can be confirmed. In the case that the two points to be segmented are adjacent, the points to be segmented can be determined as second points to be segmented 20, step S142 is performed to segment the image at the two second points to be segmented 20, and a segmented contour image is obtained. In the case that the two points to be segmented are not adjacent, the points to be segmented can be determined as first points to be segmented 10, step S141 is performed to segment the image at the two first points to be segmented 10, and a segmented contour image is obtained. After segmentation, the number of current unsegmented points to be segmented can be confirmed again, and if the number of current unsegmented points to be segmented is 0, it can be indicated that the segmentation of the image has been completed.
[0049] In the case that the number of current unsegmented segmentation points is greater than 2, the two closest segmentation points can be determined according to the segmentation point information, the relative position information between the two segmentation points is determined, in the case that the two segmentation points are adjacent, the segmentation point can be determined as the second segmentation point 20, and steps S142 are performed on the two segmentation points. In the case that the two segmentation points are not adjacent, the two segmentation points can be determined as the first segmentation point 10, and step S141 is performed. After the image segmentation at the two closest segmentation points is completed, the number of current unsegmented segmentation points can be determined again, if the number of current unsegmented segmentation points is not 0, step S143 is returned to determine the number of current unsegmented segmentation points. After the image segmentation at the two closest segmentation points is completed, one or more unsegmented segmentation points can still be included in the image, for these segmentation points, step S143 can be returned to determine the number of current unsegmented segmentation points, and the image segmentation is continued according to the number, if the number of current unsegmented segmentation points is 1, step S141 can be performed, if the number of current unsegmented segmentation points is greater than or equal to 2, step S144 can be performed, the segmentation point information can be determined and segmented continuously until the number of unsegmented segmentation points is 0, and the image segmentation is completed. According to the number of unsegmented segmentation points and the relative position information, the image segmentation method is determined, which can accurately determine the image segmentation method suitable for the segmentation point in the process of image segmentation, has higher accuracy, can detect and segment at most two segmentation points at a time, has higher efficiency, and can meet the real-time requirement when the image segmentation method of the present disclosure is applied to the sorting device, and has higher efficiency.
[0050] In some embodiments, as shown in FIG. 14, step S140 of performing image segmentation according to the segmentation point information can further include: if the number of current unsegmented segmentation points is 1, step S145 is performed to determine the contour in which the current unsegmented segmentation point is located; and if the number of current unsegmented segmentation points is greater than or equal to 2, step S146 is performed to determine the contour in which each of the two closest segmentation points is located. Figure 6 If the number of current unsegmented segmentation points is 1, the contour in which the current unsegmented segmentation point is located can be determined according to step S145, which facilitates the determination of the position of the segmentation point and the determination of the contour target to be segmented next, thereby avoiding incorrect segmentation of the contour. If the number of current unsegmented segmentation points is greater than or equal to 2, the contour in which each of the two closest segmentation points is located can be determined according to step S146. The contour in which each of the two closest segmentation points is located can be determined, so as to determine the attribution of each segmentation point, thereby facilitating the subsequent image segmentation.
[0051] During image segmentation, if the number of points to be segmented is greater than or equal to 3, two or more segmentations are required. After one segmentation, a contour in the image is segmented into two different contours. Directly continuing to segment the contour may result in segmentation errors or incorrect attribution of the points to be segmented. Therefore, after reconfirming the number of unsegmented points to be segmented, steps S145 and S146 are performed to determine the contours where the points to be segmented are located, and accurately segment the contours where the points to be segmented are located. This ensures the accuracy of image segmentation, and effectively avoids segmentation errors or incorrect attribution of the points to be segmented, especially in the case of multiple points to be segmented.
[0052] In some embodiments, as Figure 7 As shown, step S140, performing image segmentation based on the information of the points to be segmented, may also include: step S147, based on the current point to be segmented, determining whether the current point to be segmented is adjacent to other points to be segmented. If the point to be segmented is not adjacent to the other points to be segmented, step S141 is executed; if the point to be segmented is adjacent to the other points to be segmented, step S142 is executed. Any point to be segmented can be directly selected as the current point to be segmented, and step S147 is executed to determine whether the current point to be segmented is adjacent to the other points to be segmented. If so, the current point to be segmented is the first point to be segmented 10, and step S141 is executed on the current point to be segmented, performing segmentation at the current point to be segmented, so that the current point to be segmented belongs to either of the two contours obtained after segmentation. If not, the current point to be segmented and the points to be segmented adjacent to the current point to be segmented are both second points to be segmented 20. Step S142 is executed on the two second points to be segmented 20, performing segmentation between the two second points to be segmented 20, and so that the two second points to be segmented 20 respectively belong to the two contours obtained after segmentation. The adjacent relationship between the current point to be segmented and other points to be segmented can be determined by distance. If the distance between the two points to be segmented is less than or equal to the distance threshold, the two points to be segmented are adjacent; if the distance between the two points to be segmented is greater than the distance threshold, the two points to be segmented are not adjacent. The adjacent relationship between the current point to be segmented and other points to be segmented can also be determined by 8 neighborhoods. Taking the current point to be segmented as the benchmark, other points to be segmented within its 8 neighborhoods are adjacent to the current point to be segmented, and other points to be segmented outside its 8 neighborhoods are not adjacent to the current point to be segmented. By confirming the adjacent relationship between each point to be segmented and other points to be segmented, the image segmentation process has higher data accuracy, and can make more accurate image segmentation decisions for each point to be segmented, reducing the error rate of data processing. In addition, this embodiment confirms the adjacent relationship of each point to be segmented one by one, has a simpler image segmentation processing logic, a small amount of data calculation, and a short processing time, which can make the image segmentation have a faster response speed and meet the real-time requirements for image segmentation in the material sorting process.
[0053] In some embodiments, asFigure 8 As shown, in step S140, the image segmentation according to the to-be-segmented point information can further include: for three or more adjacent third to-be-segmented points, the contour in which the third to-be-segmented points are located is segmented into two contours, and part of the third to-be-segmented points belong to one of the two segmented contours, and the other part of the third to-be-segmented points belong to the other of the two segmented contours. For the case of three or more adjacent to-be-segmented points, the to-be-segmented points can be collinear. For three or more adjacent to-be-segmented points, since the to-be-segmented points are continuously adjacent, segmenting each to-be-segmented point respectively can cause segmentation errors or the existence of isolated pixel points after segmentation. Therefore, the to-be-segmented points can be segmented only once, and the three or more adjacent to-be-segmented points are divided into two different parts, so that the to-be-segmented points in the two parts belong to the two contours after segmentation respectively, and part of the third to-be-segmented points belong to one of the two segmented contours, and the other part of the third to-be-segmented points belong to the other of the two segmented contours. In the case of an odd number of adjacent to-be-segmented points, a midpoint can be taken between the adjacent to-be-segmented points, and the midpoint is segmented at the position of the midpoint and belongs to any of the two contours after segmentation. In the case of an even number of adjacent to-be-segmented points, the two central to-be-segmented points can be taken, and the two to-be-segmented points are segmented between the two to-be-segmented points and belong to the two different contours after segmentation respectively. By segmenting the three or more adjacent to-be-segmented points in step S148, repeated segmentation can be avoided, image segmentation errors can be prevented, and the existence of isolated pixel points after segmentation can be avoided. The error rate of image segmentation is reduced, the accuracy of image segmentation is improved, and the adaptability is better according to different linear connection conditions.
[0054] In some embodiments, as shown in FIG. 1, the image segmentation method comprises the following steps: Figure 9 As shown, in step S110, the contour of the image is extracted according to the image, which comprises: in step S111, the image is binarized to obtain a binary image; and in step S112, the contour of the binary image is extracted according to the binary image. The image can be subjected to step S111 to perform binarization on the image, and the pixel point gray value on the image is set to 0 or 255, which can effectively simplify the image, effectively reduce the data amount in the image, and thus effectively reduce the calculation amount of subsequent detection and segmentation of the image and improve the efficiency of image segmentation. The image after binarization processing can be obviously distinguished from the background, and the target is more clear, which facilitates the extraction of the contour according to the binary image in step S112. The extraction of the contour after binarization processing can make the extracted contour more clear and accurate. The binarization processing has a smaller data calculation amount, improves the edge information acquisition speed, and thus improves the speed of image segmentation and has better real-time performance.
[0055] In some embodiments, as shown in FIG. 1, the image segmentation method comprises the following steps: Figure 10As shown, the image segmentation method can further include: step S150, performing concave point detection according to the image to obtain a plurality of concave points; step S160, pairing the plurality of concave points two by two to form one or more concave point pairs, wherein each concave point belongs to only one concave point pair; step S170, connecting the two concave points corresponding to each concave point pair to form a segmentation line; and step S180, performing image segmentation according to the segmentation line. In the case where the targets overlap or adhere, step S150 can be performed to detect the lowest points on the image edges by concave point detection to obtain a plurality of concave points to locate the positions where the overlap or adhesion occurs. According to the concave points obtained in the image, step S160 can be performed to pair each concave point two by two to determine the concave point pairs so that each concave point is paired only once to avoid repeated pairing. By performing step S170, the two concave points in each concave point pair are connected to determine the segmentation line. Then, the image segmentation is completed according to the contour in combination with the segmentation line. Steps S150 to S180 can segment the target image where the overlap or adhesion occurs. Steps S150 to S180 can be performed in parallel with the method of performing image segmentation according to the to-be-segmented point information in the foregoing embodiments to simultaneously detect and process the image, or can be performed in series before or after the method of performing image segmentation according to the to-be-segmented point information to determine the concave point pairs by concave point detection to determine the segmentation line, so that the image segmentation method provided by the present disclosure can process the target image where the overlap or adhesion occurs. Moreover, the image provided by steps S110 to S140 can be reasonably, accurately and quickly segmented. Through steps S150 to S180, the image segmentation method can segment the target where the linear connection occurs while segmenting other targets where the overlap or adhesion occurs by the method of concave point detection, so that the image segmentation method can adapt to various different situations and can be applied to different sorting environments to segment the images in different situations, and has good expansibility and adaptability.
[0056] Based on the same inventive concept, as Figure 11 As shown, the present disclosure further provides a target detection device 200, wherein the target detection device 200 includes an image segmentation module 210 that performs the image segmentation method of any of the foregoing embodiments. The image segmentation module 210 can segment the image according to the image segmentation method of any of the foregoing embodiments to quickly and accurately complete the contour image segmentation of the linearly connected target so that one target corresponds to one independent contour. As to the target detection device in the foregoing embodiments, the specific manner in which each module performs the operation has been described in detail in the embodiments related to the method, and will not be described in detail here.
[0057] Based on the same inventive concept, the disclosure also provides a computer readable storage medium storing a program for executing the image segmentation method of any of the preceding embodiments.
[0058] As shown in Figure 12 An embodiment of the disclosure provides an electronic device 300. The electronic device 300 includes a memory 310, a processor 320, and an input / output (I / O) interface 330. The memory 310 is configured to store instructions. The processor 320 is configured to invoke the instructions stored in the memory 310 to execute the image segmentation method of the embodiments of the disclosure. The processor 320 is connected to the memory 310 and the I / O interface 330, for example, through a bus system and / or other forms of connection mechanism (not shown). The memory 310 can be configured to store programs and data, including the programs of the image segmentation method involved in the embodiments of the disclosure. The processor 320 executes various functional applications and data processing of the electronic device 300 by running the programs stored in the memory 310.
[0059] The processor 320 in the embodiments of the disclosure can be implemented in at least one of a hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 320 can be a central processing unit (CPU) or a combination of one or more of other forms of processing units having data processing capabilities and / or instruction execution capabilities.
[0060] The memory 310 in the embodiments of the disclosure can include one or more computer program products, which can include various forms of computer readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may, for example, include random access memory (RAM), cache memory, and the like. The non-volatile memory may, for example, include read-only memory (ROM), flash memory, a hard disk drive (HDD), a solid-state drive (SSD), and the like.
[0061] In the embodiments of the present disclosure, the I / O interface 330 can be configured to receive input instructions (e.g., digital or character information, and generate key signal inputs related to user settings and function control of the electronic device 300, etc.), and can also output various information (e.g., images or sounds, etc.) to the outside. The I / O interface 330 in the embodiments of the present disclosure can include one or more of a physical keyboard, function keys (such as volume control keys, on-off keys, etc.), a mouse, a joystick, a trackball, a microphone, a speaker, and a touch panel, etc.
[0062] The present application uses certain terms to describe the embodiments of the present application. As used in the description of the application and the appended claims, the terms "one embodiment," "an embodiment,” and / or "some embodiments” means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one implementation of the present application. The appearances of the phrase "in one embodiment” or "in an embodiment” or "in some embodiments” in various places in the specification are not necessarily all referring to the same embodiment.
[0063] In the context of the present application, the terms "a," "an," and / or "the" do not exclude a plurality, and "a" or "an" means "one or more” of such elements, unless otherwise specified. The use of the term "includes” means "comprises” or "consists of” in the described text, in which "consisting of” does not exclude additional steps or elements which are not specifically disclosed.
[0064] Similarly, it is to be noted that, in the interest of clarity and not limiting the application in an undesirable way, the above description has not included all the features and steps which are useful to those having ordinary skill in the art to which the application pertains. Furthermore, no element, component, or method step in the present disclosure is intended to be dedicated or activated to more than one claimed application during the lifetime of a patent covering the application.
[0065] The above description has described basic concepts, and it is obvious to those skilled in the art that the above disclosure is only used as an example and does not limit the application. Although it is not explicitly stated here, those skilled in the art can make various modifications, improvements and corrections to the present application. Such modifications, improvements and corrections are suggested in the present application, so such modifications, improvements and corrections still belong to the spirit and scope of the embodiments of the present application.
Claims
1. An image segmentation method, comprising: Extracting a contour of the image according to the image; According to each point on the contour, the contour is completely traversed in order to determine the information and frequency of occurrence of each point on the contour; According to the occurrence frequency of each point on the contour, the point with an occurrence frequency greater than 1 is determined as a point to be segmented; Image segmentation is performed according to information of points to be segmented, including: for a first point to be segmented that is not adjacent to other points to be segmented, segmenting the contour where the first point to be segmented is located at the first point to be segmented, so that the first point to be segmented belongs to one of the contours after segmentation; for two adjacent second points to be segmented, segmenting the contour where the two second points to be segmented are located between the two second points to be segmented, so that the two second points to be segmented respectively belong to different contours after segmentation, wherein the information of the points to be segmented includes relative position information of the points to be segmented.
2. The image segmentation method according to claim 1, wherein: The information of the points to be segmented further includes the number of the points to be segmented, and the image segmentation according to the information of the points to be segmented further includes: Determine the number of the points to be segmented that are currently unsegmented; If the number of the currently unsegmented points to be segmented is 1, then performing the segmentation on the currently unsegmented points to be segmented for the first point to be segmented that is not adjacent to the other points to be segmented, and segmenting the contour where the first point to be segmented is located at the first point to be segmented, so that the first point to be segmented belongs to one of the contours after segmentation; If the number of the currently undivided points to be segmented is greater than or equal to 2, then for the two points to be segmented that are closest to each other, determining the relative position between the two points to be segmented; If two points to be segmented are adjacent, the method for performing the step of segmenting the two adjacent second points to be segmented is performed on the two points to be segmented, and segmenting the contour where the second points to be segmented are located at the second points to be segmented, so that the two second points to be segmented respectively belong to different contours after segmentation. If the two points to be segmented are not adjacent, the method of segmenting the contour where the first point to be segmented is located is performed on each of the two points to be segmented, such that the first point to be segmented belongs to one of the contours after segmentation. If the number of the currently unsegmented points to be segmented is not 0, the step of determining the number of the currently unsegmented points to be segmented is returned.
3. The image segmentation method according to claim 2, wherein: The image segmentation according to the information of the points to be segmented further includes: If the number of the currently unsegmented points to be segmented is 1, then confirming the contour where the currently unsegmented points to be segmented are located; If the number of the currently unsegmented points to be segmented is greater than or equal to 2, then for the two points to be segmented that are closest to each other, the contours where the two points to be segmented are located are determined.
4. The image segmentation method according to claim 1, wherein: The image segmentation according to the information of the points to be segmented further includes: According to the current point to be segmented, determining whether the current point to be segmented is adjacent to other points to be segmented; If the point to be segmented is not adjacent to other points to be segmented, performing segmentation on the contour where the first point to be segmented is located at the first point to be segmented, so that the first point to be segmented belongs to one of the contours after segmentation; If the point to be segmented is adjacent to other points to be segmented, the step of segmenting the contour where the two adjacent second points to be segmented are located is performed at the second points to be segmented, so that the two second points to be segmented respectively belong to different contours after segmentation.
5. The image segmentation method according to claim 1, wherein: The image segmentation according to the information of the points to be segmented further includes: For three or more adjacent third points to be segmented, the contour where the third points to be segmented are located is segmented into two contours, so that some of the third points to be segmented belong to one contour after segmentation, and the other part of the third points to be segmented belong to the other contour after segmentation.
6. The image segmentation method according to claim 1, wherein: Extracting the contour of the image according to the image includes: According to the image, binarization is performed to obtain a binary image; According to the binary image, a contour of the binary image is extracted.
7. The image segmentation method according to claim 1, wherein: The image segmentation method further comprises: Perform concave point detection according to the image to obtain multiple concave points; Pairing the plurality of concave points in pairs to form one or more concave point pairs, wherein each of the concave points belongs to only one concave point pair; connecting the two concave points corresponding to each concave point pair to form a dividing line; Image segmentation is performed according to the segmentation line.
8. A target detection device, wherein: The target detection device comprises: The image segmentation module executes the image segmentation method according to claims 1-7.
9. A computer-readable storage medium storing the following program, wherein the program is used to execute the image segmentation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Cutting method and device and cutting equipment
CN113771036A
Pleura adhesion type pulmonary parenchyma segmentation method and system
CN115619806A