Method, system, device and medium for segmenting target objects in images

By using watershed algorithms and geometric feature calculations in image segmentation processing, combined with iterative optimization mechanism, the segmentation problems of irregular morphology, overlapping or obstructing target objects are solved, and the accuracy and efficiency of image segmentation are improved.

CN119477960BActive Publication Date: 2025-05-16STORAGEX TECH INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510066536.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-05-16
Estimated Expiration
2045-01-16

AI Technical Summary

Technical Problem

Existing image segmentation technology is difficult to accurately process target objects with irregular shapes, overlapping or sticking, resulting in inaccurate statistics on the number of target objects.

Method used

The target object segmentation processing method in the image is adopted, and pre-processing and segmentation is performed through the watershed algorithm, the geometric features of the segmented area are obtained, and the number of target objects is calculated. The mismatched segmented areas are processed through the iterative optimization mechanism until the number of target objects and the number of contours match.

Benefits of technology

It significantly improves the accuracy of image segmentation processing, reduces the error segmentation caused by similar morphology or sticking of target objects, and is suitable for complex image scenarios, and improves the automation, intelligence and processing efficiency of image segmentation processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119477960B_ABST
    Figure CN119477960B_ABST
Patent Text Reader

Abstract

The present invention application discloses a target object segmentation processing method, processing system, device, and medium in an image, and belongs to the field of image processing technology. The target object segmentation processing method in an image includes: inputting an image; preprocessing the image, and segmenting the image using a watershed algorithm to obtain a plurality of segmented regions; calculating the geometric features of each segmented region according to the plurality of segmented regions; calculating the number of target objects in each segmented region, and obtaining the number of contours in each segmented region; judging whether the number of target objects and the number of contours in each segmented region match, if the numbers match, terminating the image segmentation processing; if at least one of the numbers does not match, continuing to segment the image. The present invention application can improve the accuracy of image segmentation processing, and is suitable for image segmentation processing of target objects with irregular shapes, overlaps, or adhesions, and improves the wide applicability of the image segmentation processing method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing technology, and in particular relates to a method, a processing system, a device and a medium for segmenting a target object in an image. Background Art

[0002] In the existing field of image processing technology, image segmentation is a key technology in image processing. Its core task is to separate the target object in the image from the background for subsequent analysis and processing. Traditional image segmentation technology has been widely used in various industrial, medical and scientific research fields. Traditional image segmentation technology can usually use the watershed algorithm. The watershed algorithm usually performs segmentation based on the gradient information of the image, simulating the expansion of water flow to divide the image into different areas. The watershed algorithm performs well when the edges or gradients in the image are clear, and can effectively separate different target objects from the background.

[0003] However, when facing image processing where the shape of the target object in the image is irregular or there is adhesion between the target objects, traditional image segmentation algorithms (such as the watershed algorithm mentioned above) usually rely on the edge information of the image for target segmentation, and often fail to completely and correctly segment the target object. For example, when multiple target objects in the image have similar shapes or are in close contact, the watershed algorithm may mistakenly divide them into one area, resulting in inaccurate statistics of the number of target objects; for another example, in complex image processing scenarios, especially image processing involving multiple small targets (such as bumps, particles, burrs, lesion areas, etc.), it is often impossible to completely and correctly segment the target object, which brings new technical challenges to the detection and segmentation of target objects in the image.

[0004] Therefore, in order to solve the above problems, many researchers have tried to use morphological operations (such as corrosion, expansion, opening operation, closing operation, etc.) to improve the effect of image segmentation processing. The corrosion operation can reduce the size of the object, the expansion operation can expand the boundary of the object, and the opening operation and closing operation can be used to remove noise and fill small holes in the object respectively. However, when faced with irregular, overlapping or adhered target objects, these morphological operation methods are still difficult to provide ideal image segmentation results. Therefore, how to accurately segment and process the estimated number of target objects when faced with irregular, overlapping or adhered target objects is still a technical problem that needs to be solved in the existing image segmentation processing technology field. Summary of the invention

[0005] The present invention provides a method and system for segmenting target objects in an image, aiming to partially or completely solve the technical problems in existing image processing. The present invention adopts the following technical solutions:

[0006] In a first aspect, a method for segmenting a target object in an image includes:

[0007] Step S100: inputting an image, the image including a target object with irregular shape and / or a plurality of target objects adhered to each other;

[0008] Step S200: preprocessing the image, segmenting the image using a watershed algorithm to obtain a plurality of segmented regions, the plurality of segmented regions including a first segmented region, a second segmented region, ..., an i-th segmented region, ..., an n-th segmented region, where i = 1, 2, 3, ..., n;

[0009] Step S300: According to the plurality of segmented regions, respectively obtain the first segmentation contour of the first segmented region, the second segmentation contour of the second segmented region, ..., the i-th segmentation contour of the i-th segmented region, ..., the n-th segmentation contour of the n-th segmented region; respectively calculate the first geometric feature of the first segmented region, the second geometric feature of the second segmented region, ..., the i-th geometric feature of the i-th segmented region, ..., the n-th geometric feature of the n-th segmented region according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., the n-th segmentation contour; the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., the n-th geometric feature all include at least one of area, perimeter, and shape factor;

[0010] Step S400: Calculate the first target object number M1 of the first segmented area, the second target object number M2 of the second segmented area, …, the i-th target object number Mi of the i-th segmented area, …, and the n-th target object number Mn of the n-th segmented area according to the first geometric feature, the second geometric feature, …, the i-th geometric feature, …, and the n-th target object number Mn of the n-th segmented area; obtain the first contour number P1 of the first segmented area, the second contour number P2 of the second segmented area, …, the i-th contour number Pi of the i-th segmented area, …, and the n-th contour number Pn of the n-th segmented area;

[0011] Step S500: Determine whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number M i matches the i-th contour number P i, ..., whether the n-th target object number Mn matches the n-th contour number Pn. If all the numbers match, end the image segmentation process; if at least one of the numbers does not match, go to step S600;

[0012] Step S600: Continue to segment the image.

[0013] Optionally, in step S200, preprocessing of the image includes: image enhancement processing; image Gaussian blur processing, image binarization processing, image morphological operation processing, image distance transformation processing, image thresholding processing, image enhancement processing includes: image enhancement processing using Laplace operator, image morphological operation processing includes: image closing operation processing.

[0014] Optionally, in step S400, the calculation formula for the i-th target object number M i in the i-th segmented area is:

[0015]

[0016] Among them, Mi is the number Mi of the i-th target object in the i-th segmentation area, Ai is the area of ​​the i-th segmentation area, Ci is the perimeter of the i-th segmentation area, AS is the average area of ​​a single target object, PS is the average perimeter of a single target object, α is the first adjustable coefficient, and β is the second adjustable coefficient.

[0017] Optionally, in step S600, step S600 includes:

