Image segmentation method, target detection device and computer readable storage medium
By extracting and traversing the outline of the material image, the points to be segmented are determined according to the frequency of occurrence of points, the problem of difficult to segment the linear connection parts in the material image in the prior art is solved, and efficient and accurate image segmentation is achieved.
Patent Information
- Application Number
- CN202410542690.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2044-04-30
AI Technical Summary
The prior art is difficult to accurately segment the linearly connected parts in the material image, resulting in low accuracy of the segmentation result and large calculation amount, which affects the efficiency and accuracy of the segmentation.
By extracting the image outline, traverse the points on the outline, determine the points to be divided according to the frequency of occurrence of points, and perform image segmentation based on the information of the points to be divided.
Accurate segmentation of linearly connected parts in the image is achieved, reducing the calculation amount and improving the efficiency and accuracy of segmentation.
Smart Images

Figure CN119919424A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of material sorting, and in particular to an image segmentation method, a target detection device, and a computer-readable storage medium. Background Art
[0002] In the process of material sorting, it is necessary to segment the overlapping or sticky material images to facilitate the subsequent identification and classification of the materials. In the process of image segmentation, we often face the problem of linear connection between materials. This linear connection may appear as only a few pixels connecting two materials, or a line segment connection composed of multiple points. The current material image segmentation technology is difficult to segment two linearly connected materials, requires a large amount of calculation, and has low accuracy of segmentation results, which seriously affects the accuracy, precision and efficiency of segmentation. Summary of the invention
[0003] In order to overcome the problems existing in the related art, an exemplary embodiment of the first aspect of the present disclosure provides an image segmentation method, comprising: extracting the contour of the image according to the image; traversing the contour in order and completely according to each point on the contour, and determining the information and occurrence frequency of each point on the contour; according to the occurrence frequency of each point on the contour, determining the point with an occurrence frequency greater than 1 as a point to be segmented; performing image segmentation according to the information of the point to be segmented, wherein the information of the point to be segmented includes the relative position information of the point to be segmented.
[0004] In some embodiments, the image segmentation based on the information of the points to be segmented includes: for a first point to be segmented that is not adjacent to other points to be segmented, for the contour where the first point to be segmented is located, segmentation is performed 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, for the contour where the two second points to be segmented are located, segmentation is performed between the two second points to be segmented, so that the two second points to be segmented respectively belong to different contours after segmentation.
[0005] In some embodiments, the information of the points to be segmented also 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: determining the number of the points to be segmented that are not currently segmented; if the number of the points to be segmented that are not currently segmented is 1, then for the points to be segmented that are not currently segmented, performing the segmentation at the first point to be segmented that is not adjacent to other points to be segmented, for the contour where the first point to be segmented is located, so that the first point to be segmented belongs to one of the contours after segmentation; if the number of the points to be segmented that are not currently segmented is greater than or equal to 2, then for the two points to be segmented that are closest to each other, confirming the relative position between the two points to be segmented; if the two points to be segmented are If the two points to be segmented are adjacent, the step of performing the step of performing the step of performing the segmentation on the two adjacent second points to be segmented is performed on the two points to be segmented, and for the contour where the second points to be segmented are located, segmentation 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; if the two points to be segmented are not adjacent, the step of performing the step of performing the step of performing the segmentation on the first point to be segmented which is not adjacent to the other points to be segmented is performed on the two points to be segmented, and for the contour where the first point to be segmented is located, segmentation is performed 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 unsegmented points to be segmented is not 0, the step of determining the number of the currently unsegmented points to be segmented is returned.
[0006] In some embodiments, the image segmentation based on the information of the points to be segmented also includes: if the number of the currently unsegmented points to be segmented is 1, 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, confirming the contours where the two points to be segmented are located respectively.
[0007] In some embodiments, the image segmentation based on the information of the point to be segmented also includes: based on the current point to be segmented, confirming 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, executing the first point to be segmented that is not adjacent to other points to be segmented, for the contour where the first point to be segmented is located, segmenting 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, executing the second point to be segmented for two adjacent points to be segmented, for the contour where the second point to be segmented is located, segmenting at the second point to be segmented, so that the two second points to be segmented respectively belong to different contours after segmentation.
[0008] In some embodiments, the image segmentation based on the information of the points to be segmented also includes: for three or more adjacent third points to be segmented, the contour where the multiple third points to be segmented are located is divided into two contours, so that some of the third points to be segmented belong to one contour after segmentation, and another part of the third points to be segmented belong to another contour after segmentation.
[0009] In some embodiments, extracting the contour of the image according to the image includes: performing binarization processing 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 also includes: performing concave point detection based on the image to obtain multiple concave points; pairing the multiple concave points in pairs to form one or more concave point pairs, wherein each of the concave points belongs to only one of the concave point pairs; connecting the two concave points corresponding to each of the concave point pairs to form the dividing line; and performing image segmentation based on the dividing line.
[0011] In a second aspect, the present disclosure further provides a target detection device, wherein the target detection device comprises: an image segmentation module, executing the image segmentation method as described in the first aspect.
[0012] In a third aspect, the present disclosure further provides a computer-readable storage medium, which stores the following program, wherein the program is used to execute the image segmentation method described in any one of the first aspects.
[0013] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: through the image segmentation method, by traversing the image contour, determining the points to be segmented according to the frequency of occurrence of each point on the image contour, it is possible to accurately extract the linearly connected parts in the image and accurately segment the linearly connected parts. By determining the points to be segmented by the method of contour extraction and traversing the contour, the amount of calculation 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 is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The present disclosure may be better understood by describing exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, in which:
[0016] Figure 1 It is a schematic diagram of the structure of a sorting device according to an exemplary embodiment of the disclosure;
[0017] Figure 2An image showing a linear connection according to an exemplary embodiment of the disclosure;
[0018] Figure 3 This is a flowchart of an image segmentation method according to an exemplary embodiment of the 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] Fig. 9 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure;
[0025] Fig.10 is a flowchart of an image segmentation method according to another exemplary embodiment of the present disclosure;
[0026] Fig.11 is a schematic block diagram of a material sorting system according to an exemplary embodiment of the disclosure;
[0027] Fig.12 It is a schematic block diagram of an electronic device according to an exemplary embodiment of the disclosure. DETAILED DESCRIPTION
[0028] The specific implementation methods of the present disclosure will be described below. It should be noted that in the specific description of these implementation methods, in order to provide a concise description, it is impossible for this specification to provide a detailed description of all the features of the actual implementation methods. It should be understood that in the actual implementation of any implementation method, 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 implementation method to another. In addition, it can also be understood 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 the present disclosure, some changes in design, manufacturing or production based on the technical content disclosed in the present disclosure are just conventional technical means, and should not be understood as insufficient content of the present disclosure.
[0029] Unless otherwise defined, the technical or scientific terms used in the claims and the specification shall have the usual meaning understood by persons with ordinary skills in the technical field to which the present disclosure belongs. The words "first", "second" and similar words used in the patent application specification and the 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 "one" do not indicate a quantitative limitation, but indicate the existence of at least one. Words such as "include" or "comprise" and similar words mean that the elements or objects appearing before "include" or "comprise" include the elements or objects listed after "include" or "comprise" and their equivalent elements, and do not exclude other elements or objects. Words such as "connect" or "connected" and similar words 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 the 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 the sorting of ores, and can also be used for tasks such as food sorting or waste sorting.
[0031] During the sorting process of the material sorting equipment, the target materials to be sorted are close to each other, and a linear connection occurs. A linear connection refers to a situation where there are only a few pixels connecting the two targets, such as Figure 2 As shown in (a), (b), (e), and (f), the two targets are close to each other, but there is no overlap or adhesion in reality. This may be due to the low image clarity and poor imaging effect of the image acquisition device during the process of acquiring the target image, resulting in blurred image edges in the part of the image where the two target materials are close to each other, such as Figure 2 As shown in (c), (d), (g), and (h), the two target materials have very few pixel points connected in the image, resulting in a linear connection. After obtaining the target material image, it is generally necessary to perform binary processing on the image to reduce the amount of image data for easy detection and identification. For multiple targets close to each other, the binary processing may cause the grayscale gradient area on the edge of the target to be mistakenly classified as black, resulting in pixel connections between the target images, resulting in a linear connection. This linear connection makes the originally independent targets appear connected in the image, resulting in the detection mechanism 130 mistakenly identifying multiple target materials as one material during the detection of the target material, and failing to correctly identify and sort the materials. In addition, since the target material images that overlap or adhere are generally segmented by concave point detection, it is difficult to extract the concave points for the linearly connected materials by concave point detection or the concave points cannot be aligned, which reduces the sorting accuracy. Therefore, when performing material detection, the detection mechanism 130 of the material sorting equipment needs to segment the multiple targets that are linearly connected, so as to distinguish the multiple targets that are linearly connected.
[0032] In some related technologies, linearly connected targets are segmented by traditional algorithms, such as extracting image concave points for segmentation through concave point detection, or eliminating or weakening the influence of linear connections through morphological operations or filtering techniques. However, the current technical methods have large image processing errors for linearly connected targets, and segmentation errors are prone to occur. Since there are only a few pixel points connecting linearly connected targets, the concave point detection method cannot accurately extract concave points, or cannot perform registration after extracting concave points, resulting in the inability to segment multiple linearly connected targets, or segmentation errors, resulting in poor accuracy and low efficiency of image segmentation. Since image segmentation technology is mostly used in the sorting process of materials by sorting equipment, in the process of processing linearly connected targets through morphological operations or filtering technologies, it is necessary to adjust and optimize parameters for different materials and material sorting environments, which has poor versatility and flexibility, and can only weaken the influence of linear connections, and cannot completely eliminate linear connections between targets.
[0033] To solve the above problems, Figure 3As shown, an exemplary embodiment of the present disclosure provides an image segmentation method, which may include: Step S110 to Step S140, and the above steps are specifically described below:
[0034] Step S110, extracting the contour of the image according to the image. The image can be acquired by an image acquisition device, or by reading and storing an image containing multiple targets in a memory. In some cases, the image containing multiple targets can also be acquired by generating an image, and the image can contain multiple targets, and there may be linear connections between the multiple targets.
[0035] Step S120, 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. A point on the contour can be used as the starting point, and all points on the contour can be traversed in order until returning to the starting point. The contour can be the common external contour of all targets in the image. In some cases, there are two linear connections between two targets in the image. When traversing the image contour, only the common external contour of the two targets is traversed, and the contours of each target between the two linear connections are not traversed. Therefore, in the process of traversing the contour, only the external contour of the image is traversed, and the information and frequency of occurrence 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 each point on the contour can be traversed in a clockwise or counterclockwise order. In the process of traversing the contour, the coordinates of each point on the contour in the image and the frequency of occurrence of each point can be recorded. The key value can be used to count the points on the contour. The key is the coordinate of each point on the contour, and the value is the frequency of occurrence of each point. In the process of traversing the contour, each point appears once, and the value is accumulated once, until all points on the contour are traversed and return to the starting point. After completing the traversal of the contour, the coordinates of each point on the contour and the corresponding frequency of occurrence can be obtained.
[0036] Step S130, based on the occurrence frequency of each point on the contour, determine the point with an occurrence frequency greater than 1 as the point to be segmented. Based on the coordinates and occurrence frequency of each point on the contour determined in step S120, the information of the point to be segmented can be determined. For a target image with no linear connection, after completing the traversal of the contour, the occurrence frequency of each point obtained is 1, that is, each point is recorded only once in the process of traversing the contour; for an image with linear connection, such as Figure 2 , Figure 2As shown in the figure, in the process of traversing the contour, due to the linear connection between the two targets, in the process of traversing the image contour in sequence, the points at the linear connection appear multiple times, and the recorded frequency of occurrence is greater than 1. Therefore, the points with an occurrence frequency greater than 1 are located at the linear connection and need to be segmented. The points with an occurrence frequency greater than 1 can be identified as points to be segmented. Taking any point on the contour as the starting point, traverse the points on the contour in sequence, starting from any point on the contour, visit the points on the contour, visit each point, record the coordinates of the visited points, and the number of visits to each visited point, the number of visits is the frequency of occurrence of each point in the process of traversing the contour. For targets with linear connections, there are very few pixel points connected at the linear connection, and these pixel points are the points to be segmented. Since the points to be segmented are connected to the outer contours of the two targets with linear connection, in the process of traversing the contour, starting from any point on one target, the image contour is traversed in order until the linear connection is reached, and then the contour of the other target is traversed, and then the linear connection is visited again in order until the starting point is visited and the contour traversal is completed. After the contour traversal is completed, the frequency of occurrence of the points on the contours of the two targets is 1, and the frequency of occurrence of the points at the linear connection is 2, so the points with an occurrence frequency greater than 1 can be confirmed as the points to be segmented.
[0037] 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 the 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 in the linear connection part, so 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. According to the information of the points to be segmented, the ownership of the points to be segmented can be confirmed, thereby determining the position for image segmentation, so that the points to be segmented belong to the contour of one of the targets after segmentation, and a contour containing multiple targets in the image is segmented into multiple contours, each contour obtained after segmentation corresponds to a target, and according to the points to be segmented, the position where the linear connection occurs can be accurately and quickly determined, and the image segmentation is performed according to the points to be segmented, which can make the segmentation accuracy higher. At the same time, the information of the points to be segmented can include the relative position information of the points to be segmented. According to steps S120 and S130, the absolute position information of the points to be segmented can be obtained, that is, the coordinates of the points to be segmented in the image, and 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 may include the relative position of the current point to be segmented and other points to be segmented, may be the relative position coordinates of the current point to be segmented and other points to be segmented, or may be the distance between the current point to be segmented and other points to be segmented.
[0038] By extracting the contour of the image, the image segmentation method disclosed in the present invention can quickly and accurately determine the contour of the target, locate the position of the target, and effectively improve the efficiency of image segmentation. When applied to material sorting equipment, it can meet the needs of real-time processing of the material sorting equipment, and has good real-time performance. At the same time, contour extraction can be applied to a variety of different. By traversing the points on the contour, determining the information and frequency of each point, and determining the points to be segmented, the points to be segmented can be accurately obtained, and the positions of the linear connections between the targets can be located, which has high accuracy, thereby effectively improving the accuracy of image segmentation. By traversing the points on the contour, each point on the image can be recorded and processed, with higher data analysis accuracy, and can effectively avoid the decision-making risks caused by inaccurate data, reduce the error rate of data processing, and improve the accuracy of image segmentation. Image segmentation is performed according to the information of the points to be segmented, and only one or more pixel points need to be calculated, with a smaller amount of data calculation, and a short data processing time, so that the image segmentation method disclosed in the present invention has a faster response speed, can meet the needs of real-time processing of material sorting equipment, and has good real-time performance. In addition, the image segmentation method disclosed in the present invention has good scalability and adaptability, can adapt to a variety of different materials and sorting environments, and can meet the data processing needs in different fields and scenarios.
[0039] In some embodiments, Figure 4 As shown, step S140, performing image segmentation according to information of points to be segmented, may include: step S141 and step S142.
[0040] Step S141, for a first point to be segmented 10 that is not adjacent to other points to be segmented, segment the contour where the first point to be segmented 10 is located, so that the first point to be segmented 10 belongs to one of the contours after segmentation. Figure 2 As shown in (c), the first point to be segmented 10 may not be adjacent to other points to be segmented, and arbitrarily segmentation can be performed directly on a contour where the first point to be segmented 10 is located. The segmentation position is around the first point to be segmented 10, and two contours are obtained after segmentation, so that the first point to be segmented 10 belongs to any contour after segmentation.
[0041] Step S142, for two adjacent second points to be segmented 20, for the contour where the two second points to be segmented 20 are located, segmentation is performed between the two second points to be segmented 20, so that the two second points to be segmented 20 respectively belong to different contours after segmentation. Figure 2As shown in (g), the second point to be segmented 20 may be adjacent to other points to be segmented. For two adjacent second points to be segmented 20, segmentation may be performed on a contour where the two second points to be segmented 20 are located, and the segmentation position may be located between the two second points to be segmented 20, so that the two second points to be segmented 20 can belong to different contours after segmentation. After segmentation of a contour where the two second points to be segmented 20 are located, two contours are obtained, so that the second points to be segmented 20 belong to the contour closest to their location, and the two second points to be segmented 20 belong to two different contours respectively.
[0042] In some embodiments, any point to be segmented can be selected, and whether the current point to be segmented is adjacent to other points to be segmented can be confirmed based on the different relative positional relationships between the current point to be segmented and other points to be segmented, and the points to be segmented can be distinguished, thereby confirming the specific method of image segmentation. Whether the points to be segmented are adjacent can be confirmed based on the position information of the points to be segmented, and a distance threshold of the points to be segmented can be set, and the distance threshold can be 2 pixels. According to the position information of the points to be segmented, the distance between the current point to be segmented and other points to be segmented is calculated. When the distance is less than or equal to the distance threshold, the two points to be segmented can be regarded as adjacent, and when the distance is greater than the distance threshold, the two points to be segmented can be regarded as non-adjacent.
[0043] In other embodiments, it is also possible to determine whether the points to be segmented are adjacent by using an 8-neighborhood. Any point to be segmented can be selected, and the area consisting of 8 points above, below, left, right, upper left, upper right, lower left, and lower right around the current point to be segmented is an 8-neighborhood. It is determined whether the 8-neighborhood of the current point to be segmented contains other points to be segmented. If the 8-neighborhood of the current point to be segmented does not contain other points to be segmented, the current point to be segmented is not adjacent to the other points to be segmented; if the other points to be segmented are within the 8-neighborhood of the current point to be segmented, the current point to be segmented is adjacent to the points to be segmented within its 8-neighborhood.
[0044] Through step S141 and step S142, the points to be segmented can be distinguished into a first point to be segmented 10 and a second point to be segmented 20 according to the relative position information of the points to be segmented, and different segmentation processing can be performed on the image contours where different points to be segmented are located. It can adapt to a variety of different line connection situations, and can use a single algorithm to perform differentiated processing according to different image linear connection situations, with higher image segmentation accuracy, high versatility and flexibility.
[0045] In some embodiments, the information of the points to be segmented may also include the number of points to be segmented, such as Figure 5 As shown, step S140, performing image segmentation according to the information of the points to be segmented, may also include: steps S143 to S145.
[0046] Step S143, determine the number of currently unsegmented points to be segmented. First, the number of currently unsegmented points to be segmented can be determined. The current number of unsegmented points can be determined based on the points to be segmented determined in step S130. For a situation where at least one image segmentation has been performed, the current number of unsegmented points can be determined based on the number of points to be segmented determined in step S130 and the number of segmentation times. Alternatively, each contour can be traversed again in the segmented image to obtain new information on points to be segmented.
[0047] If the number of currently unsegmented points to be segmented is 1, step S141 can be performed on the currently unsegmented points to be segmented, and for the first point to be segmented 10 that is not adjacent to other points to be segmented, segmentation is performed at the first point to be segmented 10 for the contour where the first point to be segmented 10 is located, so that the first point to be segmented 10 belongs to one of the contours after segmentation. In the case that the number of currently unsegmented points to be segmented is 1, the currently unsegmented point to be segmented is not adjacent to other points to be segmented, so the currently unsegmented point to be segmented can be the first point to be segmented 10, and the contour 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 the segmentation is completed, the current number of unsegmented points to be segmented can be confirmed again, and it can be determined that the current number of unsegmented points to be segmented is 0, which can indicate that the image segmentation has been completed.
[0048] If the number of the currently unsegmented points to be segmented is greater than or equal to 2, step S144 can be executed to confirm the relative position between the two points to be segmented that are closest to each other. If the two points to be segmented are adjacent, step S142 is executed for the two points to be segmented, and for the two adjacent second points to be segmented 20, for the contour where the second points to be segmented 20 are located, segmentation is performed at the second points to be segmented 20, so that the two second points to be segmented 20 respectively belong to different contours after segmentation; if the two points to be segmented are not adjacent, step S141 is executed, and for the first point to be segmented 10 that 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. The number of currently unsegmented points to be segmented can be determined. When the number of currently unsegmented points to be segmented is 2, the relative position information between the two points to be segmented can be confirmed. When the two points to be segmented are adjacent, the points to be segmented can be determined as the second points to be segmented 20. Step S142 is executed to perform image segmentation on the two second points to be segmented 20 to obtain a contour image that has been segmented. When the two points to be segmented are not adjacent, the two points to be segmented can be determined as the first points to be segmented 10. Step S141 is executed to perform image segmentation on the two first points to be segmented 10 respectively to obtain a contour image that has been segmented. After the segmentation is completed, the number of currently unsegmented points to be segmented can be confirmed again. It can be determined that the number of currently unsegmented points to be segmented is 0, which indicates that the segmentation of the image has been completed.
[0049] In the case where the number of currently unsegmented points to be segmented is greater than 2, the two points to be segmented that are closest to each other can be taken according to the information of the points to be segmented, and the relative position information between the two points to be segmented can be confirmed. In the case where the two points to be segmented are adjacent, the points to be segmented can be determined as the second points to be segmented 20, and step S142 is performed for the two points to be segmented respectively. In the case where the two points to be segmented are not adjacent, the two points to be segmented can be determined as the first points to be segmented 10, and step S141 is performed. After completing the image segmentation at the two points to be segmented that are closest to each other, the number of currently unsegmented points to be segmented can be determined again. If the number of currently unsegmented points to be segmented is not 0, the process returns to step S143 to determine the number of currently unsegmented points to be segmented. After completing the image segmentation at the two nearest points to be segmented, the image may also include one or more unsegmented points to be segmented. For these points to be segmented, the process may return to step S143 to confirm the number of unsegmented points to be segmented, and continue to segment the image according to the number. If the number of unsegmented points to be segmented is 1, step S141 may be executed. If the number of unsegmented points to be segmented is greater than or equal to 2, step S144 may be executed. The information of the points to be segmented may be continued to be determined and segmented until the number of unsegmented points to be segmented is 0, and the image segmentation is completed. The method of image segmentation is determined according to the number of unsegmented points to be segmented and the relative position information. The image segmentation method applicable to the points to be segmented can be accurately determined during the image segmentation process. The method has higher accuracy. At most two points to be segmented can be detected and segmented at one time. The method has higher efficiency. When the image segmentation method disclosed in the present invention is applied to a sorting device, the method can meet the real-time requirements and has higher efficiency.
[0050] In some embodiments, Figure 6 As shown, step S140, image segmentation is performed according to the information of the points to be segmented, and may also include: if the number of the currently unsegmented points to be segmented is 1, then step S145 is executed to confirm 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 step S146 is executed, and 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 confirmed. If the currently unsegmented number of points to be segmented is 1, the contour where the currently unsegmented point to be segmented is located can be confirmed according to step S145, so as to facilitate the determination of the position of the points to be segmented, and at the same time, the contour target to be segmented in the next step can be determined to avoid incorrectly segmenting the contour. If the currently unsegmented number of points to be segmented is greater than or equal to 2, the contours where the two points to be segmented are located can be confirmed according to step S146 for the two points to be segmented that are closest to each other. The two points to be segmented that are closest to each other can be taken, and the contours where the two points to be segmented are located can be confirmed respectively, so as to determine the belonging of each point to be segmented, so as to facilitate subsequent image segmentation.
[0051] In the process of image segmentation, when 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, through steps S145 and S146, the contour where the points to be segmented are located can be determined, and the contour where the points to be segmented are located can be accurately segmented, which can ensure the accuracy of image segmentation, especially for the case of multiple points to be segmented, effectively avoiding segmentation errors or incorrect attribution of the points to be segmented.
[0052] In some embodiments, Figure 7 As shown, step S140, performing image segmentation according to the information of the points to be segmented, may also include: step S147, confirming whether the current point to be segmented is adjacent to other points to be segmented according to the current point to be segmented. If the point to be segmented is not adjacent to other points to be segmented, step S141 is executed; if the point to be segmented is adjacent to other points to be segmented, step S142 is executed. A point to be segmented can be directly selected as the current point to be segmented, and step S147 is executed to confirm whether the current point to be segmented is adjacent to other points to be segmented. If adjacent, the current point to be segmented is the first point to be segmented 10, and step S141 is executed for the current point to be segmented, and segmentation is performed at the current point to be segmented, so that the current point to be segmented belongs to any one of the two contours obtained after segmentation. If not adjacent, 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 for the two second points to be segmented 20, segmentation is performed between the two second points to be segmented 20, and the two second points to be segmented 20 are respectively attributed 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 a reference, 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, Figure 8 As shown, step S140, performing image segmentation according to the information of the points to be segmented, may also include: step S148, for three or more adjacent third points to be segmented, the contour where the multiple third points to be segmented are located is segmented into two contours, so that part 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. For the case where three or more adjacent points to be segmented are adjacent, the multiple points to be segmented may be collinear. For three or more adjacent points to be segmented, since these points to be segmented are continuously adjacent, segmenting each point to be segmented may cause segmentation errors, or there may be isolated pixels after segmentation. Therefore, these points to be segmented can be segmented only once, and the three or more adjacent points to be segmented are divided into two different parts, so that the points to be segmented in the two parts each belong to the two contours after segmentation, so that part 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. In the case where the number of adjacent points to be segmented is odd, the midpoint can be taken between the multiple adjacent points to be segmented, and segmentation is performed at the position of the midpoint, so that the midpoint belongs to any contour after segmentation. In the case where the number of adjacent points to be segmented is even, the two central points to be segmented can be taken, and segmentation is performed between the two points to be segmented, so that the two central points to be segmented each belong to two different contours after segmentation. Through step S148, three or more consecutive adjacent targets are segmented, which can avoid repeated segmentation, prevent image segmentation errors, avoid the situation where isolated pixels exist after segmentation, reduce the error rate of image segmentation, improve the accuracy of image segmentation, and can be segmented according to different linear connection situations, with better adaptability.
[0054] In some embodiments, Fig. 9 As shown, step S110, extracting the contour of the image according to the image includes: step S111, performing binarization processing according to the image to obtain a binary image; step S112, extracting the contour of the binary image according to the binary image. Step S111 can be performed on the image to binarize the image, and the grayscale value of the pixel on the image is set to two values of 0 or 255, which can effectively simplify the image and effectively reduce the amount of data in the image, thereby effectively reducing the amount of calculation for subsequent detection and segmentation of the image, and improving the efficiency of image segmentation. After the binarization processing, the image can be clearly distinguished from the background, and the target is clearer, which is convenient for step S112 to extract the contour according to the binary image. Extracting the contour after the binarization processing can make the extracted contour clearer and more accurate. Binarization processing has a smaller amount of data calculation, improves the speed of obtaining edge information, thereby improving the speed of image segmentation, and has better real-time performance.
[0055] In some embodiments, Fig.10As shown, the image segmentation method may also include: step S150, performing concave point detection according to the image to obtain a plurality of concave points. Step S160, performing pairing according to the plurality of concave points 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; step S180, performing image segmentation according to the segmentation line. In the case where the target overlaps or adheres, step S150 may be executed, and the lowest point of the downward depression on the edge of the image may be detected by concave point detection to obtain a plurality of concave points to locate the position where the overlap or adhesion occurs. According to the concave points in the acquired image, step S160 may be executed, and for each concave point, pairing may be performed in pairs to determine the concave point pair, so that each concave point is paired only once to avoid repeated pairing. By executing step S170, the two concave points in each concave point pair are connected to determine the segmentation line. Then, according to the contour and the segmentation line, the image segmentation is completed. Steps S150 to S180 can segment the target image that is overlapped or adhered. Steps S150 to S180 can be performed in parallel with the method for image segmentation according to the information of the points to be segmented in the aforementioned embodiment, and the image can be detected and processed at the same time, or they can be run in series. Before or after the method for image segmentation according to the information of the points to be segmented, the concave point pairs are determined by concave point detection, thereby determining the segmentation line, so that the image segmentation method provided by the present disclosure can process the target image that is overlapped or adhered. And the images with linear connections can be reasonably, accurately and quickly segmented through steps S110 to S140 provided by the present disclosure. Through steps S150 to S180, the image segmentation method can segment other overlapping or adhered targets by the method of concave point detection while segmenting the targets that are linearly connected, so that the image segmentation method can adapt to a variety of different situations, can be applied to different sorting environments, and segment images in different situations, with good scalability and adaptability.
[0056] Based on the same inventive concept, Fig.11 As shown, the present disclosure also provides a target detection device 200, wherein the target detection device 200 includes: an image segmentation module 210, which executes the image segmentation method as in any of the aforementioned embodiments. The image segmentation module 210 can segment the image according to the image segmentation method of any of the aforementioned embodiments, and can quickly and accurately complete the contour image segmentation of linearly connected targets, so that one target corresponds to an independent contour. Regarding the target detection device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.
[0057] Based on the same inventive concept, the present disclosure further provides a computer-readable storage medium, which stores the following program, and the program is used to execute the image segmentation method of any of the aforementioned embodiments.
[0058] like Fig.12 As shown, an embodiment of the present 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 used to store instructions. The processor 320 is used to call the instructions stored in the memory 310 to execute the image segmentation method of the embodiment of the present disclosure. The processor 320 is connected to the memory 310 and the I / O interface 330 respectively, for example, through a bus system and / or other forms of connection mechanisms (not shown). The memory 310 can be used to store programs and data, including the program of the image segmentation method involved in the embodiment of the present disclosure. The processor 320 executes various functional applications and data processing of the electronic device 300 by running the program stored in the memory 310.
[0059] In the embodiment of the present disclosure, the processor 320 can be implemented in at least one 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 one or a combination of other forms of processing units with data processing capabilities and / or instruction execution capabilities.
[0060] The memory 310 in the embodiment of the present disclosure may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.
[0061] In the embodiment of the present disclosure, the I / O interface 330 may be used to receive input instructions (such as digital or character information, and key signal input related to user settings and function control of the electronic device 300), and may also output various information to the outside (such as images or sounds). In the embodiment of the present disclosure, the I / O interface 330 may include one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a mouse, a joystick, a trackball, a microphone, a speaker, and a touch panel.
[0062] The present application uses specific words to describe the embodiments of the present application. For example, "one embodiment", "an embodiment", and / or "some embodiments" refer to a certain feature, structure or characteristic related to at least one embodiment of the present application. Therefore, it should be emphasized and noted that "one embodiment" or "an embodiment" or "an alternative embodiment" mentioned twice or multiple times in different positions in this specification does not necessarily refer to the same embodiment. In addition, some features, structures or characteristics in one or more embodiments of the present application can be appropriately combined.
[0063] In the context of this application, unless the context clearly indicates an exception, the words "a", "an", "a kind" and / or "the" do not refer to the singular, but may also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of the steps and elements that have been clearly identified, and these steps and elements do not constitute an exclusive list, and the method or device may also include other steps or elements.
[0064] Similarly, it should be noted that in order to simplify the description of the disclosure of this application and thus help understand one or more application embodiments, in the above description of the embodiments of this application, multiple features are sometimes merged into one embodiment, figure or description thereof. However, this disclosure method does not mean that the features required by the object of this application are more than the features mentioned in the claims. In fact, the features of the embodiments are less than all the features of the single embodiment disclosed above.
[0065] The basic concepts have been described above. Obviously, for those skilled in the art, the above disclosure is only for example and does not constitute a limitation of the present application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements and amendments to the present application. Such modifications, improvements and amendments are suggested in the present application, so such modifications, improvements and amendments still belong to the spirit and scope of the embodiments of the present application.
Claims
1. An image segmentation method, comprising: According to the image, extracting the contour of the image; According to each point on the contour, the contour is completely traversed in order to determine the information and occurrence frequency of each point on the contour; According to the occurrence frequency of each point on the contour, the point whose occurrence frequency is greater than 1 is determined as a point to be segmented; Image segmentation is performed according to information of points to be segmented, wherein the information of 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 image segmentation according to the information of the points to be segmented comprises: For a first point to be segmented that is not adjacent to other points to be segmented, segment 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, for the contour where the two second points to be segmented are located, segmentation is performed between the two second points to be segmented, so that the two second points to be segmented respectively belong to different contours after segmentation.
3. The image segmentation method according to claim 2, wherein: The information of points to be segmented also includes the number of points to be segmented, and the image segmentation according to the information of points to be segmented also includes: Determine the number of the points to be segmented that are not currently segmented; If the number of the currently unsegmented points to be segmented is 1, the currently unsegmented points to be segmented are subjected to the step of performing segmentation on 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 undivided points to be divided is greater than or equal to 2, for the two points to be divided that are closest to each other, determine the relative position between the two points to be divided; If two points to be segmented are adjacent, the method for performing the segmentation on the two adjacent second points to be segmented is performed on the two points to be segmented, and segmenting is performed at the second points to be segmented for the contour where the second points to be segmented are located, 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 steps of performing segmentation on the first point to be segmented which is not adjacent to the other points to be segmented are respectively performed on the two points to be segmented, and segmenting is performed at the first point to be segmented for the contour where the first point to be segmented is located, so 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.
4. The image segmentation method according to claim 3, wherein: The image segmentation according to the information of the points to be segmented also 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.
5. The image segmentation method according to claim 2, wherein: The image segmentation according to the information of the points to be segmented also includes: According to the current point to be segmented, confirm 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, then for the first point to be segmented that is not adjacent to other points to be segmented, segment 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 performing segmentation on 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.
6. The image segmentation method according to claim 2, wherein: The image segmentation according to the information of the points to be segmented also 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 another part of the third points to be segmented belong to another contour after segmentation.
7. The image segmentation method according to claim 1, wherein: The step of extracting the contour of the image according to the image comprises: According to the image, binarization processing is performed to obtain a binary image; According to the binary image, a contour of the binary image is extracted.
8. 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; According to the plurality of concave points, pairing is performed 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 the dividing line; Image segmentation is performed according to the segmentation line.
9. A target detection device, wherein: The target detection device comprises: An image segmentation module executes the image segmentation method as described in claims 1-8.
10. 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 8.
Citation Information
Patent Citations
Cutting method and device and cutting equipment
CN113771036A
Pleura adhesion type pulmonary parenchyma segmentation method and system
CN115619806A
Relative fuzziness for fast reduction of false positives and false negatives in computational text searches
US20230401274A1