A medical segmentation image concave defect filling method based on convex hull high power fitting
The concave defects of medical segmentation images are extracted and filled by the convex hull high-power fitting method, which solves the problem of edge missing in neural network segmentation and achieves more accurate and automated medical image processing.
Patent Information
- Application Number
- CN202310576131.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-22
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2043-05-22
AI Technical Summary
Existing medical segmentation images based on neural networks are prone to edge pixel missing and concave defects in organ segmentation areas, which affects the accuracy and completeness of disease diagnosis.
The convex hull high-power fitting method is adopted to extract the edge contour concave defect information through Graham scanning, calculate the key points and construct a set, and use the high-power curve to fit the concave defect area. Combined with the adaptive threshold and flood filling processing, the concave defect is smoothly filled.
It improves the edge integrity and fineness of medical segmentation images, enhances the accuracy and automation of disease diagnosis, and reduces dependence on doctors' subjective experience.
Smart Images

Figure CN116596791B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of medical image processing, and particularly relates to a medical segmentation image concave defect filling method based on convex hull high power fitting. BACKGROUND
[0002] Medical segmentation images provide key information such as the position and contour shape of a lesion or organ region, and can effectively assist doctors in making clinical decisions and diagnosing diseases.
[0003] The artificial segmentation method widely used in clinical practice is very time-consuming and depends on the subjective experience of doctors, and needs to occupy a large amount of social medical resources. The current popular medical image segmentation method based on a convolutional neural network has high precision and automation.
[0004] However, the existing medical images are inevitably affected by factors such as noise, edge blur and network structure, resulting in pixel missing concave defects in the segmentation edge, thereby affecting the completeness and fineness of the organ region segmentation, which is not conducive to the diagnosis of diseases by doctors. SUMMARY
[0005] The problem to be solved by the present application is that the existing medical segmentation images based on a neural network are prone to pixel missing concave defects in the edge of the organ segmentation region due to various factors.
[0006] To solve the above technical problems, the present application provides a medical segmentation image concave defect filling method based on convex hull high power fitting, comprising the following steps:
[0007] S1, obtaining a medical binary segmentation image after pre-processing, and then extracting a single-pixel organ edge contour;
[0008] S2, extracting edge contour concave defect information by Graham scanning, wherein the concave defect information includes the starting point coordinates , the ending point coordinates , the farthest point coordinates and the deepest distance of the concave defect of the concave defect at each position on the contour;
[0009] S3, constructing a key point set , calculating the intermediate point and the transition point using the concave defect information extracted in step S2, and extending the coordinates;
[0010] S4, traversing the set and fitting the point set with a high power curve in turn;
[0011] S5: using the adaptive threshold of the connected domain pixel area to determine the concave defect area, and processing the background area by flood filling;
[0012] S6: Perform logical operations on the filled image and the original input image to obtain a smooth and complete filled image;
[0013] Preferably, the specific steps of S1 are:
[0014] Step 1: Input the medical binary segmentation image, perform morphological processing, and then perform weighted average calculation based on the RGB three channels to obtain a more reasonable grayscale image;
[0015] Step 2: Use edge detection to extract the single-pixel outline of the organ edge from the grayscale image;
[0016] Preferably, the specific steps of extracting the edge contour concave defect information in S2 are:
[0017] Step 1: Find the outer contour of the organ in the image;
[0018] Step 2: Use Graham scanning to obtain all concave defect information on the external contour;
[0019] Step 3: Use parameter indicators to determine the non-concave defect area;
[0020] Preferably, the Graham scan in S2 determines the sign of two consecutive line segments by calculating the sign of the cross product. and At the point The turning point;
[0021] Preferably, the concave defect information in S2 includes the starting point coordinates , end point coordinates , coordinates of the farthest point and the deepest distance of the concave defect ;
[0022] Preferably, the starting point obtained in step S2 is used in step S3 and end point Calculate the midpoint in a 2D coordinate system ;
[0023] Preferably, the proportional coefficient is determined in S3 and through the midpoint and the farthest point Calculate the transition point in a 2D coordinate system ;
[0024] Preferably, the coordinates determined in S3 and coordinates Extend the front and back pixels on the edge contour of the region to obtain a total of six key points after extension;
[0025] Preferably, the traversal set in S4 , including points 、 as well as , and use the power The high powers of The key point in , i.e. smooth curve fitting;
[0026] Preferably, after the curve fitting in S5, several small connected domains are formed on the contour, i.e., concave defect areas, and the areas corresponding to all contours on the image are calculated, and the areas of the concave defect areas are determined by an adaptive pixel threshold;
[0027] Preferably, the specific steps of the flood filling process in S5 are:
[0028] Step 1: Add two pixels in the horizontal and vertical directions of the image to create a mask;
[0029] Step 2: Select the image seed point seedPoint and the color to be filled;
[0030] Step 3: Set the upper and lower limits of the pixel RGB threshold to redraw the color of the background area;
[0031] Preferably, in said S6, the image obtained in step S5 is subjected to a bitwise NOT operation, and then subjected to a bitwise OR operation with the original input image, and a combined image is obtained after the above logical operation.
[0032] The beneficial effects of the present invention are:
[0033] The present invention provides a concave defect filling method for medical segmentation images based on convex hull high-order power fitting. Based on the neural network segmentation image, the image is subjected to morphological processing, grayscale conversion and edge detection to extract the edge contour of the organ; Graham scanning is used to extract the edge contour concave defect information; key points are calculated and a key point set is constructed. ; Use high-order power curves to connect point sets in sequence to obtain a smooth fitting contour; determine the concave defect area through an adaptive threshold and perform flood filling on the background area; perform logical operations on the filled image to obtain a concave defect filled image; From the perspective of image processing, the present invention smoothly fills the concave defect area on the contour, and has the advantages of good filling effect and high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 This is a flow chart of a method for filling concave defects in medical segmentation images provided by an embodiment of the present invention;
[0035] Figure 2 1 is a local schematic diagram of a concave defect obtained by high-order power curve fitting in an embodiment of the present invention;
[0036] Figure 3 is a partial schematic diagram of a concave defect after filling treatment in an embodiment of the present invention;
[0037] Figure 4 is an image after all concave contour defects in the medical segmentation image in the embodiment of the present invention are smoothly filled; DETAILED DESCRIPTION
[0038] In order to clearly and completely describe the technical solutions and technical effects of the present invention, they are described in detail through the following embodiments.
[0039] Example 1
[0040] like Figure 1 As shown, the concave defect filling method of medical segmentation images based on convex hull high-order power fitting includes the following steps:
[0041] S1. Obtain a medical binary segmentation image and perform morphological operations and grayscale processing, and then extract the edge contour of the organ through Gaussian filtering and contour thresholding;
[0042] In this embodiment, the specific method for image pre-processing and edge contour extraction includes the following steps:
[0043] Performing closing operations based on dilation and erosion on the medical binary segmentation image can remove small "burrs" on the edge of the organ and form a smoother whole.
[0044] Considering that grayscale images occupy less memory and have significant visual contrast, they can better highlight organs. The image processed by the closing operation is weighted averaged into three parts according to the importance of the three RGB channels to obtain a more reasonable grayscale image.
[0045] Since the human eye is more sensitive to green, the G channel has a larger weight coefficient. The weights of the RGB components are 0.299, 0.587, and 0.114 respectively. The grayscale calculation formula is as follows:
[0046]
[0047] Gaussian filtering is performed on the grayscale image to smooth the non-regional texture at the edge and reduce the interference of image edge noise to facilitate subsequent gradient calculation. The gradient calculation formula is as follows:
[0048]
[0049]
[0050] in, represents the gradient to be sought, and Represent the gradients in the X and Y directions respectively, Indicates the direction of the gradient;
[0051] Non-maximum suppression is used to eliminate false edges of non-local grayscale to achieve the purpose of edge refinement. Finally, double threshold detection is used to retain strong edges and suppress weak edges. Through the above steps, single-pixel contour extraction of organ edges is achieved.
[0052] S2, using Graham scanning to extract all concave defect information on the edge contour;
[0053] In this embodiment, the specific method for extracting concave defect information includes the following steps:
[0054] Call the cv2.findContours() function in the OpenCV library to find the organ contour, passing in the cv2.RETR_EXTERNAL parameter to use the external contour retrieval method;
[0055] Determine the convex hull point set on the edge , and find the point with the minimum Y-axis coordinate marked as ,If there are multiple coordinates with the same Y value, take the point with the smallest X coordinate value;
[0056] Point set According to the polar angle Sort from small to large, if If they are the same, distance is preferred A closer point;
[0057] Will Push the points into the stack sequentially and traverse the remaining points in a counterclockwise direction , by calculating the cross product, we exclude the internal points of the convex hull and retain the vertex point set of the convex hull; the cross product calculation formula is as follows:
[0058]
[0059] in represents the result of cross product calculation, represents the convex hull points of the contour, Represents the set of convex hull points, when When , it means that the point is inside the convex hull, then delete it. When , it means that the point is outside the convex hull, then save it;
[0060] Concave defect information extracted by Graham scanning includes: starting point coordinates , end point coordinates , coordinates of the farthest point and the deepest distance of the concave defect ;
[0061] Calculate coordinates With coordinates Distance indicator between , when the indicator and When the contour of this segment is judged to be a concave defect area, it is retained and the rest are removed.
[0062] S3. Use the extracted concave defect information to create the remaining key points and jointly construct the key point set ;
[0063] In this embodiment, the specific method for constructing the key point set includes the following steps:
[0064] Using coordinates and coordinates Calculate the midpoint in a 2D coordinate system , the calculation formula is as follows:
[0065]
[0066] in 、 and Represents the X-axis coordinate values of the middle point, starting point and end point respectively. 、 and Represents the Y-axis coordinate values of the middle point, starting point and end point respectively;
[0067] Then connect the middle points in the two-dimensional coordinate system and the farthest point , the transition point to be created Located on the connecting line, select the scale factor ,Right now The length of the line segment accounts for the total length Line segment ; Transition point The coordinates are calculated as follows:
[0068]
[0069]
[0070]
[0071] Extend the contour coordinates, specifically to determine the starting point coordinates Then, take the contour curve The coordinates of the first n pixels And the coordinates of the last n pixels , that is, we get ; Similarly, take the contour curve The coordinates of the first n pixels And the coordinates of the last n pixels ,get ;
[0072] The key point coordinates obtained include: 、 and , and store them in key point sets in sequence middle.
[0073] S4, sequential traversal of the collection , and use high-order power curves to connect the point sets in sequence to form a smooth fitting curve;
[0074] In this embodiment, the specific method for high-order power curve fitting includes the following steps:
[0075] Sequential traversal reading collection Middle key point, using the highest power The high-order power curve connects the key points in sequence; the high-order power curve equation is as follows:
[0076]
[0077] in 、 、 and are all constants; high-order power curve fitting has better connection stability and smoothness than straight line connection, such as Figure 2 As shown, the inclined shadow part is the background, and the horizontal shadow part is the area to be filled.
[0078] S5. Using pixel area adaptive thresholds to determine several closed connected domains formed after curve fitting, excluding non-concave defect areas to further improve the accuracy of concave defect area determination, and simultaneously using flood filling to fill pixels in the image background to extract concave defect areas;
[0079] In this embodiment, the outer contour of the organ is found and input as a parameter to the cv2.contourArea() function in the OpenCV library to calculate the area of the closed contour. Through adaptive threshold adjustment, all closed contours on the edge that are larger than the threshold are added to the created contour set;
[0080] Add two pixel values in the horizontal and vertical directions of the image to create a mask image, and the generated mask image is a single-channel array of uint8;
[0081] Select the image seed point seedPoint as (0, 0), that is, the left upper corner coordinate point of the image, and set the RGB value as (255, 255, 255) to be filled color;
[0082] The upper and lower limits of the filling pixel threshold value are set as (120, 120, 120) and (0, 0, 0) respectively, and then the image background is processed as pure white;
[0083] The RGB pixels of the image background area are filled to the same RGB value (255, 255, 255) as the organ area, at this time, only the concave defect area in the image is pure black with RGB value (0, 0, 0), realizing the extraction of the concave defect area, as shown in Figure 3 , wherein the shaded part is the background area.
[0084] S6, performing logical operation on the filled image and the original input image to obtain a complete concave defect filled image after merging;
[0085] In the embodiment, the RGB value of the concave defect area in the filled image is (0, 0, 0), and the RGB value of the non-concave defect area is (255, 255, 255), so the pixel color is reversed by performing bitwise NOT operation on the filled image, to obtain a reversed image in which the concave defect area is white and the non-concave defect area is black;
[0086] The reversed image and the input binary image are subjected to bitwise OR operation, and the background area in the obtained image is still black, while the concave defect area is seamlessly merged with the organ, finally realizing the smooth filling of the concave defect of the medical segmentation image, as shown in Figure 4 , wherein the shaded part is the organ area.
[0087] The above only describes some embodiments of the present application. For those skilled in the art, without departing from the inventive concept, several modifications and improvements can be made, and any modification, equivalent replacement and improvement within the inventive concept are all within the protection scope of the present application.
Claims
1. A method for filling concave defects in medical segmentation images based on convex hull high-order power fitting, characterized in that: The following steps are involved: S1: Obtain medical binary segmentation images, perform pre-processing, and then extract single-pixel organ edge contours; S2: Graham scanning extracts the edge contour concave defect information, which includes the starting point coordinates S of each concave defect on the contour. i , End point coordinates E i , coordinates of the farthest point F i And the deepest distance D of the concave defect Far ; S3: Constructing a key point set Defect i ,in: S3.1: Calculate the midpoint in a two-dimensional coordinate system using the starting and ending points. S3.2: Calculate the transition point through the middle point and the farthest point according to the proportional coefficient λ, where 0<λ<1; S3.3: Extend the contour curve by n pixels before and after to obtain extended key points, where n is a positive integer representing the number of pixels extended on the contour curve; S4: traverse the key point set and use a high-order power curve with a power greater than 2 to fit the point set in sequence; S5: using the adaptive threshold of the connected domain pixel area to determine the concave defect area, and processing the background area by flood filling; S6: Perform logical operations on the filled image and the original input image to obtain a smooth and complete filled image.
2. The method for filling concave defects in medical segmentation images based on convex hull high-order power fitting according to claim 1, characterized in that: The specific steps of S1 are: Step 1: The input medical binary segmentation image is morphologically processed, and then the grayscale image is obtained by weighted averaging of the RGB three channels, where the weights of the three components are 0.299, 0.587, and 0.114 respectively; Step 2: Use edge detection to extract the single-pixel contour of the organ edge from the grayscale image.
3. The method for filling concave defects in medical segmentation images based on convex hull high-order power fitting according to claim 1, characterized in that: The specific steps of extracting the edge contour concave defect information in S2 are: Step 1: Find the outer contour of the organ in the image; Step 2: Use Graham scanning to obtain all concave defect information on the external contour; Step 3: Use parameter indicators to determine the non-concave defect area.
4. The method for filling concave defects in medical segmentation images based on convex hull high-order power fitting according to claim 1, characterized in that: The coordinates S determined in S3 i and coordinates E i The forward and backward pixel points are extended on the edge contour of the region, and a total of six key points are obtained after extension.
5. The method for filling concave defects in medical segmentation images based on convex hull high-order power fitting according to claim 1, characterized in that: The S4 traversal set Defect i , including point [S i-n ,S i ,S i+n ]、T i and [E i-n ,E i ,E i+n ], use the high power of σ to connect Defect in sequence i The key points in , where σ>2, are smooth curve fitting.
6. The method for filling concave defects in medical segmentation images based on convex hull high-power fitting according to claim 1, characterized in that: After the curve fitting in S5, several small connected domains are formed on the contour, namely, concave defect areas. The areas corresponding to all contours on the image are obtained, and the areas of the concave defect areas are determined by adaptive pixel thresholds.
7. The method for filling concave defects in medical segmentation images based on convex hull high-order power fitting according to claim 1, characterized in that: The specific steps of the flood filling process in S5 are: Step 1: Add two pixels in the horizontal and vertical directions of the image to create a mask; Step 2: Select the image seed point seedPoint and the color to be filled; Step 3: Set the upper and lower pixel RGB thresholds to repaint the background area.
8. The method for filling concave defects in medical segmentation images based on convex hull high-order power fitting according to claim 1, characterized in that: In step S6, the image obtained in step S5 is subjected to a bitwise NOT operation, and then subjected to a bitwise OR operation with the original input image, and a combined image is obtained after the above logical operation.