[0018] Step S601: when the number of target objects and the number of contours do not match, obtaining one or more corresponding segmentation regions;

[0019] Step S602: Determine whether the number of target objects in one or more segmented areas is greater than a preset value R, if yes, proceed to step S603, if no, proceed to step S604;

[0020] Step S603: performing morphological operation processing and watershed algorithm processing again on one or more segmented regions to form a new image, wherein the morphological operation processing includes image corrosion processing or image dilation processing, taking the new image as the input image in step S200, and re-entering step S200;

[0021] Step S604: Re-enter step S200.

[0022] In a second aspect, a target object segmentation processing system in an image is used to implement any target object segmentation processing method in an image as described in the first aspect, including:

[0023] An input module, used for inputting an image, wherein the image includes a target object with irregular shapes and / or a plurality of target objects adhered to each other;

[0024] A preprocessing segmentation module is used to preprocess the image and segment the image using a watershed algorithm to obtain a plurality of segmented regions, wherein the plurality of segmented regions include a first segmented region, a second segmented region, ..., an i-th segmented region, ..., an n-th segmented region, where i = 1, 2, 3, ..., n;

[0025] A geometric feature calculation module, which obtains, according to the plurality of segmented areas, a first segmentation contour of a first segmented area, a second segmentation contour of a second segmented area, ..., an i-th segmentation contour of an i-th segmented area, ..., and an n-th segmentation contour of an n-th segmented area respectively; and calculates, according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., and the n-th segmentation contour, a first geometric feature of the first segmented area, a second geometric feature of the second segmented area, ..., an i-th geometric feature of the i-th segmented area, ..., and an n-th geometric feature of the n-th segmented area respectively; the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature all include at least one of an area, a perimeter, and a shape factor;

[0026] The quantity calculation acquisition module calculates the first target object quantity M1 of the first segmented area, the second target object quantity M2 of the second segmented area, ..., the i-th target object quantity Mi of the i-th segmented area, ..., and the n-th target object quantity Mn of the n-th segmented area according to the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature; obtains the first contour quantity P1 of the first segmented area, the second contour quantity P2 of the second segmented area, ..., the i-th contour quantity Pi of the i-th segmented area, ..., and the n-th contour quantity Pn of the n-th segmented area;

[0027] The judgment processing module judges whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number Mi matches the i-th contour number Pi, ..., whether the n-th target object number Mn matches the n-th contour number Pn. If all the numbers match, the image segmentation processing is terminated; if at least one number does not match, the image segmentation processing continues.

[0028] Optionally, the calculation formula for the i-th target object number M i in the i-th segmented area is:

[0029]

[0030] Among them, Mi is the number Mi of the i-th target object in the i-th segmentation area, Ai is the area of ​​the i-th segmentation area, Ci is the perimeter of the i-th segmentation area, AS is the average area of ​​a single target object, PS is the average perimeter of a single target object, α is the first adjustable coefficient, and β is the second adjustable coefficient.

[0031] Optionally, the judgment processing module includes a judgment unit and a processing unit, the judgment unit judges whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2,…, whether the i-th target object number Mi matches the i-th contour number Pi…, whether the n-th target object number Mn matches the n-th contour number Pn, outputs the judgment result and sends it to the processing unit, the judgment result includes that all quantities match or at least one quantity does not match; the processing unit, based on the judgment result, if all quantities match, the processing unit ends the image segmentation processing; if at least one quantity does not match, the processing unit continues to segment the image.

[0032] Optionally, when the processing unit continues to perform segmentation processing on the image, the processing unit includes a segmentation area acquisition subunit, a target object number judgment subunit and a secondary processing formation subunit, the segmentation area acquisition subunit acquires one or more segmentation areas corresponding to this time; the target object number judgment subunit judges whether the number of target objects in one or more segmentation areas is greater than a preset value R, and outputs the target object number judgment result; based on the target object number judgment result, if it is greater than the preset value R, the secondary processing formation subunit performs morphological operation processing and watershed algorithm processing on one or more segmentation areas again and forms a new image, the morphological operation processing includes image corrosion processing or image expansion processing, and the target object segmentation processing system in the image is used again to process the new image; if it is not greater than the preset value R, the target object segmentation processing system in the image is used again to process the input image.

[0033] In a third aspect, the present invention application provides a device for detecting and segmenting target objects in an image, comprising a memory and a processor that are communicatively connected, wherein the memory is used to store a computer program, and the processor is used to read the computer program and execute a method for segmenting target objects in an image as described in any one of the first aspects.

[0034] In a fourth aspect, the present invention application provides a computer-readable storage medium having instructions stored thereon. When the instructions are run on a computer, the method for segmenting a target object in an image as described in any one of the first aspects is executed.

[0035] (1) In the present invention, firstly, by introducing segmentation regions, geometric features, and whether the number of targets matches the number of contours, the accuracy of image segmentation processing can be significantly improved, and the erroneous segmentation caused by the similarity or adhesion of the target objects can be reduced. The present invention can adapt to a variety of complex image scenes (such as multiple small target objects, convex points, particles, etc.), overlapping or adhered objects, etc., thereby improving the wide applicability of the image segmentation processing method. In addition, through multiple iterative adjustments and morphological operations, target objects with irregular shapes, overlapping or adhered objects can be effectively processed, thereby improving the accuracy and stability of the image segmentation processing results, reducing manual intervention, and improving the automation, intelligence and processing efficiency of image segmentation processing.

[0036] (2) In the present invention, the accuracy of image segmentation is effectively improved by introducing an iterative optimization mechanism. In each segmentation process, the unmatched segmented areas are processed again, and a combination of re-morphological operation processing and re-watershed algorithm processing is used to gradually eliminate the target objects with adhesion, overlap or irregular shapes in the image. This iterative optimization mechanism can handle complex image segmentation problems, especially when there are multiple target objects with adhesion or irregular shapes in the image, it can improve the accuracy and quality of image segmentation processing, ensure the accuracy of the final image segmentation, and also improve the accuracy of the target object quantity statistics, meeting the actual needs in various application scenarios such as medical imaging, industrial detection, and agricultural monitoring. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0038] Figure 1 It is a flowchart of step S100 to step S300 in the method for segmenting a target object in an image applied for by the present invention;

[0039] Figure 2 It is a flowchart of steps S400 to S600 in the method for segmenting a target object in an image of the present invention;

[0040] Figure 3 A schematic diagram of a target object segmentation processing system in an image applied for by the present invention;

[0041] Figure 4 This is a schematic diagram of the composition of the judgment processing module 500 of the present invention;

[0042] Figure 5Schematic diagram of comparison between the input image and the output image after being processed by the method for segmenting the target object in the image according to the present invention ( Figure 5 (a) is the input image, Figure 5 (b) is the image processed by the target object segmentation processing method in the image).

[0043] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. DETAILED DESCRIPTION

