Method and system for processing cell image based on DistSeg model
By applying the DistSeg model and morphological operation image processing technology at the WSI level, the balance between accuracy and morphological authenticity in cell detection and segmentation is solved, and the cell detection and segmentation effect with high accuracy and morphological authenticity is achieved.
Patent Information
- Application Number
- CN202510158446.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-06-27
AI Technical Summary
The prior art is difficult to achieve a balance between high accuracy and morphological authenticity of cell detection and segmentation at the WSI level, especially when processing high-resolution large-scale images.
The image processing technology based on the DistSeg model is used to pre-treat the cell images, and the nuclear region is generated through star geometric regression and Euclidean distance transformation, and the morphological operation and watershed algorithm are combined to perform segmentation and optimization, and the intranuclear and surrounding contours of the cells are finally extracted.
It improves the accuracy and accuracy of cell detection results, improves the morphological performance of cell boundaries, enhances the separation ability of the foreground and background, and improves the overall cell detection and segmentation performance.
Smart Images

Figure CN120219283A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical image processing, and particularly relates to a method and system for detecting cells based on the DistSeg model image processing technology, and a method and system for stitching the cell image segmentation results. Background Art
[0002] With the development of digital pathology, the whole slide image (WSI) technology has become an important tool in pathological image analysis. The WSI technology can record the entire pathological section at high resolution, providing a basis for the storage, analysis, and sharing of large-scale pathological images. However, due to the complex cell morphology, high density, blurred boundaries in pathological images, and the diversity of microscope imaging conditions, achieving high-precision cell detection and segmentation has always been a major technical difficulty in this field.
[0003] Currently, the application of deep learning technology, especially convolutional neural networks (CNNs), has made remarkable progress in the field of automated processing of pathological images. For example, the segmentation method based on U-Net is widely used in medical image segmentation tasks due to its simple structure and excellent performance. In addition, generative adversarial networks (GANs) have also shown powerful capabilities in medical image enhancement and segmentation in recent years. For another example, the Pix2Pix GAN model can generate high-quality enhanced images through adversarial learning between the generator and the discriminator, making the cell nucleus center more prominent and the boundary clearer. At the same time, some methods based on traditional image processing technologies (such as morphological operations and watershed algorithms) are still widely used. These methods have certain advantages in capturing global features and enhancing boundary characteristics.
[0004] Nevertheless, the current cell detection and segmentation methods at the WSI level are still difficult to balance between accuracy and morphological authenticity. Especially when dealing with high-resolution large-scale images, how to combine the powerful modeling ability of deep learning with traditional image processing technologies to optimize the accuracy and morphological authenticity of cell contour detection is still an unsolved technical challenge. Summary of the Invention
[0005] The technical problem solved by the technical solution of the present invention is: how to improve the accuracy and precision of the cell detection results at the WSI level.
[0006] To solve the above technical problem, the technical solution of the present invention provides a method for detecting cells based on the DistSeg model image processing technology, including:
[0007] Preprocess the collected cell images;
[0008] Segment the cell images based on the DistSeg model image processing technology to generate the cell nucleus regions;
[0009] Based on the segmented cell nucleus regions, use morphological operations to generate background regions, foreground regions, and edge regions;
[0010] Calculate the shortest Euclidean distance from each background region pixel to the nearest foreground region pixel, and use the watershed algorithm to segment the cell images;
[0011] Optimize the results of the segmentation maps corresponding to each cell instance label to obtain the filtered segmentation label maps;
[0012] Extract the outer contours of the nuclear regions and the outer contours of the surrounding regions of each cell from the segmentation label maps, and save them to the corresponding result files.
[0013] Optionally, the preprocessing of the collected cell images includes:
[0014] Segment the collected cell images into several sub-images. The sub-images contain local cell information, and the position information of the sub-images in the global collected cell images is retained;
[0015] Convert the sub-images into grayscale format.
[0016] Optionally, the sub-images include: fluorescence images and bright-field images; the conversion of the sub-images into grayscale format includes:
[0017] After directly grayscaling the fluorescence images, filter out the images with weak background signals according to the pixel brightness distribution, and retain the regions with significant signals;
[0018] For the bright-field images, convert the RGB images to the HSI color model, extract and enhance the saturation component to highlight the contrast of the cell regions, and then convert the enhanced images to grayscale images for processing.
[0019] Optionally, the segmentation of the cell images based on the DistSeg model image processing technology includes:
[0020] Load the preprocessed cell images and use them as inputs;
[0021] Combined with the star-shaped geometric regression method, use the multi-directional distances from each pixel point to the cell nucleus boundary to describe the cell nucleus contour and reconstruct the star-shaped geometric polygon contour of the cell nucleus;
[0022] Based on the star-shaped geometric polygon contour, calculate the object probability of each pixel belonging to the cell nucleus, where the object probability is the normalized Euclidean distance from the pixel to the nearest background pixel;
[0023] Set a threshold, select the pixels whose object probability of the pixel object is greater than the threshold from all pixels, and generate the corresponding polygon candidate regions and the intersection-over-union ratio between the polygon candidate regions;
[0024] Use non-maximum suppression to remove overlapping candidate regions, sort the candidate regions according to the object probability, and sequentially retain the polygon candidate regions with the highest object probability and an intersection-over-union ratio less than the threshold with other candidate regions;
[0025] Assign labels to the retained polygon candidate regions and generate the final cell nucleus segmentation region.
[0026] Optionally, let the pixel points in the cell image be (i, j), where i and j are natural numbers greater than zero, i = 1, 2, …, I, j = 1, 2, …, J, and i and j are the horizontal and vertical marker numbers of the pixel points in the image coordinate system respectively; I and J are natural numbers greater than 1;
[0027] The reconstruction of the star-shaped geometric polygon contour of the cell nucleus by using the multi-directional distances from each pixel point to the cell nucleus boundary includes:
[0028] Use the Euclidean distance to represent the distance from the pixel (i, j) in the cell image to the boundary of the cell nucleus object in the cell image. Let the boundary k is a natural number greater than zero, representing the direction angle number of the currently selected pixel (i, j). Assume that the pixel (i, j) is equidistantly selected at the 1st, 2nd, …, nth preset direction angles to calculate the distance from the pixel to the selected object boundary at the selected direction angles. n is a natural number greater than 1, and k = 1, 2, …, n;
[0029]
[0030] where, θ k = n / (2πk), k = 1, 2, …, n is the selected direction angle number, and Boundary is the boundary of the current object;
[0031] Based on the Euclidean distance from the pixel (i, j) in the cell image to the cell nucleus object Reconstruct the star-shaped geometric polygon contour of the cell nucleus;
[0032] The calculation of the object probability of each pixel belonging to the cell nucleus includes:
[0033] Let the object probability of the pixel (i, j) be d i,j , there is:
[0034]
[0035] Among them, Distance((i,j), Background) represents the normalized distance from each pixel (i,j) to the nearest background pixel Background, and MaxDistance represents the maximum value among all the calculated normalized distances;
[0036] The generation of the corresponding polygon candidate regions and the intersection over union between the polygon candidate regions includes:
[0037] Let the pixels whose object probability is greater than the threshold be selected from all pixels according to the threshold as (i’,j’), where i’ = i1, i2,..., i x ; i1, i2,..., i x are the abscissa sequence numbers of the pixels with object probability greater than the threshold in 1, 2,..., I in sequence, x is a natural number greater than 1, and j’ = j1, j2,..., j y ; j1, j2,..., j y are the ordinate sequence numbers of the pixels with object probability greater than the threshold in 1, 2,..., J in sequence, and y is a natural number greater than 1;
[0038] Based on the selected pixels (i’,j’), the multi-directional distances from the selected pixels (i’,j’) to the nuclear boundary can be obtained
[0039] Based on the multi-directional distances from these pixels (i’,j’) with object probability greater than the threshold to the nuclear boundary the polygon candidate region A of the cell nucleus can be reconstructed i’,j’ ;
[0040] Define the polygon candidate region A i’,j’ (i’ = i1, i2,..., i x , j’ = j1, j2,..., j y ), the intersection over union IoU between the polygon candidate region A i’,j’ and other polygon candidate regions A u,v is as follows:
[0041]
[0042] u and v represent pixel values. When the value of the selected pixel point (i’, j’) is determined, the pixel point (u, v) is the pixel value other than the pixel point (i’, j’);
[0043] The sequential retention of the polygon candidate regions with the highest object probability and an intersection over union less than the threshold with other candidate regions includes:
[0044] Use non - maximum suppression to remove overlapping candidate regions in candidate region A to obtain A i’,j’ ; Let the pixels of the candidate region after removing the overlapping regions be (i0, j0), where i0 = i i0,j0 , i 10 , i 20 , …, i x0 ; i 10 , i 20 , …, i x0 , in sequence are the corresponding pixel abscissa sequence numbers of the subsequent regions obtained after removing the overlapping candidate regions in i, x0 is a natural number greater than 1; j0 = j x , j 10 , j 20 , …, j y0 ; j 10 , j 20 , …, j y0 in sequence are the corresponding pixel ordinate sequence numbers of the subsequent regions obtained after removing the overlapping candidate regions in j, y0 is a natural number greater than 1; y Sort candidate region A according to the object probability d of pixel (i0, j0)
[0045] and retain the polygon candidate region IoU(A i0,j0 ) with the highest object probability in d i0,j0 and an intersection - over - union ratio with other candidate regions less than the threshold; i0,j0 i0,j0 )
[0046] Assigning labels to the retained polygon candidate regions and generating the final nucleus segmentation region includes:
[0047] Based on the above - retained polygon candidate region IoU(A i0,j0 ), let I(iz, jz) represent the finally generated nucleus segmentation map, (iz, jz) represent the horizontal and vertical pixel sequence numbers for generating the segmentation map, obtained from the pixel (i0, j0) of the retained polygon candidate region IoU(A i0,j0 ), and based on the label assigned to the corresponding pixel (iz, jz) by P(iz, jz), then there is:
[0048]
[0049] Generate the final nucleus segmentation region based on these pixels (iz, jz) assigned labels.
[0050] Optionally, the morphological operations based on the segmented nucleus region to generate the background region, foreground region, and edge region include:
[0051] First, perform a dilation operation to increase the pixel values at the nucleus boundaries for marking potential background regions;
[0052] Then, perform an erosion operation to reduce the pixel values at the nucleus boundaries for generating a foreground region with high confidence;
[0053] Mark the region where the foreground differs from the background as the edge region for subsequent segmentation.
[0054] Optionally, let the binary image of the nucleus instance be II, where II(x1,y1) = 1 represents the target region and II(x1,y1) = 0 represents the background, and x1, y1 represent the horizontal and vertical indices of the pixels in the binary image II;
[0055] The operation of increasing the pixel values at the nucleus boundaries through dilation includes:
[0056] Define the background dilation B k1 (II):
[0057]
[0058] where K k1 is a structuring element of size k1×k1, represents the dilation operation, and k1 is the dilation kernel size;
[0059] Set each target region to be marked with an independent label l, and the background is 0;
[0060] The operation of reducing the pixel values at the nucleus boundaries through erosion includes:
[0061] Define the instance erosion F m (II):
[0062] F m (II) = II - K m
[0063] where "-" represents the erosion operation here, and K m is a structuring element of size m×m, and m is the erosion operation coefficient;
[0064] The operation of marking the region where the foreground differs from the background as the edge region includes:
[0065] Calculate the total foreground region F all (II), which is the union of all instance foregrounds:
[0066]
[0067] Mark the region where the foreground differs from the background as the edge region U k1 ;
[0068] U k1 = Bk1 (II)-F all (II).
[0069] Optionally, calculating the shortest Euclidean distance from each background region pixel to the nearest foreground region pixel and segmenting the cell image using the watershed algorithm includes:
[0070] Calculating the shortest distance D(P b (x b , y b ) to the nearest foreground region pixel P f (x f , y f ): b , P f ):
[0071]
[0072] For each background pixel P b , find all foreground pixel sets F(P b ) within its 5×5 neighborhood, and take the minimum value as the final distance d min (P b ), there is:
[0073]
[0074] If F(P b ) is empty, then d min (P b ) is set to infinity;
[0075] Define the distance map D(x a , y a ), where the value of each background pixel (x b , y b ) is equal to its distance to the nearest foreground pixel:
[0076]
[0077] where Background represents the set of background pixels and Foregound represents the set of foreground pixels;
[0078] Generate a distance map based on D(x a , y a ) to segment the cell image;
[0079] Segment the cell image using the watershed algorithm based on the labels of the foreground, background, edge region, and distance map:
[0080] Define the initial label M(x c,y c ), the foreground region label F = F all (II), the background region label B = B k1 (II), the edge region label E = U k1 , there is:
[0081]
[0082] Among them, for the pixel (x c ,y c ), the foreground region label is 1, the background region label is 2, and the edge region label is 0;
[0083] Denote the unknown region E(x e ,y e ). Each pixel (x e ,y e ) is assigned the nearest label value, then there is:
[0084]
[0085] Optionally, the result optimization of the segmentation map corresponding to each cell instance label to obtain a filtered segmentation label map includes:
[0086] Performing connectivity analysis on the instance segmentation map corresponding to each cell instance label to generate a label map L(x f ,y f ), and let lf ∈ {0, 1, 2, …, N f} represent the label of the connected region;
[0087] Define the area A of each connected region lf , and denote the area A of each connected region calculated by counting the number of pixels belonging to the label lf in the statistical label map L(x f ,y f ), and the calculation formula is: lf The area filtering condition is:
[0088]
[0089] Lf'(x
[0090]
[0091] ,y f ,y f ) is the filtered segmentation label map.
[0092] Optionally, the extraction of the outer contour of the nuclear region and the outer contour of the surrounding region of each cell from the segmentation label map and saving them to the corresponding result file includes:
[0093] Extract the outer contour of the nuclear region and the outer contour of the surrounding region of each cell from the segmentation label map based on the following formula:
[0094] Let the output label map be M'(x e ,y e ). Then, from the label map:
[0095] Extract the outer contour C nb (Ig) of the nuclear region of each cell Ig as:
[0096] C nb (Ig) = {(x g ,y g ) | (x g ,y g ) ∈ M'(x e ,y e ) = 1}
[0097] The outer contour C cb (Ig) of the surrounding region of each cell Ig is:
[0098] C cb (Ig) = {(x h ,y h ) | (x h ,y h ) ∈ M'(x e ,y e ) = 2}
[0099] Record and save the corresponding results to a JSON file.
[0100] To solve the above technical problems, the technical solution of the present invention also provides a method for stitching the cell image segmentation results, including:
[0101] Obtain input data, where the input data includes: the original slice image file and the segmentation image results after detecting cells by the method described above, and the original slice image file includes: several slice image blocks;
[0102] Horizontally stitch the image blocks in each row in sequence, while merging the overlapping region masks between the image blocks, removing redundant parts and optimizing the overlapping regions, load the image blocks in each row and record the segmentation image results of the image blocks from the specified path, check the overlapping situation of the masks in the overlapping regions, update the merged mask and remove the redundant masks;
[0103] Use the IoU metric to measure the overlapping situation between two masks and evaluate the overlapping situation of the masks based on the IoU metric;
[0104] Draw an image based on the overlapping situation of all masks to generate the stitched image of the cell image segmentation results.
[0105] Optionally, the IoU metric is used to measure the overlap between two masks, and evaluating the overlap of masks based on the IoU metric includes:
[0106] Evaluating the similarity between two mask polygons P1 and P2, the calculation formula is:
[0107]
[0108] Where: Area of Intersection represents the area of the overlapping region of the two mask polygons P1 and P2, and Area of Union represents the area of the union region of the two mask polygons P1 and P2;
[0109] For two mask polygons P1 and P2, calculate their IoU metric. If IoU ≥ threshold, delete the mask Intersection with the smaller area; if IoU < threshold, calculate the Intersection part and perform a difference set operation: threshold is a preset metric threshold;
[0110] P1' = P1 - Intersection
[0111] P2' = P2 - Intersection
[0112] Retain the non-overlapping regions on both sides.
[0113] To solve the above technical problems, the technical solution of the present invention also provides a system for detecting cells based on the DistSeg model image processing technology, including: a preprocessing module, a first segmentation module, a second segmentation module, a third segmentation module, an optimization processing module, and an extraction module;
[0114] The preprocessing module is adapted to preprocess the collected cell images;
[0115] The first segmentation module is adapted to segment the cell images based on the DistSeg model image processing technology to generate a cell nucleus region;
[0116] The second segmentation module is adapted to generate a background region, a foreground region, and an edge region by using morphological operations based on the segmented cell nucleus region;
[0117] The third segmentation module is adapted to calculate the shortest Euclidean distance from each background region pixel to the nearest foreground region pixel, and segment the cell image by using the watershed algorithm;
[0118] The optimization processing module is adapted to optimize the results of the segmentation map corresponding to each cell instance label to obtain a filtered segmentation label map;
[0119] The extraction module is adapted to extract the outer contour of the nuclear region and the outer contour of the surrounding region of each cell from the segmentation label map and save them to the corresponding result file.
[0120] To solve the above technical problems, the technical solution of the present invention also provides a system for stitching the cell image segmentation results, including: an image input module, an image stitching module, an overlapping region processing module, and a contour merging and output module;
[0121] The image input module is adapted to obtain input data, and the input data includes: an original slice image file and a JSON file recording the corresponding segmentation image results after cell detection. The original slice image file includes: several slice image blocks;
[0122] The image stitching module is adapted to horizontally stitch the image blocks in each row in sequence, and at the same time merge the overlapping region masks between the image blocks, remove redundant parts and optimize the overlapping regions, load the image blocks in each row and the corresponding segmentation image results of the image blocks from the specified path, check the overlapping situation of the masks in the overlapping regions, update the merged masks and remove redundant masks;
[0123] The overlapping region processing module is adapted to use the IoU metric to measure the overlapping situation between two masks and evaluate the overlapping situation of the masks based on the IoU metric;
[0124] The contour merging and output module is adapted to draw an image based on the overlapping situation of all masks and generate a stitched image of the cell image segmentation results.
[0125] The beneficial effects of the technical solution of the present invention at least include:
[0126] The present invention adopts the DistSeg model deep learning network. Through star-shaped geometric regression and Euclidean distance transformation, the structural information of the background region is enhanced, a more accurate basis for foreground and background separation is provided, the boundary morphology of cell detection is effectively improved, and the overall performance of cell detection and segmentation is improved.
[0127] The present invention introduces the IoU metric to judge the overlapping regions in the stitching process and combines parallel processing to effectively remove redundant parts, ensuring the integrity and accuracy of the stitched image. At the same time, the stitching speed and efficiency are improved, making the large-scale WSI image stitching more efficient and accurate. Description of the Drawings
[0128] Other features, objects, and advantages of the present invention will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0129] Figure 1 Schematic flowchart of a method for detecting cells based on the DistSeg model image processing technology provided by the technical solution of the present invention;
[0130] Figure 2 Schematic diagram of the process steps for detecting and segmenting cell nuclei in a cell image using the DistSeg model image processing technology in the method for detecting cells based on the DistSeg model image processing technology provided by the technical solution of the present invention;
[0131] Figure 3 Schematic flowchart of a method for stitching the segmentation results of a cell image provided by the technical solution of the present invention;
[0132] Figure 4 Schematic diagram of the system structure for detecting cells based on the DistSeg model image processing technology provided by the technical solution of the present invention;
[0133] Figure 5 Schematic diagram of the system structure for stitching the segmentation results of a cell image provided by the technical solution of the present invention;
[0134] Figure 6 Schematic diagram of an example of a method for detecting cells based on the DistSeg model image processing technology provided by the technical solution of the present invention;
[0135] Figure 7 Schematic diagram of an example of a method for stitching the segmentation results of a cell image provided by the technical solution of the present invention;
[0136] Figure 8 Schematic diagram for comparing the cell segmentation experimental results generated by the method for detecting cells based on the DistSeg model image processing technology provided by the technical solution of the present invention with the original image and the cell detection and processing results of the prior art respectively;
[0137] Figure 9 Schematic diagram for comparing the stitching effect of the bright-field image segmentation result with the original image after detecting and stitching cells based on the DistSeg model image processing technology in the technical solution of the present invention;
[0138] Figure 10 Schematic diagram for comparing the stitching effect of the fluorescence image segmentation result with the original image after detecting and stitching cells based on the DistSeg model image processing technology in the technical solution of the present invention. Detailed implementation manners
[0139] To better present the technical solution of the present invention clearly, the present invention will be further described below with reference to the accompanying drawings.
[0140] The DistSeg (Distance Segmentation) technology is an image segmentation technology based on deep learning. It mainly achieves precise segmentation of images by calculating the spatial distance and feature similarity between pixels, and can optimize the image processing process through a deep learning model.
[0141] Specifically, the DistSeg technology can use a convolutional neural network (CNN) to perform multi-level feature extraction and representation learning on images, so as to accurately identify and separate different objects or regions in complex images. The specific process includes: extracting image features from the image, including: through the stacking of multiple convolutional layers, the network can gradually construct complex high-level features (such as object parts, facial features, etc.) from simple low-level features (such as edges, textures, etc.); realizing parameter sharing and local receptive fields, including: the convolutional layer uses a small filter to perform a sliding window operation on the input image, only focusing on a small area in the image each time, which helps the model capture local features in the image. At the same time, the same convolutional kernel slides across the entire image and the calculations are the same, greatly reducing the number of parameters and improving the translational invariance of the network; applying a non-linear activation function to further learn feature patterns, including: the convolutional layer usually adds a non-linear activation function (such as ReLU) after the convolutional operation. This non-linear transformation enables the network to learn complex feature patterns rather than just simple linear combinations.
[0142] The DistSeg technology can achieve precise recognition and segmentation of target regions in images through a deep learning model, especially an improved version based on the U-Net architecture. For example, the DistSeg technology can capture context information in the image based on the symmetric encoder-decoder of the U-Net architecture and restore a fine segmentation result in the decoding stage. During the training process, the DistSeg technology learns how to assign pixels in the image to different categories or objects through a large amount of labeled data, so as to quickly process new images and generate segmentation results.
[0143] In an embodiment of the technical solution of the present invention, as Figure 1 shown, a method for detecting cells based on the DistSeg model image processing technology is provided, including the following steps:
[0144] S10, preprocess the collected cell images.
[0145] In step S10, the process of preprocessing the collected cell images includes: segmenting the WholeSlide Image (WSI) into image patches of size 512×512. Each sub-image contains local cell information and retains its position information in the WSI global; uploading the cell slice images to be processed to the server, and the server saves the images to a specified folder; converting the slice images to grayscale format; normalizing the grayscale images; checking whether the file size of each image is less than 5KB, and if so, deleting it.
[0146] Among them, the specific process of converting the slice images to grayscale format further includes grayscale processing for two types of images: after directly grayscaling the fluorescence images, filter out the images with weak background signals (such as the pixel ratio with gray values less than 45 is too high) according to the pixel brightness distribution, and retain the significant signal regions; for bright-field images, convert the RGB images to the HSI color model, extract and enhance the saturation component (S component) to highlight the contrast of the cell regions, and then convert the enhanced images to grayscale images for processing.
[0147] Continue to refer to Figure 1 , the method for detecting cells based on the DistSeg model image processing technology in this embodiment further includes the steps:
[0148] S11, segment the cell images based on the DistSeg model image processing technology.
[0149] The specific process of step S11 includes: loading the preprocessed cell images, and using the DistSeg model image processing technology to detect and segment the cell nuclei in the cell images.
[0150] Among them, the preprocessed cell images are the cell slice images converted to grayscale format in step S10, and the cell images after grayscale conversion are read as input.
[0151] The process of using the DistSeg model image processing technology to detect and segment the cell nuclei in the cell images, referring to Figure 2 , further includes the following sub-steps:
[0152] S100, combining the star-shaped geometric regression method, using the multi-directional distances from each pixel point to the nuclear boundary to describe the nuclear contour, and reconstructing the star-shaped geometric polygon contour of the nucleus;
[0153] S101, based on the star-shaped geometric polygon contour, calculate the object probability of each pixel point belonging to the nucleus, and the object probability is the normalized Euclidean distance from this pixel to the nearest background pixel;
[0154] S102. Set a threshold, select the pixels whose pixel object probability is greater than the threshold from all pixels, and generate corresponding polygon candidate regions and the intersection-over-union ratios between the polygon candidate regions.
[0155] S103. Use non-maximum suppression to remove overlapping candidate regions, sort the candidate regions according to the object probability, and sequentially retain the polygon candidate regions with the highest object probability and an intersection-over-union ratio less than the threshold with other candidate regions.
[0156] S104. Assign labels to the retained polygon candidate regions and generate a final nucleus segmentation map.
[0157] In sub-step S100 of this embodiment, a star-shaped geometric regression method is adopted to describe the contour of the nucleus, thereby reconstructing the star-shaped geometric polygon contour of the nucleus.
[0158] Specifically, let the pixel point in the cell image be (i, j), where i and j are natural numbers greater than zero. i takes values from 1, 2, …, I, and j takes values from 1, 2, …, J. i and j are respectively the horizontal and vertical marking serial numbers of the pixel point in the image coordinate system, and I and J are natural numbers greater than 1. Since each pixel (i, j) belongs to an object of the nucleus (such as: nucleus, cytoplasm, or cell background, etc.), the Euclidean distance is used to represent the distance from the pixel (i, j) to the boundary of this object, that is: where k is a natural number greater than zero, representing the direction angle serial number of the currently selected pixel (i, j). In this embodiment, the pixel (i, j) is equidistantly selected at the 1st, 2nd, …, nth preset direction angles to calculate the distance from the pixel at the selected direction angle to the boundary of the selected object, and n is a natural number greater than 1.
[0159] More specifically, the Euclidean distance from the pixel (i, j) to the boundary of the selected object can be determined by the following formula:
[0160]
[0161] where: θ k = n / (2πk), k = 1, 2, …, n is the selected direction angle serial number, Boundary is the boundary of the current object, and d represents the distance from the pixel point (i, j) along the selected direction (the direction represented by the angle θk) to the boundary of the target object.
[0162] Through these multi-directional distances i = 1, 2, …, I, j = 1, 2, …, J, the star-shaped geometric polygon contour of the current cell image can be reconstructed.
[0163] The Euclidean distances from each pixel (i, j) obtained in step S100 of the present embodiment to the nuclear boundary in n selected different angular directions Thereby obtaining the contours of these pixels to the nuclear boundary.
[0164] Based on the contours of the pixels to the nuclear boundary, in this embodiment, the object probability that the pixel (i, j) belongs to the nucleus is further calculated through step S101. The object probability refers to the distance from each foreground pixel (usually represented as white or 255) to the nearest background pixel (usually represented as black or 0) in a binary image, and this distance is a normalized Euclidean distance.
[0165] More specifically, according to the setting of this embodiment, to determine whether the pixel (i, j) belongs to a selected object (such as a nucleus), let the object probability of the pixel (i, j) be d i,j , then there is:
[0166]
[0167] Among them, Distance((i, j), Background) represents the normalized distance from each pixel (i, j) to the nearest background pixel Background, and MaxDistance represents the maximum value among all calculated normalized distances. The Distance((i, j), Background) function can specifically use the distanceTransform function in image processing libraries such as OpenCV to calculate the distance from each pixel (i, j) to the nearest background pixel. Different distance metrics can be used as this function, such as Euclidean distance, Manhattan distance, or Chebyshev distance. Usually, the Euclidean distance is used.
[0168] Since the object probability d of the pixel (i, j) i,j is the normalized Euclidean distance from this pixel to the nearest background pixel, the pixels close to the center of the nucleus in the image have a higher object probability, while the probability of background pixels is 0.
[0169] In the prior art, there are problems in cell images such as nuclear overlap, clustering, and being close to each other, which increase the difficulty of segmentation. In this embodiment, based on the object probability that the pixels obtained in step S101 belong to the nucleus, non-maximum suppression can be used to remove overlapping candidate regions, thereby retaining subsequent regions with high object probability.
[0170] Therefore, based on step S100 of the present embodiment, the multi-directional distances from each pixel point (i, j) to the nuclear boundary can be utilized And based on step S100 of the present embodiment, the object probability d that each pixel point (i, j) belongs to the nucleus can be calculated i,j, where \(i\) takes values from 1, 2, …, \(I\), and \(j\) takes values from 1, 2, …, \(J\).
[0171] Continue to refer to Figure 3 , according to step S102 of this embodiment, among all pixels \((i, j)\) (\(i\) can take values from 1, 2, …, \(I\), and \(j\) can take values from 1, 2, …, \(J\)), pixels with object probability greater than the threshold \(\tau\) d can be selected, and the selected pixels are defined as pixels \((i', j')\). \(i'\) is the abscissa serial number of the pixel with object probability greater than the threshold among 1, 2, …, \(I\). Let \(i'\) be \(i_1\), \(i_2\), …, \(i\) x ; \(i_1\), \(i_2\), …, \(i\) x are successively the abscissa serial numbers of the pixels with object probability greater than the threshold among 1, 2, …, \(I\), \(x\) is a natural number greater than 1; \(j'\) is the ordinate serial number of the pixel with object probability greater than the threshold among 1, 2, …, \(J\). Let \(j'\) be \(j_1\), \(j_2\), …, \(j\) y ; \(j_1\), \(j_2\), …, \(j\) y are successively the ordinate serial numbers of the pixels with object probability greater than the threshold among 1, 2, …, \(J\), \(y\) is a natural number greater than 1.
[0172] Based on the selected pixels \((i', j')\), the multi-directional distances from the selected pixels \((i', j')\) to the nucleus boundary can be obtained
[0173] Based on the multi-directional distances from these pixels \((i', j')\) with object probability greater than the threshold to the nucleus boundary a polygon candidate region \(A\) of the nucleus can be reconstructed i’,j’ , where \(i' = i_1\), \(i_2\), …, \(i\) x , \(j' = j_1\), \(j_2\), …, \(j\) y . In this embodiment, the threshold setting can be taken as 0.5.
[0174] It should be noted that in this embodiment, the polygon candidate region \(A\) i’,j’ is constructed by calculating the multi-directional distances of pixel points \((i, j)\) and connecting the boundary points. For each pixel point \((i, j)\), in the image coordinate system, the distances to the nucleus boundary are calculated along multiple directions. Using the multi-directional distances the positions of the pixel point \((i, j)\) and the boundary points in each direction \(\theta\) k can be mapped. In the order of direction \(\theta\) k , these boundary points are successively connected to form a closed polygon region \(A\) i’,j’ , thus obtaining the polygon candidate region.
[0175] More specifically, taking the threshold setting as 0.5 in this embodiment as an example:
[0176] Definable polygon candidate region A i’,j’ (where i’ = i1, i2, …, i x , and j’ = j1, j2, …, j y ) the Intersection over Union (IoU) between each pair, that is:
[0177]
[0178] f, g, u, v represent pixel values. When the value of the selected pixel (f, g) is determined, the pixel (u, v) is the pixel value other than the pixel (f, g). A f,g represents the polygon region constructed by the multi-directional distance calculation and boundary point connection through the pixel (f, g) (refer to the construction method of the polygon candidate region A i’,j’ ), and A u,v represents the polygon region constructed by the multi-directional distance calculation and boundary point connection through the pixel (u, v) (similarly refer to the construction method of the polygon candidate region A i’,j’ ).
[0179] According to step S103 of this embodiment, non-maximum suppression (NMS) is further used to remove overlapping candidate regions A i’,j’ .
[0180] Non-maximum suppression is a commonly used post-processing technique in object detection, aiming to eliminate redundant bounding boxes and only retain the best detection results. Its basic idea is that in the same local area, if a window is better than all other windows, only this window is retained, and other less optimal windows are suppressed. After S100 to S102 of this embodiment, polygon candidate regions for pixels (i’, j’) are generated, and these polygon candidate regions can be screened and suppressed according to a set threshold.
[0181] Common non-maximum suppression algorithms in the prior art include Soft-NMS, Adaptive NMS, and DIoU-NMS, etc. Each method has its unique advantages and applicable scenarios. For example, Soft-NMS reduces false negatives by reducing the confidence of the overlapping region, while DIoU-NMS uses the Intersection over Union (IoU) as a measurement standard, improving the stability and accuracy of detection.
[0182] In step S103 of this embodiment, the polygon candidate region A i’,j’ (where i’ = i1, i2, …, i x , and j’ = j1, j2, …, j y) The intersection over union (IoU) between each pair is used as a measurement criterion, and further, pixels (i’, j’) with an object probability greater than the threshold are selected, and polygon candidate regions with an IoU less than the threshold when intersecting with other candidate regions are retained.
[0183] Specifically, in step S103:
[0184] First, non-maximum suppression is used to remove overlapping candidate regions in candidate region A i’,j’ to obtain A i0,j0 , where i0 is defined as the abscissa serial number of the corresponding pixel of the subsequent region obtained after removing the overlapping candidate regions in the image coordinate system, j0 is defined as the ordinate serial number of the corresponding pixel of the subsequent region obtained after removing the overlapping candidate regions in the image coordinate system, let i0 be i 10 , i 20 , …, i x0 ; i 10 , i 20 , …, i x0 are successively the abscissa serial numbers of the corresponding pixels of the subsequent region obtained after removing the overlapping candidate regions in i1, i2, …, i x , x0 is a natural number greater than 1; let j0 be j 10 , j 20 , …, j y0 ; j 10 , j 20 , …, j y0 are successively the ordinate serial numbers of the corresponding pixels of the subsequent region obtained after removing the overlapping candidate regions in j1, j2, …, j y , y0 is a natural number greater than 1.
[0185] Secondly, the candidate regions A i0,j0 are sorted according to the object probability d i0,j0 of the pixel (i0, j0), and the d i0,j0 (i0 ∈ {i 10 , i 20 , …, i x0}}, j0 ∈ {j 10 , j 20 , …, j y0}) with the highest object probability is retained successively, and the candidate region A ix,jy is selected, and the IoU ix,jy between A ix,jy and other candidate regions A ix’,jy’ is calculated ix’,jy’ (ix’ represents the serial number other than ix selected from {i 10 , i 20 , …, i x0}}, jy’ represents the serial number selected from {j 10 , j20 …, j y0} except jy) less than the threshold, where ix and jy are the horizontal and vertical sequence numbers of the pixel corresponding to the highest object probability in the image coordinate system for d i0,j0 (i0 ∈ {i 10 , i 20 , …, i x0}, j0 ∈ {j 10 , j 20 , …, j y0}) in the image coordinate system.
[0186] Let the selected polygon candidate region be A in,jn , where in = i 1n , i2 n , …, i x n , jn = j 1n , j2 n , …, j y n , the polygon candidate region A in,jn is the candidate region A ix,jy with an intersection over union (IoU) less than the threshold with other candidate regions A ix’,jy’ in the set of candidate regions, where i ix’,jy’ , i2 1n , …, i n x n n are the horizontal sequence numbers of the pixels corresponding to these polygon candidate regions, and j 1n , j2 n , …, j y n are the vertical sequence numbers of the pixels corresponding to these polygon candidate regions.
[0187] The resulting polygon candidate region is A in,jn , in = i 1n , i2 n , …, i x n , jn = j 1n , j2 n , …, j y n , that is, only the nuclei contours with high confidence are retained.
[0188] According to step S104, each retained polygon candidate region A in,jn is assigned a unique label to generate the final instance segmentation map, ensuring that each cell is labeled as an independent instance:
[0189]
[0190] Among them, I(iz, jz) represents the finally generated segmentation map, where iz and jz represent the horizontal and vertical pixel numbers of the generated segmentation map, and P(iz, jz) represents the label assigned to the corresponding pixel. If a certain pixel (iz, jz) belongs to the assigned label P(iz, jz), then this pixel is used to generate the corresponding segmentation map I(iz, jz).
[0191] It should be noted that in this embodiment, l k represents the unique label assigned to a certain reserved polygon candidate region A in,jn and is a marker used to identify each independent cell nucleus region during the instance segmentation process. The label l k is an identifier (for example, it can take integer values 1, 2, 3,...) used to distinguish different cell nucleus regions. Each label l k is unique. Therefore, different cell nucleus instances will not share the same label in the segmentation map, ensuring that each cell nucleus in the instance segmentation map is independently marked.
[0192] According to the above steps S100 to S104 of this embodiment, it can be considered that if the pixel (iz, jz) satisfies iz ∈ {i 1n , i2 n , …, i x n} and jz ∈ {j 1n , j2 n , …, j y n}, then these pixels are used to generate the final cell nucleus segmentation map.
[0193] Continuing to refer to Figure 1 , the method for detecting cells based on the DistSeg model image processing technology in this embodiment further includes the steps of:
[0194] S12. Based on the segmented cell nucleus regions, morphological operations are used to generate background regions, foreground regions, and edge regions.
[0195] In step S12, the process of the morphological operation is specifically as follows:
[0196] First, the dilation operation is used to increase the cell nucleus boundary pixels to mark potential background regions. Using the binary map of the cell nucleus instance as II, where it is set that II(x1, y1) = 1 represents the target region and II(x1, y1) = 0 represents the background, and x1, y1 represent the horizontal and vertical numbers of the pixels in the binary map II. Then, the background dilation B k1 (II):
[0197]
[0198] where Kk1 is a structuring element of size k1×k1, denotes the dilation operation. When k1 is set to 3, it is a small-scale dilation for adjacent cell boundary detection; when k1 is set to 5, it is a large-scale dilation for cell cluster segmentation. k1 is the range dilation coefficient for adjacent cell boundary detection.
[0199] Then, the erosion operation is used to reduce the nucleus boundary pixels for generating a foreground region with high confidence. Using the given instance graph II of nucleus segmentation, where each target region is labeled with an independent label l and the background is 0. Define the instance erosion F m (II):
[0200] F m (II) = II - K m
[0201] where "-" represents the erosion operation here, and K m is a structuring element of size m×m, and m is set to 2. The total foreground region F all (II) is the union of all instance foregrounds:
[0202]
[0203] The region with the difference between the foreground and the background is marked as the edge region U k1 , which is used for subsequent segmentation.
[0204] U k1 = B k1 (II) - F all (II)
[0205] where k1 is the dilation kernel size.
[0206] Continuing to refer to Figure 1 , the method for detecting cells based on the DistSeg model image processing technology in this embodiment further includes the step of:
[0207] S13, calculating the shortest Euclidean distance from each background region pixel to the nearest foreground region pixel, and segmenting the cell image using the watershed algorithm.
[0208] In step S13, the shortest distance from each background region pixel to the nearest foreground region pixel is calculated using the Euclidean Distance. The Euclidean distance is a way to calculate the straight-line distance between two points and is commonly used for calculating the distance between points in space. For a background pixel P b (x b , y b ) and P f (x f , yf ), and the calculation formula of its Euclidean distance is:
[0209]
[0210] Therefore, for each background pixel P b , find all foreground pixel sets F(P b ) within its 5×5 neighborhood, take the minimum value as the final distance, and generate a distance map.
[0211] The closest distance d min has the following calculation formula:
[0212]
[0213] If F(P b ) is empty, then d min (P b ) is set to infinity.
[0214] Define the distance map D(x a , y a ), where the value of each background pixel (x b , y b ) is equal to its distance to the closest foreground pixel:
[0215]
[0216] where Background represents the set of background pixels and Foregound represents the set of foreground pixels.
[0217] Generate the labels of the foreground, background, edge region, and distance map through the above steps.
[0218] In step S13, the specific process of segmenting the cell image using the watershed algorithm includes:
[0219] Use the labels of the foreground, background, edge region, and distance gradient map for cell segmentation. Regard the image as a topographic map, simulate the flow of water starting from the labeled foreground and background regions, expand along the path of the "water flow", form a dividing line between the "foreground" and the "background", and finally generate the segmented regions to achieve the refinement of the cell boundary and assign the pixels in the unknown edge region to the foreground or background.
[0220] Among them, in the definition of the input data, the foreground region label (F = F all (II)): a binary image, where the foreground region is labeled with a non-zero value and the background is labeled with 0. The background region label (B = B k1 (II)): a binary image, where the background region is labeled with a non-zero value and the foreground is labeled with 0. The edge region (E = Uk1 ):Subtract the foreground from the inflated background, defined as the unknown pixel area. The distance gradient map (G = D(x a , y a )): Defined as the shortest Euclidean distance map from background pixels to foreground pixels.
[0221] Define the initial marker M(x c , y c ), where (x c , y c ) are the horizontal and vertical coordinates of the pixel, and integrate the foreground and background regions:
[0222]
[0223] The foreground region is marked as 1, the background region is marked as 2, and the edge region is marked as 0 (unknown region).
[0224] In this embodiment, the specific process of watershed segmentation is as follows:
[0225] Regard the distance gradient map G(x d , y d ) = D(x a , y a ) as the terrain height map, where the gradient value represents the "height" of the pixel: H(x d , y d ) = G(x d , y d ). Start simulating the expansion of water flow along the path with the lowest gradient from the marked foreground and background regions. Define the expansion condition of the water flow as for each pixel (x d , y d ) and its neighborhood N(x d ’, y d ’), find the neighborhood that satisfies the following condition:
[0226] H(x d ’, y d ) < H(x d , y d )
[0227] where N(x d ’, y d ’) is the neighborhood function of the pixel (x d , y d ), that is, in the watershed algorithm, it is used to define the neighborhood range of the current pixel. N is used to represent the set of neighborhood pixels of a pixel during the watershed expansion process, and is used to judge the condition of water flow expansion. When the water flow meets from different marked regions (such as the foreground and the background), a dividing line is formed, and the pixel is assigned to the nearest marked region.
[0228] Unknown region E(x e ,y e ) of each pixel (x e ,y e ) is assigned the nearest label value (foreground or background):
[0229]
[0230] The output of the watershed algorithm is the labeled map M'(x e ,y e ), indicating the attribution of each pixel (x e ,y e ). The dividing line represents the refinement of the cell boundary through the boundary pixels of the labeled regions.
[0231] Continue to refer to Figure 1 . The method for detecting cells based on the DistSeg model image processing technology in this embodiment further includes the steps:
[0232] S14. Optimize the result of the segmentation map corresponding to each cell instance label to obtain a filtered segmentation label map.
[0233] In step S14, the specific process of optimizing the result of the segmentation map corresponding to the cell instance label includes the following:
[0234] Perform connectivity analysis on the instance segmentation map corresponding to each cell instance label to generate a labeled map L(x f1 ,y f1 ). Let lf ∈ {0, 1, 2,..., N f}, where lf represents the label of the connected region and lf is a natural number greater than zero.
[0235] Define the area A lf of each connected region. The area A f1 ,y f1 of each connected region is calculated by counting the number of pixels belonging to the label lf in the labeled map L(x lf ). The calculation formula is:
[0236]
[0237] Define the upper area threshold A max as 600 to filter out overly large regions. The area filtering condition is:
[0238]
[0239] Lf'(x f1 ,y f1 ) is the filtered segmentation label map. Through the operations in step S14, it can be avoided that multiple cell nuclei are misidentified as one.
[0240] In the processes of steps S13 and S14, (x a , y a ), (x b , y b ), (x c , y c ), (x d , y d ), (x e , y e ), (x f , y f ), (x f1 , y f1 ) respectively represent the pixel values input based on the corresponding specific algorithm under the algorithm, and are successively the x - coordinate value and y - coordinate value of the pixel point in the image coordinate system. (x d ’, y d ) is the neighborhood pixel of (x d , y d ).
[0241] Continuing to refer to Figure 1 , the method for detecting cells based on the DistSeg model image - processing technology in this embodiment further includes the steps:
[0242] S15, Extract the outer contour of the nuclear region and the outer contour of the surrounding region of each cell from the segmentation label map, and save them to the corresponding result file.
[0243] Specifically, in step S15,
[0244] The outer contour of the nuclear region and the outer contour of the surrounding region of each cell can be extracted from the segmentation label map based on the following formula:
[0245] Let the output label map be M'(x e , y e ), then from the label map:
[0246] Extract the outer contour C nb (Ig) of the nuclear region of each cell Ig as:
[0247] C nb (Ig) = {(x g , y g )|(x g , y g ) ∈ M'(x e , y e ) = 1}
[0248] The outer contour C cb (Ig) of the surrounding region of each cell Ig is:
[0249] C cb (Ig) = {(x h , y h ) | (x h , y h ) ∈ M'(x e , y e ) = 2}
[0250] Record and save the corresponding results to a JSON file. In step S15: (x g , y g ) represents the pixel values of the nuclear region contour image of each cell Ig, which are successively the x - coordinate value and the y - coordinate value of the pixel points of the nuclear region contour image in the image coordinate system; (x h , y h ) represents the pixel values of the outer contour image of the surrounding region of each cell Ig, which are successively the x - coordinate value and the y - coordinate value of the pixel points of the outer contour image of the cell surrounding region in the image coordinate system.
[0251] The JSON file contains the unique identifier of each cell inst, incrementing from 1, the set x of the x - coordinates of the nuclear region contour points x e , the set y of the y - coordinates of the nuclear region contour points y e , the set x of the x - coordinates of the surrounding region contour points x h , and the set y of the y - coordinates of the surrounding region contour points y h , for subsequent analysis.
[0252] It should be noted that the method for detecting cells based on the DistSeg model image - processing technology in this embodiment can further use a multiprocessing pool (multiprocessing.Pool) to concurrently execute the DistSeg model image - processing technology for the segmentation tasks of the above steps. Each process processes different images to improve the computing efficiency. While executing the above steps, the time consumption of each step can be statistically analyzed and logged, which is convenient for performance monitoring and optimization.
[0253] Based on the method for detecting cells based on the DistSeg model image - processing technology of this embodiment, the cell image segmentation results can finally be obtained, that is, including: the outer contour of the nuclear region and the outer contour of the surrounding region C nb (Ig) of each cell Ig, and the outer contour C cb (Ig) of the surrounding region of each cell Ig, and further record and save the corresponding results of the inner and outer contours C nb (Ig) of the cell nucleus and the contour C cb (Ig) of the cell surrounding region to a JSON file.
[0254] An embodiment of the technical solution of the present invention also provides a method for stitching the segmentation results of cell images as follows: Figure 3 As shown in the figure, the method includes the following steps:
[0255] Step S20, obtain input data, where the input data includes: an original slice image file and a JSON file recording the corresponding segmentation image results after cell detection, and the original slice image file includes: a plurality of slice image blocks.
[0256] Among them, the input data includes an original slice image file cut from a Whole Slide Imaging (WSI) image and a JSON file of the corresponding segmentation image information after cell detection. The original slice is a small tile cropped from a whole slide image (Whole Slide Image, WSI) taken by a microscope. The file format is {r}-{c}-{num}.png, and each file name represents its position in the whole slice, where r represents the row index (Row Index), c represents the column index (Column Index), and num represents the tile number. The file storage path is specified by the variable imgs_dir_path. The Json file is the segmentation result of each image block, with the file format of *.json, and each file name is the same as the name of its corresponding image file, only the extension is different. The file storage path is specified by the variable json_dir_path. Each JSON file contains the segmentation results of one or more cells, and only the x_cb and y_cb data are used in this task.
[0257] Continuing to refer to Figure 3 , the method for stitching the segmentation results of cell images in this embodiment further includes:
[0258] Step S21, horizontally stitch the image blocks in each row in sequence, while merging the overlapping region masks between the image blocks, removing redundant parts and optimizing the overlapping regions, load the image blocks in each row and the segmentation image results of the image blocks from the specified path, check the overlapping situation of the masks in the overlapping regions, update the merged mask and remove the redundant masks.
[0259] It should be noted that in this embodiment:
[0260] The segmentation result of each image block is the segmentation map of cell instances within the block region, that is, it contains the instance label (l k ) of each pixel. The segmentation result is usually saved in the form of an image, and the pixel value corresponds to the unique identifier of the cell instance or the background label. The overlapping region mask refers to the pixel region shared between two adjacent image blocks. This region may contain segmentation results from both blocks and needs to be optimized.
[0261] The mask records the instance label of each pixel in the segmentation result. If the instance labels segmented from different image blocks in the overlapping area conflict, trade-offs and optimizations are required.
[0262] Load the original image and its corresponding segmentation result for each image block from the specified path.
[0263] The segmentation result provides an instance label for each pixel, which provides a basis for subsequent mask merging. For adjacent image blocks, determine the range of their horizontal overlapping areas. In the overlapping area, generate a mask for each pixel. The mask contains the following information: Instance label: records the segmentation result label of each pixel (l k ); Source tag: records whether the pixel comes from block (A) or block (B); Check for conflicts: In overlapping areas, it may happen that two image blocks assign different labels to the same pixel (l k ), a conflict occurs; a label is assigned in one image block, and a label is not assigned in the other image block. If the segmentation result of a pixel only exists in one block, the result is directly retained. If the segmentation result of the pixel exists in both blocks: a trade-off is made based on the iou threshold comparison process
[0264] The concatenated mask is a global segmentation result map, where the label of each pixel represents its instance segmentation affiliation. Overlapping areas are optimized and conflict-processed to ensure that there are no redundant labels.
[0265] Specifically, in step S21, the image blocks of each row can be horizontally spliced in order, and the overlapping area masks between the images are merged at the same time to remove the redundant parts and optimize the overlapping area. The image blocks of each row and their masks (JSON files) are loaded from the specified path. The overlapping area of each two adjacent image blocks is determined (the width overlap is 256). In the overlapping area, the mask is checked for intersection according to the intersection-overlap ratio of the overlapping area. If the ratio is greater than the set threshold value of 0.05, the larger mask is retained and the smaller mask is removed.
[0266] The updated mask is merged into the final result, and the processed image blocks are stitched into a whole row in order. The row images that have been stitched horizontally are stitched vertically in order to form a complete large image, and the vertical overlap area masks between rows are merged. The vertical overlap area between every two rows is determined (the height overlap is 256). Similarly, the masks are checked for intersection in the overlapping area, and the merged masks are updated and the redundant masks are removed.
[0267] Continue to refer Figure 3 The method for splicing the cell image segmentation results in this embodiment also includes:
[0268] Step S22: Use the IoU metric to measure the overlap between two masks and evaluate the mask overlap based on the IoU metric.
[0269] According to Step S22, the Intersection over Union (IoU) metric can be used to measure the overlap between two masks. IoU (Intersection over Union) is used to evaluate the similarity between two mask polygons, and the calculation formula is:
[0270]
[0271] Where: Area of Intersection represents the area of the overlapping region of the two mask polygons, and Area of Union represents the area of the union region of the two mask polygons. For two mask polygons P1 and P2, calculate their IoU metric. Here, the threshold is set to 0.05. If IoU ≥ threshold, then delete the mask Intersection with the smaller area. If IoU < threshold, calculate the Intersection part and perform the difference operation:
[0272] P1' = P1 - Intersection
[0273] P2' = P2 - Intersection
[0274] Retain the non-overlapping regions on both sides. By introducing the IoU metric, the overlap of the masks can be evaluated more precisely, enhancing the reliability and accuracy of mask processing during the stitching process.
[0275] Continue to refer to Figure 3 , the method for stitching the cell image segmentation results in this embodiment further includes:
[0276] Step S23: Draw an image based on the overlap of all masks to generate a stitched image of the cell image segmentation result.
[0277] In the final stitched image, all mask information is unified and integrated, and drawn on the image to generate an output image containing the complete content and the segmentation contours of each target area. Multiple mask point sets are integrated into one image, ensuring that the masks do not overlap with each other while maintaining the consistency of spatial positions. The stitched complete image is final_img, and the merged mask point set is merged_masks, with the format {mask_id:[(x1,y1),(x2,y2),...]}. Traverse the masks in merged_masks and use the cv2.circle method to draw the points on the image. The drawing color is set to red (0,0,255). Save the drawn image final_img_with_masks as a file for subsequent display and analysis.
[0278] Based on the above embodiments, the technical solution of the present invention further provides a system for detecting cells based on the image processing technology of the DistSeg model as Figure 4 shown, including: a preprocessing module, a first segmentation module, a second segmentation module, a third segmentation module, an optimization processing module, and an extraction module, where: the preprocessing module is adapted to execute step S10, that is, preprocess the collected cell image; the first segmentation module is adapted to execute step S11, that is, segment the cell image based on the image processing technology of the DistSeg model to generate a cell nucleus region; the second segmentation module is adapted to execute step S12, that is, based on the segmented cell nucleus region, use morphological operations to generate a background region, a foreground region, and an edge region; the third segmentation module is adapted to execute step S13, that is, calculate the shortest Euclidean distance from each background region pixel to the nearest foreground region pixel, and use the watershed algorithm to segment the cell image; the optimization processing module is adapted to execute step S14, that is, optimize the result of the segmentation map corresponding to each cell instance label to obtain a filtered segmentation label map; the extraction module is adapted to execute step S15, that is, extract the outer contour of the intranuclear region and the outer contour of the surrounding region of each cell from the segmentation label map and save them to the corresponding result file.
[0279] Based on the above embodiments, the technical solution of the present invention further provides a system for detecting cells based on the image processing technology of the DistSeg model as Figure 5The system for stitching the cell image segmentation results shown in the figure includes: an image input module, an image stitching module, an overlapping area processing module, and a contour merging and output module. Among them: the image input module is adapted to execute step S20, that is, to obtain input data, and the input data includes: an original slice image file and a JSON file recording the corresponding segmentation image results after cell detection, and the original slice image file includes: several slice image blocks; the image stitching module is adapted to execute step S21, that is, to horizontally stitch the image blocks in each row in sequence, and at the same time merge the overlapping area masks between the image blocks, remove redundant parts and optimize the overlapping area, load the image blocks in each row and the segmentation image results of the image blocks from the specified path, check the overlapping situation of the masks in the overlapping area, update the merged mask and remove the redundant mask; the overlapping area processing module is adapted to execute step S22, that is, to use the IoU index to measure the overlapping situation between two masks, and evaluate the overlapping situation of the masks based on the IoU index; the contour merging and output module is adapted to execute step S23, that is, to draw an image based on the overlapping situation of all masks, and generate a stitched image of the cell image segmentation results.
[0280] For the specific execution process of the above system, reference can be made to the content recorded in the above embodiments of the technical solution of the present invention, which will not be elaborated here.
[0281] Based on the method for detecting cells using the DistSeg model image processing technology provided in this embodiment, the technical solution of the present invention provides an application example as shown in Figure 6 the figure.
[0282] In this application example, the method for detecting cells using the DistSeg model image processing technology includes the following execution steps:
[0283] First, collect and preprocess the WSI image.
[0284] The specific process of image processing is as follows:
[0285] I. Perform sliding window segmentation on the whole slide image (WSI) image, cut it into image blocks with a size of 512×512, with 256 pixels of overlap between each sub-image, and retain its position information in the WSI global.
[0286] II. Upload the cell slice image to be processed to the specified folder.
[0287] III. Convert the sliced images into grayscale format. After directly grayscaling the fluorescence images, filter out the images with weak background signals (such as those with a too high proportion of pixels with grayscale values less than 45) according to the pixel brightness distribution, and retain the regions with significant signals; for bright-field images, convert the RGB images to the HSI color model, extract and enhance the saturation component (S component) to highlight the contrast of the cell regions, and then convert the enhanced images to grayscale images for processing.
[0288] IV. Normalize the grayscale images.
[0289] V. Delete the images with file sizes less than 5 KB.
[0290] Secondly, perform cell segmentation based on the cell detection method of the DistSeg model.
[0291] The cell segmentation process of the DistSeg model is specifically as follows:
[0292] I. Load the images and the model, read the images after grayscale conversion as the input; load the DistSeg model to avoid repeated model loading for each processing process.
[0293] II. Use the DistSeg model to detect and segment the cell nuclei. Combine the star-shaped geometric regression method, use the multi-directional distances from each pixel point to the cell nucleus boundary to describe the contour of the cell nucleus, and use non-maximum suppression to remove the overlapping candidate regions, only retain the cell nucleus contours with high confidence. The output result is the instance segmentation map of each cell, ensuring that each cell is labeled as an independent instance.
[0294] Then, perform background and foreground segmentation on the cell images based on morphological operations.
[0295] The process of background and foreground segmentation based on morphological operations is specifically as follows:
[0296] I. Generate foreground, background, and edge regions using morphological operations. The dilation operation increases the pixels at the cell nucleus boundary to mark potential background regions; the erosion operation reduces the pixels at the cell nucleus boundary to generate foreground regions with high confidence; the regions with differences between the foreground and the background are marked as edge regions for subsequent segmentation.
[0297] II. Calculate the shortest distance from each pixel in the background region to the nearest foreground pixel. Search for all foreground pixels within the 5×5 neighborhood around each background pixel, calculate the Euclidean distance, and take the minimum value as the final distance to generate a distance map.
[0298] Specifically, the Euclidean Distance is a way to calculate the straight-line distance between two points and is commonly used for calculating the distance between points in space. For two points P1(x1, y1) and P2(x2, y2) in a two-dimensional space, the calculation formula for their Euclidean distance is:
[0299]
[0300] III. Perform cell segmentation using the markings of the foreground, background, edge regions, and distance gradient map. Consider the image as a topographic map, simulate the flow like water starting from the marked foreground and background regions, and expand along the path of the "flow" to form a dividing line between the "foreground" and the "background", ultimately generating the segmented regions to achieve the refinement of the cell boundaries and assign the pixels in the unknown edge regions to the foreground or the background.
[0301] Then, optimize and save the segmentation results of the cell images.
[0302] The process of result optimization and saving is specifically as follows:
[0303] Perform connectivity analysis on the instance segmentation map, filter out regions with too large an area to avoid misidentifying multiple cell nuclei as one. Record the point sets of each cell contour, including the coordinates of the regions inside and around the nucleus. Save the results to a JSON file, recording the segmentation detail information of each cell for subsequent analysis.
[0304] Finally, perform batch processing and performance optimization on the input cell images.
[0305] The process of batch processing and optimization is specifically as follows:
[0306] Use the multiprocessing.Pool to concurrently execute the DistSeg segmentation tasks, with each process handling different images to improve the calculation efficiency.
[0307] Based on the method for stitching the segmentation results of cell images provided in this embodiment, the technical solution of the present invention provides an Figure 7 application example as shown.
[0308] Combined with Figure 7 , in the application example of the method for stitching the segmentation results of cell images, the image input module, image stitching module, overlapping region processing module, and contour merging and output module of the system are used. Among them:
[0309] The image input module receives the original slice image file cut from the Whole Slide Imaging (WSI) image and the JSON file of the corresponding segmentation image information after cell detection. The image stitching module first performs horizontal stitching on the images and the position files of the corresponding segmentation information in each row received by the image input module, and the stitched images are input into the overlapping region processing module to process the overlapping regions between the images. For each overlapping region, the Intersection over Union (IoU) metric is used to measure the overlap between the two masks, and the masks are merged to remove redundant parts.
[0310] In image processing and mask merging, IoU measures the ratio of the area of intersection of two regions (usually masks or bounding boxes) to the area of their union. The specific calculation formula is as follows:
[0311]
[0312] If the proportion of the overlapping area of the two masks in the area of the smaller mask exceeds the threshold, the smaller mask is deleted; otherwise, the difference set operation is performed on the overlapping part, and the non-overlapping regions on both sides are retained. Then the horizontally stitched rows are vertically stitched into the final large image. After stitching, it enters the processing completed contour merging and output module, and the segmentation contours in the final image are merged and drawn on the image to generate the final image containing the content of the stitched image and the mask of each target region.
[0313] In the above embodiments and application examples of the technical solution of the present invention, the DistSeg model deep learning network is adopted. Through star-shaped geometric regression and Euclidean distance transformation, the structural information of the background region is enhanced, providing a more accurate basis for foreground and background separation, effectively improving the boundary morphology of cell detection, and improving the overall performance of cell detection and segmentation.
[0314] Combined with Figure 8 , the comparison display of the cell segmentation experimental results generated by the method of cell detection based on the DistSeg model image processing technology with the original image and the cell detection processing results of the prior art can be obtained. It can be seen that the present invention has a more obvious boundary morphology after cell detection, segmentation and stitching based on the DistSeg model image processing technology, effectively improving the overall performance of cell detection and segmentation.
[0315] On the other hand of the technical solution of the present invention, by introducing the IoU metric to judge the overlapping regions in the stitching process and combining parallel processing, redundant parts are effectively removed, ensuring the integrity and accuracy of the stitched image, while improving the stitching speed and efficiency, making the large-scale WSI image stitching more efficient and accurate.
[0316] Figure 9 andFigure 10 It shows the comparison diagrams of the stitching effect of the bright-field image segmentation result and the original image, as well as the comparison diagrams of the fluorescence image segmentation result and the original image after the cell detection and stitching based on the DistSeg model image processing technology in the technical solution of the present invention. It can be seen that the technical solution of the present invention can achieve the integrity and accuracy of the stitched image, and effectively improve the stitching efficiency and accuracy of large-scale WSI images.
[0317] The specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various deformations or modifications within the scope of the claims, which do not affect the essence of the present invention.
Claims
1. A method for detecting cells based on DistSeg model image processing technology, characterized in that: include: Preprocessing the collected cell images; The cell images are segmented based on the DistSeg model image processing technology to generate the cell nucleus region; Based on the segmented cell nucleus region, morphological operations are used to generate background region, foreground region and edge region; Calculating the shortest Euclidean distance from each background area pixel to the nearest foreground area pixel, and segmenting the cell image using a watershed algorithm; Optimize the segmentation map corresponding to each cell instance label to obtain a filtered segmentation label map; The outer contour of the nuclear region and the outer contour of the surrounding region of each cell are extracted from the segmentation mark map and saved in the corresponding result file.
2. The method for detecting cells based on the DistSeg model image processing technology according to claim 1, characterized in that: The preprocessing of the collected cell images comprises: Segmenting the collected cell image into a plurality of block images, wherein the block images contain local cell information and retain position information of the block images in the global collected cell image; The block image is converted into a grayscale format.
3. The method for detecting cells based on DistSeg model image processing technology as claimed in claim 2, characterized in that: The block images include: a fluorescent image and a bright field image; and converting the block images into a grayscale format includes: After the fluorescent image is directly grayed, the image with weak background signal is filtered out according to the pixel brightness distribution, and the signal significant area is retained; The bright field image is processed by converting the RGB image into an HSI color model, extracting and enhancing the saturation component to highlight the contrast of the cell area, and then converting the enhanced image into a grayscale image.
4. The method for detecting cells based on DistSeg model image processing technology as claimed in claim 1, characterized in that: The segmentation of cell images based on the DistSeg model image processing technology includes: Load the preprocessed cell image as input; Combined with the star geometry regression method, the outline of the cell nucleus is described by using the multi-directional distance from each pixel point to the cell nucleus boundary to reconstruct the star geometry polygon outline of the cell nucleus; Based on the star-shaped geometric polygon outline, calculating the object probability that each pixel belongs to the cell nucleus, the object probability being the normalized Euclidean distance from the pixel to the nearest background pixel; A threshold is set, pixels whose pixel object probability is greater than the threshold are selected from all pixels, and the corresponding polygon candidate regions and the intersection-and-union ratio between the polygon candidate regions are generated; Using non-maximum suppression to remove overlapping candidate regions, sorting the candidate regions according to object probability, and sequentially retaining polygonal candidate regions with the highest object probability and whose intersection-over-union ratio with other candidate regions is less than the threshold; Labels are assigned to the retained polygonal candidate regions, and the final cell nucleus segmentation region is generated.
5. The method for detecting cells based on DistSeg model image processing technology as claimed in claim 2, characterized in that: Assume that the pixel point in the cell image is (i, j), where i and j are natural numbers greater than zero, i=1, 2, ..., I, j=1, 2, ..., J, i and j are the horizontal and vertical marking numbers of the pixel point in the image coordinate system respectively; I, J are natural numbers greater than 1; The step of describing the outline of the cell nucleus by using the multi-directional distance from each pixel point to the cell nucleus boundary to reconstruct the star-shaped geometric polygonal outline of the cell nucleus comprises: The Euclidean distance is used to represent the boundary of the cell image pixel (i, j) to the cell nucleus object of the cell image. k is a natural number greater than zero, representing the direction angle sequence number of the currently selected pixel (i, j). Suppose the pixel (i, j) is equidistantly selected from the 1st, 2nd, ..., nth preset direction angles to calculate the distance from the pixel to the boundary of the selected object when the direction angle is selected. n is a natural number greater than 1, k = 1, 2, ..., n; Among them, θ k =n / (2πk), k=1,2,…,n is the selected direction angle number, Boundary is the boundary of the current object; Based on the Euclidean distance from the cell image pixel (i, j) to the cell nucleus object reconstructing a star-shaped geometric polygonal outline of the cell nucleus; Calculating the object probability of each pixel belonging to the cell nucleus includes: Let the object probability of pixel (i, j) be d i,j ,have: Where Distance((i,j),Background) represents the normalized distance from each pixel (i,j) to the nearest background pixel Background, and MaxDistance represents the maximum value of all calculated normalized distances; The generating of the corresponding polygonal candidate regions and the intersection-over-union ratio between the polygonal candidate regions comprises: Suppose that the pixel whose pixel object probability is greater than the threshold is selected from all pixels according to the threshold as (i', j'), i' = i1, i2, ..., i x ; i1, i2, …, i x are the horizontal coordinate numbers of the pixels whose object probability is greater than the threshold in 1, 2, ..., I, respectively, x is a natural number greater than 1, j'=j1, j2, ..., j y ; j1, j2, …, j y They are 1, 2, …, the ordinate numbers of the pixels in J whose object probability is greater than the threshold, and y is a natural number greater than 1; Based on the selected pixel (i', j'), the multi-directional distance from the selected pixel (i', j') to the cell nucleus boundary can be obtained. Based on the multi-directional distances to the cell nucleus boundary of pixels (i', j') whose object probabilities are greater than the threshold The polygonal candidate region A of the cell nucleus can be reconstructed i’,j’ ; Define polygonal candidate area A i’,j’ (i'=i1,i2,…,i x , j'=j1,j2,…,j y ), polygon candidate area A i’,j’ With other polygonal candidate regions A u,v The intersection over union (IoU) between them is: u, v represent pixel values. When the value of pixel (i', j') is selected, pixel (u, v) is the value of the pixel other than pixel (i', j'); The polygonal candidate regions that are sequentially retained and have the highest object probability and an intersection-over-union ratio with other candidate regions that is less than the threshold include: Use non-maximum suppression to remove candidate regions A i’,j’ The candidate regions overlapped in order to obtain A i0,j0 ; Let the candidate area pixel after removing the overlapping area be (i0, j0), i0 = i 10 ,i 20 ,…,i x0 ;i 10 ,i 20 ,…,i x0 , i1, i2, ..., i x After removing the overlapping candidate areas, the corresponding pixel horizontal coordinate numbers of the subsequent areas are obtained, where x0 is a natural number greater than 1; j0 = j 10 , j 20 , …, j y0 ;j 10 , j 20 , …, j y0 j1, j2, ..., j y After removing the overlapping candidate areas, the corresponding pixel ordinate numbers of the subsequent areas are obtained, and y0 is a natural number greater than 1; According to the object probability d of pixel (i0, j0) i0,j0 For candidate region A i0,j0 Sort and keep d i0,j0 The polygon candidate region with the highest object probability and whose IoU with other candidate regions is less than the threshold (A i0,j0 ); The step of assigning labels to the retained polygonal candidate regions and generating the final cell nucleus segmentation region comprises: Based on the above retained polygon candidate area IoU (A i0,j0 ), let I(iz,jz) represent the final generated nucleus segmentation map, (iz,jz) represent the horizontal and vertical pixel numbers of the generated segmentation map, and then i0,j0 ) and the label assigned to the corresponding pixel (iz, jz) based on P(iz, jz) is obtained: The final cell nucleus segmentation region is generated based on these labeled pixels (iz, jz).
6. The method for detecting cells based on DistSeg model image processing technology according to claim 1, characterized in that: The method of using morphological operations to generate a background region, a foreground region, and an edge region based on the segmented cell nucleus region includes: First, the cell nucleus boundary pixels are increased through dilation operation to mark the potential background area; Then, the cell nucleus boundary pixels are reduced through corrosion operation to generate high-confidence foreground areas; The area where the foreground and background differ is marked as the edge area for subsequent segmentation.
7. The method for detecting cells based on DistSeg model image processing technology as claimed in claim 6, characterized in that: Let the binary image of the cell nucleus instance be II, where II(x1,y1)=1 represents the target area, II(x1,y1)=0 represents the background, and x1,y1 represent the horizontal and vertical numbers of the pixels in the binary image II; The step of increasing the cell nucleus boundary pixels by dilation operation comprises: Define background expansion B k1 (II): Where K k1 is a structuring element of size k1×k1, represents the expansion operation, k1 is the expansion kernel size; Set each target area to be marked with an independent label l and the background to be 0; The method of reducing the cell nucleus boundary pixels by the corrosion operation includes: Define the instance corrosion F m (II): F m (II)=II-K m Here, "-" indicates the corrosion operation, K m is a structural element of size m×m, where m is the corrosion operation coefficient; The step of marking the area where the foreground and the background differ as the edge area comprises: Calculate the total foreground area F all (II) is the union of all instance foregrounds: The area where the foreground and background differ is marked as the edge area U k1 ; U k1 =B k1 (II)-F all (II).
8. The method for detecting cells based on DistSeg model image processing technology as claimed in claim 1, characterized in that: The method of calculating the shortest Euclidean distance from each background area pixel to the nearest foreground area pixel and segmenting the cell image using a watershed algorithm comprises: Calculate each background area pixel P b (x b ,y b ) to the nearest foreground pixel P f (x f ,y f )'s shortest distance D(P b ,P f ): For each background pixel P b , find all foreground pixel sets F(P b ), take the minimum value as the final distance d min (P b ),have: If F(P b ) is empty, then d min (P b ) is set to infinity; Define the distance graph D(x a ,y a ), where each background pixel (x b ,y b ) is equal to its distance to the nearest foreground pixel: Among them, Background represents the background pixel set, and Foregound represents the foreground pixel set; Based on D(x a ,y a ) generating a distance map to segment the cell image; The cell image is segmented using a watershed algorithm based on the markings of foreground, background, edge region, and distance map: Define the initial mark M(x) of the watershed algorithm c ,y c ), the foreground area is marked with F = F all (II), background area label B = B k1 (II), edge region marking E=U k1 ,have: Among them, the pixel (x c ,y c ) is marked as 1 for the foreground area, 2 for the background area, and 0 for the edge area; Let the unknown area E(x e ,y e ) for each pixel (x e ,y e ) is assigned the most recent tag value, then:
9. The method for detecting cells based on DistSeg model image processing technology as claimed in claim 1, characterized in that: The result optimization of the segmentation map corresponding to each cell instance label to obtain a filtered segmentation label map includes: Perform connectivity analysis on the instance segmentation map corresponding to each cell instance label to generate a label map L(x f ,y f ), let lf∈{0,1,2,…,N f } represents the label of the connected area; Define the area A of each connected region lf , record the statistical label graph L(x f1 ,y f1 The area A of each connected region is calculated by the number of pixels belonging to label lf in lf , the calculation formula is: The area filter conditions are: Lf'(x f1 ,y f1 ) is the filtered segmentation label map.
10. The method for detecting cells based on DistSeg model image processing technology according to claim 1, characterized in that: The process of extracting the outer contour of the nuclear region and the outer contour of the surrounding region of each cell from the segmentation mark map and saving them to the corresponding result file includes: The outer contour of the nuclear region and the outer contour of the surrounding region of each cell are extracted from the segmentation mark map based on the following formula: Let the output labeled graph be M'(x e ,y e ), then from the labeled graph: Extract the outer contour of the nuclear region C of each cell Ig nb (Ig) is: C nb (Ig)={(x g ,y g )|(x g ,y g )∈M'(x e ,y e )=1} The outer contour of the area surrounding each cell Ig cb (Ig) is: C cb (Ig)={(x h ,y h )|(x h ,y h )∈M'(x e ,y e )=2} Record and save the corresponding results to a JSON file.
11. A method for splicing cell image segmentation results, characterized in that: include: Acquire input data, the input data comprising: an original slice image file and a segmented image result after detecting cells by the method according to any one of claims 1 to 10, the original slice image file comprising: a plurality of slice image blocks; Horizontally splice the image patches of each row in sequence, while merging the overlapping region masks between the image patches, removing redundant parts and optimizing the overlapping regions, load the image patches of each row from the specified path and record the segmentation image results of the image patches, check the overlapping situation of the masks within the overlapping regions, update the merged mask and remove the redundant masks; Use the IoU metric to measure the overlapping situation between two masks, and evaluate the overlapping situation of the masks based on the IoU metric; Draw an image based on the overlapping situation of all masks to generate a spliced image of the cell image segmentation result.
12. The method for splicing cell image segmentation results according to claim 11, characterized in that: The step of using the IoU metric to measure the overlapping situation between two masks and evaluating the overlapping situation of the masks based on the IoU metric includes: Evaluate the similarity between two mask polygons P1 and P2, and the calculation formula is: Where: Area of Intersection represents the area of the overlapping region of the two mask polygons P1 and P2, and Area of Union represents the area of the union region of the two mask polygons P1 and P2; For two mask polygons P1 and P2, calculate their IoU metric. If IoU≥threshold, delete the mask Intersection with the smaller area; if IoU<threshold, calculate the Intersection part and perform a difference set operation: threshold is a preset metric threshold; P1' = P1 - Intersection P2' = P2 - Intersection Retain the non-overlapping regions on both sides.
13. A system for detecting cells based on DistSeg model image processing technology, characterized in that: Including: A preprocessing module, a first segmentation module, a second segmentation module, a third segmentation module, an optimization processing module, and an extraction module; The preprocessing module is suitable for preprocessing the collected cell images; The first segmentation module is suitable for segmenting the cell images based on the DistSeg model image processing technology to generate the cell nucleus region; The second segmentation module is suitable for generating the background region, foreground region, and edge region based on the segmented cell nucleus region by using morphological operations; The third segmentation module is suitable for calculating the shortest Euclidean distance from each background region pixel to the nearest foreground region pixel, and segmenting the cell image by using the watershed algorithm; The optimization processing module is suitable for optimizing the results of the segmentation map corresponding to each cell instance label to obtain a filtered segmentation label map; The extraction module is suitable for extracting the outer contour of the nuclear region and the outer contour of the surrounding region of each cell from the segmentation label map and saving them to the corresponding result file.
14. A system for splicing cell image segmentation results, characterized in that: Including: An image input module, an image splicing module, an overlapping region processing module, and a contour merging and output module; The image input module is suitable for obtaining input data, and the input data includes: an original slice image file and a JSON file recording the corresponding segmentation image results after cell detection, and the original slice image file includes: several slice image patches; The image stitching module is adapted to stitch the image blocks of each row horizontally in sequence, merge the overlapping area masks between the image blocks, remove the redundant parts and optimize the overlapping area, load the image blocks of each row from the specified path and record the image segmentation results of the image blocks, check whether the masks are overlapping in the overlapping area, update the merged masks and remove the redundant masks; The overlapping area processing module is adapted to use an IoU index to measure the overlap between two masks, and to evaluate the overlap of the masks based on the IoU index; The outline merging and outputting module is suitable for drawing an image based on the overlapping conditions of all masks to generate a spliced image of the cell image segmentation result.
Citation Information
Cited By
Pathological section analysis device and method based on deep learning
CN121170353A
Plane random placement image analysis processing system and processing method thereof
CN121661016A