[0044] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments; based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0045] As shown in the present application and claims, unless the context clearly indicates an exception, the words "a", "an", "an" and / or "the" do not refer to the singular, but 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.

[0046] Although the present invention application has made various references to certain modules in the system according to the embodiment of the present invention application, however, any number of different modules can be used and run on the user terminal and / or server. The modules are only illustrative, and different aspects of the system and method can use different modules.

[0047] The present invention application uses a flow chart to illustrate the operations performed by the system of the embodiment of the present invention application. It should be understood that the preceding or following operations are not necessarily performed accurately in order. On the contrary, various steps can be processed in reverse order or simultaneously as needed. At the same time, other operations can also be added to these processes, or one or more operations can be removed from these processes.

[0048] Below, the exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.

[0049] It is worth noting that in the present invention application, all actions of acquiring data are carried out in compliance with the relevant data protection laws and policies of the country where the data is located, and with the authorization given by the owner of the corresponding device.

[0050] Method for segmenting target objects in images

[0051] like Figure 1 and Figure 2 As shown, in a first aspect, a method for segmenting a target object in an image comprises:

[0052] Step S100: inputting an image, the image including a target object with irregular shape and / or a plurality of target objects adhered to each other;

[0053] Step S200: preprocessing the image, segmenting the image using a watershed algorithm to obtain a plurality of segmented regions, the plurality of segmented regions including a first segmented region, a second segmented region, ..., an i-th segmented region, ..., an n-th segmented region, where i = 1, 2, 3, ..., n;

[0054] Step S300: According to the plurality of segmented regions, respectively obtain the first segmentation contour of the first segmented region, the second segmentation contour of the second segmented region, ..., the i-th segmentation contour of the i-th segmented region, ..., the n-th segmentation contour of the n-th segmented region; respectively calculate the first geometric feature of the first segmented region, the second geometric feature of the second segmented region, ..., the i-th geometric feature of the i-th segmented region, ..., the n-th geometric feature of the n-th segmented region according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., the n-th segmentation contour; the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., the n-th geometric feature all include at least one of area, perimeter, and shape factor;

[0055] Step S400: Calculate the first target object number M1 of the first segmented area, the second target object number M2 of the second segmented area, …, the i-th target object number Mi of the i-th segmented area, …, and the n-th target object number Mn of the n-th segmented area according to the first geometric feature, the second geometric feature, …, the i-th geometric feature, …, and the n-th target object number Mn of the n-th segmented area; obtain the first contour number P1 of the first segmented area, the second contour number P2 of the second segmented area, …, the i-th contour number Pi of the i-th segmented area, …, and the n-th contour number Pn of the n-th segmented area;

[0056] Step S500: Determine whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number M i matches the i-th contour number P i, ..., whether the n-th target object number Mn matches the n-th contour number Pn. If all the numbers match, end the image segmentation process; if at least one of the numbers does not match, go to step S600;

[0057] Step S600: Continue to segment the image.

[0058] In some embodiments, in step S100, the input image includes an irregularly shaped target object and / or multiple target objects that are adhered to each other. The target object itself may include an asymmetric shape, a complex edge, and multiple target objects are adhered to each other (which may mean that there is a partial overlap between multiple target objects) to adapt to the existing image segmentation processing scenario. It should be understood that the present application does not impose strict restrictions on the specific format of the input image. The technician can select a suitable image format for image acquisition or input according to actual needs, whether it is a grayscale image, a color image, a depth image, or a preprocessed binary image. The image acquisition method can also be selected according to actual conditions, such as through a camera, a scanner, an industrial detection equipment or a medical imaging device, etc., to ensure that the image content can truly reflect the morphological characteristics and distribution laws of the target object. The flexible design of the image input format and method makes the method of the present application have strong adaptability and can be effectively applied in a variety of different application scenarios.

[0059] In some embodiments, in step S200, the image is preprocessed, and the preprocessing operations may include denoising, enhancement, smoothing, etc., to remove possible background noise and unnecessary details, improve the input image quality, and thus improve the visibility of the target object, so as to provide a clearer image basis for subsequent image segmentation and target object detection.

[0060] In some embodiments, in step S200, the image may be segmented using a watershed algorithm to obtain a plurality of segmented regions, the plurality of segmented regions including a first segmented region, a second segmented region, ..., an i-th segmented region, ..., an n-th segmented region, i = 1, 2, 3, ..., n. It should be understood that the processed image is segmented using a watershed algorithm, and the watershed algorithm can regard the image as a terrain according to the gradient information of the image, wherein the region with a higher grayscale value is a ridge, and the region with a lower grayscale value is a valley. The watershed algorithm simulates the expansion process of the water flow, so that the water flow expands from the lowest point to the surroundings, and forms a dividing line between different regions, and finally divides the image into a plurality of regions. In the image segmentation process, the watershed algorithm can effectively identify the edge information in the image, and divide the image into a plurality of different segmented regions according to the change of the gradient information, and these segmented regions usually correspond to different target objects or parts of the target object. However, when facing target objects with irregular shapes and / or multiple target objects that are adhered to each other, the watershed algorithm may cause mis-segmentation or region merging. Therefore, the watershed algorithm is mainly used to roughly segment the image in this step, providing preliminary segmentation results for subsequent fine processing and extraction of target objects.

[0061] In some embodiments, in step S300, the first segmentation contour of the first segmented area, the second segmentation contour of the second segmented area, ..., the i-th segmentation contour of the i-th segmented area, ..., and the n-th segmentation contour of the n-th segmented area can be obtained respectively, and the first geometric feature of the first segmented area, the second geometric feature of the second segmented area, ..., the i-th geometric feature of the i-th segmented area, ..., and the n-th geometric feature of the n-th segmented area can be calculated respectively according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., and the n-th segmentation contour; the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature all include at least one of area, perimeter, and shape factor, for example, the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature all include area and perimeter, so as to provide more accurate information for subsequent estimation of the number of target objects.

[0062] First, for the first segmented area, the second segmented area, ..., the i-th segmented area, ..., the n-th segmented area, the first segmented contour (line) of the first segmented area, the second segmented contour (line) of the second segmented area, ..., the i-th segmented contour (line) of the i-th segmented area, ..., the n-th segmented contour (line) of the n-th segmented area are extracted by edge detection or contour tracking algorithm; the first segmented contour (line), the second segmented contour (line), ..., the i-th segmented contour (line), ..., the n-th segmented contour (line) represent the boundaries of the first segmented area, the second segmented area, ..., the i-th segmented area, ..., the n-th segmented area in the image respectively;

[0063] Then, according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., the n-th segmentation contour, the first geometric feature of the first segmentation area, the second geometric feature of the second segmentation area, ..., the i-th geometric feature of the i-th segmentation area, ..., the n-th geometric feature of the n-th segmentation area can be calculated. Common geometric features include but are not limited to the following three types:

[0064] Area: Indicates the size of each segmented area, which can help distinguish the target object from the background area, or distinguish between multiple target objects. The larger area may represent the main target, while the smaller area may be noise or a small object; Perimeter: Indicates the total length of the outline of each segmented area. The perimeter feature can be used to identify the shape of the object. Usually, targets with larger perimeters may have complex shapes, while targets with smaller perimeters are usually simpler; Shape Factor: Shape Factor is an indicator used to characterize the shape of the target object, which can usually be obtained by calculating the relationship between the area and perimeter of the object. For example, a target with a higher shape factor may be close to a circle or regular shape, while a target with a lower shape factor may be irregular or complex.

[0065] Therefore, these geometric features can help further analyze and identify the number of target objects in the image, especially when the target objects have complex shapes or there are adhesions between target objects. Geometric features may help distinguish and evaluate the size, shape and complexity of each object, and can also provide important reference for subsequent target object detection, quantity estimation, etc., thereby improving the accuracy and efficiency of image segmentation.

[0066] In some embodiments, in step S400, based on the first geometric feature, the second geometric feature, …, the i-th geometric feature, …, the n-th geometric feature, the first target object number M1 in the first segmented area, the second target object number M2 in the second segmented area, …, the i-th target object number M i in the i-th segmented area, …, the n-th target object number Mn in the n-th segmented area can be calculated to analyze the size, distribution pattern, etc. of the target objects in the image.

[0067] In some embodiments, in order to accurately calculate the first target object number M1 of the first segmented area, the second target object number M2 of the second segmented area, ..., the i-th target object number M i of the i-th segmented area, ..., and the n-th target object number Mn of the n-th segmented area, the first geometric feature of the first segmented area, the second geometric feature of the second segmented area, ..., the i-th geometric feature of the i-th segmented area, ..., the n-th geometric feature of the n-th segmented area and the geometric feature of a single target object may be considered respectively. Specifically:

[0068] First, according to the first geometric feature of the first segmented area, the second geometric feature of the second segmented area, ..., the i-th geometric feature of the i-th segmented area, ..., the n-th geometric feature of the n-th segmented area (such as area, perimeter, shape factor, etc.) obtained in step S300, if the area or shape feature of a segmented area is small, the outline of the segmented area is generally simpler, and it can be preliminarily determined that the area may contain a target object; on the contrary, if the geometric feature of a segmented area is more complex and contains multiple boundaries or holes, it may contain multiple target objects, which may mean that the multiple target objects are adhered or overlapped; in addition, the first geometric feature of the first segmented area, the second geometric feature of the second segmented area, ..., the i-th geometric feature of the i-th segmented area, ..., the n-th geometric feature of the n-th segmented area obtained in step S300 On this basis, we can further consider using the geometric features of a single target object (such as area, perimeter, shape factor, etc.), and through the relative size relationship between the geometric features of the single target object and the first geometric features of the first segmented area, the second geometric features of the second segmented area,…, the i-th geometric features of the i-th segmented area,…, the n-th geometric features of the n-th segmented area, we can then calculate the first target object number M1 in the first segmented area, the second target object number M2 in the second segmented area,…, the i-th target object number Mi in the i-th segmented area,…, the n-th target object number Mn in the n-th segmented area; and we can also obtain the first contour number P1 in the first segmented area, the second contour number P2 in the second segmented area,…, the i-th contour number Pi in the i-th segmented area,…, the n-th contour number Pn in the n-th segmented area.

[0069] In some embodiments, in step S500, it is determined whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number Mi matches the i-th contour number Pi, ..., whether the n-th target object number Mn matches the n-th contour number Pn. If all the numbers match, the image segmentation process is terminated; if at least one of the numbers does not match, the process proceeds to step S600, that is, by determining whether the two numbers match, it is evaluated whether the current image segmentation process result is correct. If all the target object numbers match the contour numbers, it means that the image has been accurately segmented and the target objects have been correctly identified. At this time, the image segmentation process can be terminated; if at least one target object number does not match the contour number, it means that some target objects in the image have not been completely segmented or there are errors. Usually, there may be adhesion, overlap or irregular shapes between the objects. At this time, it is necessary to proceed to step S600 to continue to perform further segmentation processing on the image until the target object number matches the contour number.

[0070] It should be noted that the matching of the i-th target object number Mi and the i-th contour number Pi at least means that the quantity difference between the i-th target object number Mi and the i-th contour number Pi is within the preset matching range T. Exemplarily, the preset matching range T can be: 0≤|Mi-Pi|≤1, etc. Those skilled in the art can reasonably set the preset range T according to actual conditions, and the present invention application does not impose any special restrictions on this.

[0071] In some embodiments, if the number of all target objects matches the number of contours, it means that the image has been accurately segmented and the target objects have been correctly identified. At this time, the image segmentation process can be terminated, and the image processed by the target object segmentation process method in the output image can be displayed.

[0072] In some embodiments, in step S600, different processing strategies may be used to segment and optimize the image, and more iterative segmentation processes may be used to eliminate errors that occurred in previous steps to ensure complete recognition of the target object.

[0073] Exemplarily, step S600 may include the following operations: (1) Morphological operations. Morphological operations (such as erosion, dilation, opening and closing operations) may be used to further optimize image segmentation. The erosion operation can reduce the area of ​​the target object or eliminate noise, and the dilation operation can help separate adjacent target objects. Through morphological operations, the adhesion or overlap problems between target objects can be effectively handled; (2) Boundary optimization: During the segmentation process, if the boundaries of some target objects are not clear, the system may use edge detection algorithms (such as Canny edge detection or Sobel operator) to optimize the segmentation results to ensure that the boundaries of the target objects are accurately divided. Each time a new segmentation is performed, the first geometric feature of the first segmented area, the second geometric feature of the second segmented area, ..., the i-th geometric feature of the i-th segmented area, ..., the n-th geometric feature of the n-th segmented area and the first target object number M1 in the first segmented area, the second target object number M2 in the second segmented area, ..., the i-th target object number Mi in the i-th segmented area, ..., the n-th target object number Mn in the n-th segmented area are recalculated until the total number of target objects matches the total number of contours. At this time, the image segmentation process can be ended and the target objects have been accurately identified.

[0074] Therefore, in the target object segmentation processing method in the image applied for by the present invention, firstly, by introducing the segmentation area, geometric features, and whether the target number matches the contour number, the accuracy of the image segmentation processing can be significantly improved, and the erroneous segmentation caused by the similarity or adhesion of the target object morphology can be reduced. It can adapt to a variety of complex image scenes (such as multiple small target objects, convex points, particles, etc.), overlapping or adhered objects, etc., and improve the wide applicability of the image segmentation processing method; in addition, through multiple iterative adjustments and morphological operations, it can effectively process target objects with irregular morphology, overlapping or adhesion, improve the accuracy and stability of the image segmentation processing results, reduce manual intervention, and improve the automation, intelligence and processing efficiency of image segmentation processing.

[0075] Optionally, in step S200, preprocessing of the image includes: image enhancement processing; image Gaussian blur processing, image binarization processing, image morphological operation processing, image distance transformation processing, image thresholding processing, image enhancement processing includes: image enhancement processing using Laplace operator, image morphological operation processing includes: image closing operation processing.

[0076] In step S200, image preprocessing is a key step in the image segmentation process, which aims to improve image quality, remove noise, and enhance the features of the target object to make it easier to segment and analyze. The preprocessing process involves multiple operations, each of which has its specific purpose and effect. The following is a detailed expansion of each preprocessing operation:

[0077] In some embodiments, image enhancement processing is to improve the visibility and contrast of the target object in the image by adjusting the image parameters such as brightness, contrast, saturation, etc., so as to facilitate subsequent image analysis. Common image enhancement methods include histogram equalization, contrast stretching, etc. These methods can effectively improve the clarity of the image, especially for low-contrast or blurred images, can improve the separation of the target object and the background, make the details of the image more prominent, especially in the case of poor image quality, improve the visibility of the target object, enhance the outline of the target object, and make the subsequent segmentation processing more accurate.

[0078] In some embodiments, image Gaussian blur processing is a commonly used image smoothing technology, which is usually used to remove high-frequency noise and convex points in images. The image is smoothed by weighted averaging of each pixel, thereby reducing small noise and interference in the image and errors in image processing. Gaussian blur is particularly suitable for images with high noise or uneven lighting. It can make the outline of the target object smoother, which helps to improve the accuracy of subsequent segmentation algorithms.

[0079] In some embodiments, the image binarization process is to convert the grayscale image into an image with only black and white colors, usually by setting a threshold value, setting pixel values ​​greater than the threshold value to white (1), and pixel values ​​less than the threshold value to black (0). The image binarization process helps to simplify the image, making the separation of the target object and the background clearer, especially when the color of the target object is in sharp contrast with the background, simplifying the image, improving the image processing efficiency, reducing the image complexity, and facilitating subsequent image analysis and feature extraction.

[0080] In some embodiments, image morphological operation processing is a type of technology used to process image structural elements, which is often used to remove noise, fill small holes in the image, connect separated parts, etc. Common morphological operations include dilation, erosion, opening operation, closing operation, etc. Morphological operations are particularly suitable for processing noise, holes or small objects in the image. In the present application, image closing operation processing is a combination of dilation operation and erosion operation, which is usually used to fill small holes in the image or connect adjacent target objects. Each point in the image can be expanded and then eroded to achieve the effect of smoothing edges, eliminating small holes and connecting close objects, which helps to clearly define the contour of the target object and reduce misjudgment caused by noise or small object spacing. For example, the erosion operation can remove small noise points, and the dilation operation can expand the object area, thereby better segmenting adjacent target objects.

[0081] In some embodiments, image distance transform processing is a processing technique for analyzing the morphology of objects in an image. The distance from each pixel to the nearest background pixel is calculated, and a "distance map" representing the morphology of the object in the image is generated. Image distance transform processing can generally be used to process irregular or connected target objects, which can help further clarify the segmentation of the target object. It is suitable for cases where the object morphology is irregular, and it also helps to identify the central area and boundary of the target object, and improve the distinction between the target object and the background, especially for target objects with complex morphology.

[0082] In some embodiments, the image thresholding process is to segment the image according to the gray value, set the pixels within a certain gray range in the image as the foreground (target object), and the rest as the background. The thresholding process can extract different features or target objects from the image by setting different thresholds. The thresholding process includes global thresholding and adaptive thresholding, which can clearly distinguish the target object and the background in the image, and try to ensure that the obvious part of the target object is segmented, providing a clear basis for the subsequent target object.

[0083] Therefore, in the present application, by comprehensively using image processing technologies such as image enhancement processing, image Gaussian blur processing, image binarization processing, image morphological operation processing, image distance transformation processing, and image thresholding processing, the quality of image preprocessing can be significantly improved, making the contour of the target object clearer, and the background noise is effectively suppressed, and the error in the image can be reduced. The preprocessed image is more suitable for subsequent image segmentation processing operations, ensuring that the segmentation processing can proceed smoothly, especially when there are noise, adhesion or irregular morphology target objects in the image, providing a good technical foundation for subsequent image segmentation and target object detection.

[0084] Optionally, in step S400, the calculation formula for the i-th target object number M i in the i-th segmented area is:

[0085]

[0086] Among them, Mi is the number Mi of the i-th target object in the i-th segmentation area, Ai is the area of ​​the i-th segmentation area, Ci is the perimeter of the i-th segmentation area, AS is the average area of ​​a single target object, PS is the average perimeter of a single target object, α is the first adjustable coefficient, and β is the second adjustable coefficient.

[0087] In some embodiments, the value range of the first adjustable coefficient α is 0≤α≤2, the value range of the second adjustable coefficient β is 0≤β≤2, and the size of the average area AS can be selected according to actual conditions, for example, 1 mm 2 -100mm 2 The size of the average perimeter PS can be selected as 0-50 mm according to actual conditions, etc. Those skilled in the art can reasonably set the average area AS and the average perimeter PS of a single target object according to actual conditions, and this application does not limit this.

[0088] Optionally, in step S600, step S600 includes:

[0089] Step S601: when the number of target objects and the number of contours do not match, obtaining one or more corresponding segmentation regions;

[0090] Step S602: Determine whether the number of target objects in one or more segmented areas is greater than a preset value R, if yes, proceed to step S603, if no, proceed to step S604;

[0091] Step S603: performing morphological operation processing and watershed algorithm processing again on one or more segmented regions to form a new image, wherein the morphological operation processing includes image corrosion processing or image dilation processing, taking the new image as the input image in step S200, and re-entering step S200;

[0092] Step S604: Re-enter step S200.

[0093] In some embodiments, in step S601, when the number of target objects does not match the number of contours, one or more corresponding segmentation areas will inevitably be obtained. These segmentation areas are usually generated after being processed by a watershed algorithm. There may be situations where the target objects are irregular in shape, the target objects are adhered, etc., and they cannot be accurately segmented. Confirming these inaccurately segmented segmentation areas can prepare for further optimization of the image segmentation process.

[0094] In some embodiments, the preset value R can be 1, 2, etc. Of course, the preset value R can also be other values. Those skilled in the art can reasonably set the size of the preset value R according to actual conditions, and the present invention application does not impose any special restrictions on this.

[0095] In some embodiments, in step S602, it is determined whether the number of target objects in these segmented areas is greater than a preset value R. If it is greater than the preset value R, it indicates that there may be target objects with irregular shapes, adhesions or overlapping targets in one or more segmented areas, and further processing is required to achieve accurate segmentation, and the process accordingly enters step S603; if the number of target objects is not greater than R (that is, it means less than or equal to R), but the number of target objects and the number of contours in the input image do not match, then the process can return to step S200 again, and the process accordingly enters step S604.

[0096] In some embodiments, in step S603, one or more segmented regions are subjected to morphological operation processing and watershed algorithm processing again. Among them, the morphological operation processing again: operations such as image corrosion or expansion can be used to adjust the boundary of the target object. The corrosion operation can remove the small connection or noise between the target objects, and the expansion operation can help connect the adjacent target objects in the segmented region to prevent them from being misjudged as one object; the watershed algorithm is applied again: after the morphological processing, the watershed algorithm is used again to segment the image. At this time, since the morphological operation optimizes the structure in the image, the watershed algorithm can more accurately identify multiple target objects in the segmented region, reduce the phenomenon of mis-segmentation or adhesion, and further refine the image segmentation, and improve the separation and accuracy of the target objects. On this basis, after the one or more segmented regions are subjected to morphological operation processing and watershed algorithm processing again, a new image can be formed by combining one or more segmented regions whose number of target objects and the number of contours match.

[0097] In some embodiments, in step S603 and step S604, after re-entering step S200, step S200, step S300, step S400, and step S500 will be processed accordingly until all quantities are matched; or, after iteratively repeating step S200, step S300, step S400, step S500, and step S600 for multiple times, step S200, step S300, step S400, and step S500 will be processed again until all quantities are matched.

[0098] In the present invention, the design of step S600 effectively improves the accuracy of image segmentation by introducing an iterative optimization mechanism. In each segmentation process, the non-matching area is processed again, and the combination of morphological operation processing and watershed algorithm processing is adopted to gradually eliminate the target objects with adhesion, overlap or irregular shape in the image. This iterative optimization mechanism can handle complex image segmentation problems, especially when there are multiple target objects with adhesion or irregular shape in the image, it can improve the accuracy and quality of image segmentation processing, ensure the accuracy of the final image segmentation, and also improve the accuracy of the target object quantity statistics, meeting the actual needs in various application scenarios such as medical imaging, industrial detection, and agricultural monitoring.

[0099] Target object segmentation processing system in image

[0100] like Figure 3 As shown, in a second aspect, a target object segmentation processing system S in an image is used to implement any target object segmentation processing method in an image described in the first aspect, including:

[0101] It should be noted that a system for segmenting and processing target objects in an image applied for by the present invention is used to implement any of the methods for segmenting and processing target objects in an image in the first aspect, and accordingly also includes: all the technical problems, technical solutions and technical effects recorded in any of the methods for segmenting and processing target objects in an image in the first aspect, which will not be repeated in the present application.

[0102] An input module 100 is used to input an image, wherein the image includes a target object with irregular shapes and / or a plurality of target objects that are adhered to each other;

[0103] The preprocessing segmentation module 200 is used to preprocess the image and segment the image using a watershed algorithm to obtain a plurality of segmented regions, wherein the plurality of segmented regions include a first segmented region, a second segmented region, ..., an i-th segmented region, ..., an n-th segmented region;

[0104] The geometric feature calculation module 300 obtains, according to the plurality of segmented areas, a first segmentation contour of a first segmented area, a second segmentation contour of a second segmented area, ..., an i-th segmentation contour of an i-th segmented area, ..., and an n-th segmentation contour of an n-th segmented area respectively; calculates, according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., and the n-th segmentation contour, a first geometric feature of the first segmented area, a second geometric feature of the second segmented area, ..., an i-th geometric feature of the i-th segmented area, ..., and an n-th geometric feature of the n-th segmented area respectively; the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature all include at least one of an area, a perimeter, and a shape factor;

[0105] The quantity calculation acquisition module 400 calculates the first target object quantity M1 of the first segmented area, the second target object quantity M2 of the second segmented area, ..., the i-th target object quantity M i of the i-th segmented area, ..., and the n-th target object quantity Mn of the n-th segmented area according to the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature; obtains the first contour quantity P1 of the first segmented area, the second contour quantity P2 of the second segmented area, ..., the i-th contour quantity Pi of the i-th segmented area, ..., and the n-th contour quantity Pn of the n-th segmented area;

[0106] The judgment processing module 500 judges whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number Mi matches the i-th contour number Pi, ..., whether the n-th target object number Mn matches the n-th contour number Pn. If all the numbers match, the image segmentation processing is terminated; if at least one number does not match, the image segmentation processing continues.

[0107] In some embodiments, the preprocessing segmentation module 200 includes an image preprocessing unit and a segmentation unit. The image preprocessing unit preprocesses the image. The image preprocessing includes: image enhancement processing; image Gaussian blur processing, image binarization processing, image morphological operation processing, image distance transformation processing, image thresholding processing. The image enhancement processing includes: image enhancement processing using the Laplace operator. The image morphological operation processing includes: image closing operation processing. The segmentation unit 202 uses a watershed algorithm to segment the image to obtain multiple segmented areas.

[0108] In some embodiments, the quantity calculation and acquisition module 400 includes a target object quantity calculation unit and a contour quantity acquisition unit. The target object quantity calculation unit calculates the first target object quantity M1 of the first segmented area, the second target object quantity M2 of the second segmented area, …, the i-th target object quantity Mi of the i-th segmented area, …, and the n-th target object quantity Mn of the n-th segmented area based on the first geometric feature, the second geometric feature, …, the i-th geometric feature, …, and the n-th geometric feature; the contour quantity acquisition unit acquires the first contour quantity P1 of the first segmented area, the second contour quantity P2 of the second segmented area, …, the i-th contour quantity Pi of the i-th segmented area, …, and the n-th contour quantity Pn of the n-th segmented area.

[0109] like Figure 4 As shown, optionally, the judgment processing module 500 includes a judgment unit 501 and a processing unit 502, the judgment unit 501 judges whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2,…, whether the i-th target object number Mi matches the i-th contour number Pi…, whether the n-th target object number Mn matches the n-th contour number Pn, outputs a judgment result and sends it to the processing unit 502, the judgment result includes that all quantities match or at least one quantity does not match; the processing unit 502, based on the judgment result, if all quantities match, the processing unit 502 ends the image segmentation processing; if at least one quantity does not match, the processing unit 502 continues to segment the image.

[0110] In some embodiments, if the number of all target objects matches the number of contours, it means that the image has been accurately segmented and the target objects have been correctly identified. At this time, the image segmentation process can be terminated, and the image processed by the target object segmentation process method in the output image can be displayed.

[0111] In the target object segmentation processing system in the image applied for by the present invention, firstly, by introducing the segmentation area, geometric features, and whether the number of targets matches the number of contours, the accuracy of image segmentation processing can be significantly improved, and the erroneous segmentation caused by the similarity or adhesion of the target objects can be reduced. It can adapt to a variety of complex image scenes (such as multiple small target objects, convex points, particles, etc.), overlapping or adhered objects, etc., and improve the wide applicability of the image segmentation processing method; in addition, through multiple iterative adjustments and morphological operations, it can effectively process target objects with irregular shapes, overlapping or adhesion, improve the accuracy and stability of image segmentation processing results, reduce manual intervention, and improve the automation, intelligence and processing efficiency of image segmentation processing.

[0112] Optionally, the calculation formula for the i-th target object number M i in the i-th segmented area is:

[0113]

[0114] Among them, Mi is the number Mi of the i-th target object in the i-th segmentation area, Ai is the area of ​​the i-th segmentation area, Ci is the perimeter of the i-th segmentation area, AS is the average area of ​​a single target object, PS is the average perimeter of a single target object, α is the first adjustable coefficient, and β is the second adjustable coefficient.

[0115] In some embodiments, the value range of the first adjustable coefficient α is 0≤α≤2, the value range of the second adjustable coefficient β is 0≤β≤2, and the size of the average area AS can be selected according to actual conditions, for example, 1 mm 2 -100mm 2 The size of the average perimeter PS can be selected as 0-50 mm according to actual conditions, etc. Those skilled in the art can reasonably set the average area AS and the average perimeter PS of a single target object according to actual conditions, and this application does not limit this.

[0116] Optionally, when the processing unit 502 continues to perform segmentation processing on the image, the processing unit 502 includes a segmentation area acquisition subunit 5021, a target object quantity judgment subunit 5022 and a secondary processing formation subunit 5023. The segmentation area acquisition subunit 5021 acquires one or more segmentation areas corresponding to this time; the target object quantity judgment subunit 502 judges whether the number of target objects in one or more segmentation areas is greater than a preset value R, and outputs the target object quantity judgment result; based on the target object quantity judgment result, if it is greater than the preset value R, the secondary processing formation subunit 5023 performs morphological operation processing and watershed algorithm processing on one or more segmentation areas again and forms a new image, the morphological operation processing includes image corrosion processing or image expansion processing, and the target object segmentation processing system in the image is used again to process the new image; if it is not greater than the preset value R, the target object segmentation processing system in the image is used again to process the input image.

[0117] In some embodiments, when the processing unit 502 continues to perform segmentation processing on the image, it means that: the number of target objects and the number of contours in at least one segmented area do not match. Accordingly, first, when the number of target objects and the number of contours in at least one segmented area do not match, one or more segmented areas corresponding to this time can be obtained; then, it is determined whether the number of target objects in one or more segmented areas is greater than a preset value R. If it is greater than the preset value R, it indicates that there may be target objects with irregular shapes, adhesions or overlaps in one or more segmented areas, and the processing unit 502 must be used for further processing to achieve accurate segmentation; if the number of target objects is not greater than R (that is, it means less than or equal to R), but the number of target objects and the number of contours in the input image do not match at this time, then the input image can be processed again using the target object segmentation processing system in the image.

[0118] In some embodiments, if it is greater than the preset value R, the secondary processing forming subunit 5023 performs morphological operation processing and watershed algorithm processing on one or more segmented areas again and forms a new image. Specifically, it includes: morphological operation processing again: operations such as image corrosion or expansion can be used to adjust the boundary of the target object. The corrosion operation can remove the small connection or noise between the target objects, and the expansion operation can help connect the adjacent target objects in the segmented area to avoid them being misjudged as one object; re-application of the watershed algorithm: after the morphological processing, the watershed algorithm will be used again to segment the image. At this time, since the morphological operation optimizes the structure in the image, the watershed algorithm can more accurately identify multiple target objects in the segmented area, reduce the phenomenon of mis-segmentation or adhesion, and realize further refined image segmentation, and improve the separation and accuracy of the target objects. On this basis, after the one or more segmented areas are processed again by morphological operation processing and watershed algorithm processing again, a new image can be formed by combining one or more segmented areas whose number of target objects and the number of contours match.

[0119] In some embodiments, the target object segmentation processing system in the image is used again to process a new image, including: the new image can be input through the input module 100 (or, the new image is input into the input module 100), and then processed through the pre-processing segmentation module 200, the geometric feature calculation module 300, the quantity calculation acquisition module 400 and the judgment processing module 500 until all quantities are matched.

[0120] In some embodiments, the input image is processed again using the target object segmentation processing system in the image, including: the original input image is processed again through the pre-processing segmentation module 200, the geometric feature calculation module 300, the quantity calculation acquisition module 400 and the judgment processing module 500 until all quantities are matched.

[0121] In the present invention, when the processing unit 502 continues to perform segmentation processing on the image, the accuracy of image segmentation is effectively improved by introducing an iterative optimization mechanism. In each segmentation process, the unmatched area is processed again, and a combination of morphological operation processing and watershed algorithm processing is used to gradually eliminate the target objects with adhesion, overlap or irregular shape in the image. This iterative optimization mechanism can handle complex image segmentation problems, especially when there are multiple target objects with adhesion or irregular shape in the image, it can improve the accuracy and quality of image segmentation processing, ensure the accuracy of the final image segmentation, and also improve the accuracy of the target object quantity statistics.

[0122] Device for detecting and segmenting target objects in images

[0123] In a third aspect, the present invention application provides a device for segmenting and processing target objects in an image, comprising a memory and a processor that are communicatively connected, wherein the memory is used to store a computer program, and the processor is used to read the computer program and execute a method for segmenting and processing target objects in an image as described in any one of the first aspects.

[0124] Those skilled in the art can understand that the device for segmenting target objects in an image includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in any of the above-mentioned methods for segmenting target objects in an image in the first aspect are implemented.

[0125] Computer readable storage medium

[0126] In a fourth aspect, the present invention application provides a computer-readable storage medium having instructions stored thereon. When the instructions are run on a computer, the method for segmenting a target object in an image as described in any one of the first aspects is executed.

[0127] Those skilled in the art will understand that the schematic diagram is merely an example of a terminal device and does not constitute a limitation on the terminal device. The terminal device may include more or fewer components than shown in the diagram, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.

[0128] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the terminal device, and uses various interfaces and lines to connect various parts of the entire terminal device.

[0129] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the terminal device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Med ia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0130] Wherein, if the module / unit integrated in the terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0131] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.

[0132] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for segmenting a target object in an image, characterized in that: include: Step S100: inputting an image, the image including a target object with irregular shape and / or a plurality of target objects adhered to each other; Step S200: preprocessing the image, segmenting the image using a watershed algorithm to obtain a plurality of segmented regions, the plurality of segmented regions including a first segmented region, a second segmented region, ..., an i-th segmented region, ..., an n-th segmented region, where i = 1, 2, 3, ..., n; Step S300: According to the plurality of segmented regions, respectively obtain the first segmentation contour of the first segmented region, the second segmentation contour of the second segmented region, ..., the i-th segmentation contour of the i-th segmented region, ..., the n-th segmentation contour of the n-th segmented region; respectively calculate the first geometric feature of the first segmented region, the second geometric feature of the second segmented region, ..., the i-th geometric feature of the i-th segmented region, ..., the n-th geometric feature of the n-th segmented region according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., the n-th segmentation contour; the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., the n-th geometric feature all include at least one of area, perimeter, and shape factor; Step S400: Calculate the first target object number M1 of the first segmented area, the second target object number M2 of the second segmented area, ..., the i-th target object number Mi of the i-th segmented area, ..., the n-th target object number Mn of the n-th segmented area according to the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., the n-th geometric feature; Obtain the first contour number P1 of the first segmented area, the second contour number P2 of the second segmented area, ..., the i-th contour number Pi of the i-th segmented area, ..., and the n-th contour number Pn of the n-th segmented area; Step S500: determine whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number Mi matches the i-th contour number Pi, ..., whether the n-th target object number Mn matches the n-th contour number Pn. If all the numbers match, end the image segmentation process; If at least one of the quantities does not match, proceed to step S600; Step S600: continue to segment the image; In step S400, the calculation formula for the i-th target object number Mi in the i-th segmented area is: Among them, Mi is the number Mi of the i-th target object in the i-th segmentation area, Ai is the area of ​​the i-th segmentation area, Ci is the perimeter of the i-th segmentation area, AS is the average area of ​​a single target object, PS is the average perimeter of a single target object, α is the first adjustable coefficient, and β is the second adjustable coefficient.

2. The method for segmenting a target object in an image according to claim 1, characterized in that: In step S200, the image is preprocessed including: image enhancement processing; image Gaussian blur processing, image binarization processing, image morphological operation processing, image distance transformation processing, image thresholding processing, the image enhancement processing includes: image enhancement processing using Laplace operator, and the image morphological operation processing includes: image closing operation processing.

3. The method for segmenting a target object in an image according to claim 2, characterized in that: In step S600, step S600 includes: Step S601: when the number of target objects and the number of contours do not match, obtaining one or more corresponding segmentation regions; Step S602: Determine whether the number of target objects in one or more segmented areas is greater than a preset value R, if yes, proceed to step S603, if no, proceed to step S604; Step S603: performing morphological operation processing and watershed algorithm processing again on one or more segmented regions to form a new image, wherein the morphological operation processing includes image corrosion processing or image dilation processing, taking the new image as the input image in step S200, and re-entering step S200; Step S604: Re-enter step S200.

4. A target object segmentation processing system in an image, used to implement the target object segmentation processing method in an image according to any one of claims 1 to 3, characterized in that: include: An input module, used for inputting an image, wherein the image includes a target object with irregular shapes and / or a plurality of target objects adhered to each other; A preprocessing segmentation module is used to preprocess the image and segment the image using a watershed algorithm to obtain a plurality of segmented regions, wherein the plurality of segmented regions include a first segmented region, a second segmented region, ..., an i-th segmented region, ..., an n-th segmented region, where i = 1, 2, 3, ..., n; A geometric feature calculation module, which obtains, according to the plurality of segmented areas, a first segmentation contour of a first segmented area, a second segmentation contour of a second segmented area, ..., an i-th segmentation contour of an i-th segmented area, ..., and an n-th segmentation contour of an n-th segmented area respectively; and calculates, according to the first segmentation contour, the second segmentation contour, ..., the i-th segmentation contour, ..., and the n-th segmentation contour, a first geometric feature of the first segmented area, a second geometric feature of the second segmented area, ..., an i-th geometric feature of the i-th segmented area, ..., and an n-th geometric feature of the n-th segmented area respectively; the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature all include at least one of an area, a perimeter, and a shape factor; A quantity calculation acquisition module calculates the first target object quantity M1 of the first segmented area, the second target object quantity M2 of the second segmented area, ..., the i-th target object quantity Mi of the i-th segmented area, ..., and the n-th target object quantity Mn of the n-th segmented area according to the first geometric feature, the second geometric feature, ..., the i-th geometric feature, ..., and the n-th geometric feature; Obtain the first contour number P1 of the first segmented area, the second contour number P2 of the second segmented area, ..., the i-th contour number Pi of the i-th segmented area, ..., and the n-th contour number Pn of the n-th segmented area; The judgment processing module judges whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number Mi matches the i-th contour number Pi, ..., whether the n-th target object number Mn matches the n-th contour number Pn. If all the numbers match, the image segmentation processing is terminated; if at least one number does not match, the image segmentation processing continues.

5. The system for segmenting a target object in an image according to claim 4, characterized in that: The calculation formula for the number of target objects Mi in the i-th segmentation area is: Among them, Mi is the number Mi of the i-th target object in the i-th segmentation area, Ai is the area of ​​the i-th segmentation area, Ci is the perimeter of the i-th segmentation area, AS is the average area of ​​a single target object, PS is the average perimeter of a single target object, α is the first adjustable coefficient, and β is the second adjustable coefficient.

6. A target object segmentation processing system in an image according to claim 5, characterized in that: The judgment processing module includes a judgment unit and a processing unit. The judgment unit judges whether the first target object number M1 matches the first contour number P1, whether the second target object number M2 matches the second contour number P2, ..., whether the i-th target object number Mi matches the i-th contour number Pi..., whether the n-th target object number Mn matches the n-th contour number Pn, outputs the judgment result and sends it to the processing unit. The judgment result includes that all quantities match or at least one quantity does not match; the processing unit, based on the judgment result, if all quantities match, the processing unit ends the image segmentation processing; if at least one quantity does not match, the processing unit continues to segment the image.

7. The system for segmenting a target object in an image according to claim 6, characterized in that: When the processing unit continues to perform segmentation processing on the image, the processing unit includes a segmentation region acquisition subunit, a target object quantity judgment subunit and a secondary processing formation subunit, and the segmentation region acquisition subunit acquires one or more segmentation regions corresponding to this time; The target object quantity determination subunit determines whether the number of target objects in one or more segmented areas is greater than a preset value R, and outputs a target object quantity determination result; Based on the result of the target object quantity judgment, if it is greater than the preset value R, the secondary processing forming subunit performs morphological operation processing and watershed algorithm processing on one or more segmented areas again to form a new image. The morphological operation processing includes image corrosion processing or image expansion processing, and the target object segmentation processing system in the image is used again to process the new image; if it is not greater than the preset value R, the target object segmentation processing system in the image is used again to process the input image.

8. A device for detecting and segmenting target objects in an image, characterized in that: It comprises a memory and a processor which are communicatively connected, wherein the memory is used to store a computer program, and the processor is used to read the computer program and execute a method for segmenting a target object in an image as described in any one of claims 1 to 3.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a computer, the method for segmenting a target object in an image as described in any one of claims 1 to 3 is executed.

Citation Information

Patent Citations

  • Vehicle image segmentation quality evaluation method and device, equipment and storage medium

    CN114387331A

  • Character image segmentation method based on feature contour

    CN115272378A