Stacked cell hierarchy determination method based on contour completion and gradient quantization
By employing ellipse fitting and global gradient quantization, the challenges of contour completion and hierarchical judgment in cell image processing were solved, achieving complete restoration of cell morphology and accurate quantization of hierarchical relationships, thus improving the accuracy and repeatability of 3D modeling.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WUHAN MUTUAL UNITED TECH CO LTD
- Filing Date
- 2026-05-08
- Publication Date
- 2026-06-26
Smart Images

Figure CN122290108A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of biomedical image processing technology, specifically to a method for determining stacked cell levels based on contour completion and gradient quantization. Background Technology
[0002] In cutting-edge fields such as cell biology research, clinical pathology diagnosis, and tissue engineering, the precise analysis of the three-dimensional spatial distribution characteristics and interaction mechanisms of cells is a core prerequisite for revealing the laws of life activities and optimizing disease diagnosis strategies. Cell three-dimensional modeling technology, as a key bridge connecting two-dimensional microscopic imaging and three-dimensional spatial cognition, directly depends on the quality of resolving cell stacking relationships in two-dimensional images. When cell density is high, cells may come into contact, become adjacent, or even partially overlap, forming a stacking phenomenon in two-dimensional images, such as cancer cell clusters in tumor tissue sections or cell aggregation in hematopoietic stem cell culture systems. Accurately determining the hierarchical occlusion levels of these stacked cells is the core foundation for achieving precise conversion from two-dimensional images to three-dimensional models.
[0003] Current cell image processing technologies face several insurmountable bottlenecks in determining cell stacking hierarchy. First, regarding contour description, traditional image segmentation methods can only extract visible cell edges, failing to fill in contour breaks caused by occlusion. This results in insufficient integrity and accuracy of cell geometry, directly interfering with subsequent stacking relationship determination. Second, in terms of hierarchy determination criteria, most methods rely on manual observation or simple area and grayscale comparisons, lacking quantitative criteria based on image features. This leads to highly subjective results, poor experimental repeatability, and difficulty in meeting the needs of large-scale analysis. Third, regarding the analysis scope, existing methods focus only on completely overlapping cell pairs, ignoring potential stacking scenarios where cells are adjacent but do not intersect, resulting in analytical omissions. Finally, in terms of adapting to complex scenes, when multiple cells form complex stacked structures, current technologies cannot integrate the local relationships between pairs of cells to generate a structured global hierarchy sequence. This leads to disordered cell spatial positions and significant deviations between morphological reconstruction and the actual physiological state during 3D modeling.
[0004] In practical applications of 3D cell modeling, the accuracy of stacking hierarchy determination directly determines the modeling quality. Existing methods, due to the aforementioned shortcomings, result in significant deviations between the 3D model and the actual spatial distribution of cells. For example, in 3D tumor cell modeling, incorrect stacking hierarchy can misjudge the direction of cell invasion; in blood cell modeling, chaotic stacking relationships can obscure the physiological patterns of cell aggregation. Therefore, how to accurately resolve cell stacking hierarchy relationships through feature quantification analysis of 2D microscopic images, providing reliable spatial location input for 3D cell modeling, has become a critical technical challenge urgently needing to be solved in the field of cell image processing. Summary of the Invention
[0005] This invention provides a method for determining the stacked cell hierarchy based on contour completion and gradient quantization, which solves the technical problems in the prior art such as distorted cell morphology restoration, subjective ambiguity in the basis of hierarchy determination, low analysis efficiency, and chaotic global sorting of multiple cells.
[0006] To address the aforementioned technical problems, this invention provides a method for determining stacked cell levels based on contour completion and gradient quantization, comprising the following steps: Step S1: Extract the set of visible contour points of each cell in the cell micrograph; Step S2: Perform ellipse fitting on the set of visible contour points of each cell to obtain the fitting ellipse parameters of each cell. The fitting ellipse parameters include the center coordinates, the length of the major axis, the length of the minor axis, and the rotation angle. Step S3: Calculate the global gradient magnitude map for the cell microscopic image; Step S4: Screen candidate cell pairs based on the fitted ellipse parameters. The candidate cell pairs include overlapping cell pairs and adjacent cell pairs. Step S5: For each pair of cells in the candidate cell pairs, extract the contour points of each cell located in the overlapping area, obtain the gradient value corresponding to the contour points from the global gradient magnitude map, and calculate the average gradient value respectively. Determine the hierarchical relationship between the two cells by comparing the average gradient values. Step S6: Construct an attribute graph by treating each cell as a node and the hierarchical relationship as an edge, perform topological sorting on the attribute graph, and output a global stacked hierarchical sequence.
[0007] Preferably, in step S2, the least squares method is used to fit the ellipse, with the optimization objective being to minimize the sum of the geometric distances from all visible contour points to the fitted ellipse equation.
[0008] Preferably, step S3 includes: The gradient operator was used to calculate the horizontal gradient components of the cell micrographs. and vertical gradient components ; According to the horizontal gradient component and the vertical gradient component Calculate the gradient magnitude for each pixel; The gradient magnitude is linearly normalized to generate a global gradient magnitude map.
[0009] Preferably, the gradient operator is the Sobel operator; the linear normalization range is 0 to 255.
[0010] Preferably, the method for screening overlapping cell pairs in step S4 includes: An elliptical binary mask is generated based on the fitted ellipse parameters of each cell. Perform a bitwise AND operation on the elliptic binary mask of any two cells; If the number of non-zero pixels in the bitwise AND operation result exceeds a preset overlapping pixel threshold, then the two cells are determined to be an overlapping cell pair.
[0011] Preferably, the method for screening adjacent cell pairs in step S4 includes: For two cells that are not identified as overlapping cell pairs, extract the center coordinates of their fitted ellipses and calculate the distance between the two centers. ; If the distance Meet the conditions If so, then the two cells are determined to be an adjacent cell pair; in, and Cells The lengths of the major and minor axes of the fitted ellipse. and Cells The lengths of the major and minor axes of the fitted ellipse. This is the preset pixel tolerance value.
[0012] Preferably, the overlapping pixel threshold is 5 pixels.
[0013] Preferably, the method for determining the hierarchical relationship in step S5 includes: Calculate cells separately and cells Average gradient value of contour points within the overlapping region and ; Calculate gradient difference ; If the gradient difference Greater than the preset gradient difference threshold Then determine the cell Located in cells Above; if the gradient difference Less than the gradient difference threshold If the value is negative, then the cell is determined to be negative. Located in cells Above; if the gradient difference The absolute value is not greater than the gradient difference threshold. Then determine the cell With cells They are at the same level.
[0014] Preferably, the method for constructing the attribute graph in step S6 includes: Each cell is treated as a graph node, and the node attributes include cell identifier, fitted ellipse parameters, and global average gradient value. For cell pairs that are determined to be in a hierarchical relationship, a directed edge is established from the upper cell to the lower cell, and the weight of the directed edge is the absolute value of the average gradient difference between the two cells in the overlapping region. For cell pairs that are determined to be in the same layer, an undirected edge is established, and the weight of the undirected edge is zero.
[0015] Preferably, the method for topological sorting the attribute graph in step S6 includes: Nodes connected by undirected edges are aggregated into groups of the same level, while individual nodes not connected to other nodes by undirected edges form their own groups. Calculate the in-degree of each group at the same level, where the in-degree is the total number of directed edges pointing to any node within that group. Add the same-level groups with zero in-degree to the queue after sorting them in descending order by the average global gradient value of the nodes in the group. Take out the same level group from the queue in order and add it to the sorting result. Delete the outgoing edges of all nodes in the same level group and update the in-degree of the pointed-to same level group. If the in-degree of a certain same level group drops to zero, add it to the queue in descending order of the average global gradient value. Repeat the previous step until all groups at the same level have been processed, and output the global stacking hierarchy sequence.
[0016] The beneficial effects of the present invention include at least the following: (1) This invention addresses the characteristic that cells often exhibit elliptical shapes due to their growth state, imaging angle, and mutual compression. It utilizes visible contour fragments for elliptical fitting, effectively completing the contour of occluded areas. This solves the problems of morphological analysis distortion caused by morphological deviation in traditional circle fitting and contour breakage in traditional methods, providing a basis for determining the complete cell morphology and spatial boundaries required for 3D modeling.
[0017] (2) This invention designs a dual detection mechanism that combines mask bitwise AND operation with elliptical center distance calculation. It identifies completely overlapping cell pairs by matching the mask overlap of the fitted ellipse, and determines adjacent but non-intersecting cell pairs by combining the elliptical center distance with major and minor axis thresholds, ensuring that no potential stacking relationships are missed. This mechanism comprehensively covers various spatial contact morphologies of cell 3D stacking, providing complete cell spatial association data for 3D modeling and avoiding modeling structure loss due to missed relationships.
[0018] (3) This invention utilizes the optical imaging principle that the edge imaging of upper cells is clearer and its gradient amplitude is higher, to transform the difference in visual clarity into quantifiable gradient data, eliminate the subjectivity of human judgment, and improve the repeatability and reliability of the experiment.
[0019] (4) This invention treats each cell as a graph node, models the spatial relationships between cells as edges, and assigns three types of attributes to the edges: direction, color, and weight. The hybrid graph is topologically sorted using the improved Kahn algorithm, and processed in units of the same layer, taking into account both strict hierarchy and equality within the same layer. Finally, a globally consistent and logically conflict-free cell stacking hierarchy sequence is output, which solves the problem of spatial sorting in 3D modeling of complex multi-cell stacking scenarios.
[0020] (5) This invention does not require multi-layer scanning or three-dimensional imaging equipment. It can restore the spatial stacking relationship between cells with only a single two-dimensional microscopic image, which has important application value in the fields of cell counting, morphological analysis and tissue engineering. Attached Figure Description
[0021] Figure 1 This is an overall flowchart of the stacked cell hierarchy determination method based on contour completion and gradient quantization of the present invention; Figure 2 This is a flowchart of the candidate cell pair screening process of the present invention; Figure 3 This is a flowchart illustrating the calculation of the average gradient of the intersecting region and the determination of the hierarchy in this invention. Figure 4 This is a schematic diagram illustrating the hierarchy determination in a two-cell stacking scenario according to the present invention; Figure 5 This is a schematic diagram illustrating the hierarchy determination in a multi-cell stacking scenario according to the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the present invention.
[0023] This invention proposes a method for determining the stacked cell hierarchy based on ellipse fitting and global gradient analysis. Its core principle relies on the optical imaging law that upper-layer cells have clearer visible edges and higher gradient amplitudes. During microscopic imaging, the edges of upper-layer cells are directly imaged, exhibiting sharp and clear characteristics, corresponding to higher image gradient values; the edges of lower-layer cells are occluded or located off-focal planes, exhibiting blurred and soft characteristics, corresponding to lower gradient values. Based on this physical law, this invention achieves automated determination of cell stacking hierarchy through a process of contour extraction, ellipse fitting, gradient calculation, intersection filtering, region gradient comparison, and topological sorting.
[0024] The feasibility of this invention stems from two aspects: First, the spatial stacking relationship of cells directly reflects the difference in the clarity of the edges of overlapping areas in imaging, with the upper layer of cells having a high edge gradient and the lower layer of cells having a low edge gradient; Second, the natural shape of cells is mostly similar to an ellipse, and even if part of the outline is obscured, the visible part still contains complete elliptical geometric features. By fitting, the complete shape of the cell can be restored, providing an accurate geometric basis for intersection judgment.
[0025] like Figure 1 As shown, the specific implementation steps of the present invention are as follows: Step S1: Extract the set of visible contour points of each cell in the cell micrograph.
[0026] Contours are the core carriers of cell morphology, directly determining the accuracy of subsequent fitting and hierarchical determination. The goal of this step is to preserve as completely as possible the unobstructed visible edges of each cell, providing a reliable data source for ellipse fitting. The input cell microscopic images are processed using a previously validated contour extraction algorithm, fully preserving the unobstructed visible edge pixels of each cell and directly outputting a clean set of contour points for each cell, serving as the core data source for subsequent morphological reconstruction and geometric analysis. This step inherits a mature contour extraction process, ensuring the reliability of the input data.
[0027] Step S2: Perform ellipse fitting on the set of visible contour points of each cell to obtain the fitting ellipse parameters for each cell. The fitting ellipse parameters include the center coordinates, major axis length, minor axis length, and rotation angle.
[0028] After obtaining the contour point set of each cell, to overcome the problems of contour breakage and incomplete shape caused by stacking, this invention utilizes the elliptical-like properties of most cells for shape completion. In actual imaging, the natural shape of cells is mostly elliptical rather than a standard circle, which is related to factors such as cell compression, illumination angle, and tissue environment. Even if part of the contour is occluded, the remaining visible edges still conform to the geometric characteristics of an ellipse. By fitting an ellipse, the complete shape of the cell can be restored, solving the shape distortion problem caused by traditional circle fitting.
[0029] For each cell, an ellipse fitting algorithm based on the least squares method is employed. The algorithm aims to minimize the sum of the geometric distances from all visible contour points to the fitted ellipse equation, iteratively solving for the ellipse parameters, including the center coordinates, that best represent the complete morphology of the cell. Major axis length minor axis length and rotation angle Finally, a complete fitted ellipse equation and a corresponding binary mask image are generated for each cell, thereby converting potentially broken or incomplete contours into continuous and complete closed geometric shapes, providing a precise basis for subsequent spatial relationship analysis.
[0030] Step S3: Calculate the global gradient magnitude map for the cell microscopic image.
[0031] After completing the morphological completion, it is necessary to quantify the edge sharpness of all pixels in the entire image. This is a crucial physical quantity transformation step for determining the hierarchy. Gradient magnitude reflects edge sharpness and is a key indicator for judging cell hierarchy relationships. The edges of cells in the upper layer are usually sharper, with higher gradient values; the edges of cells occluded by the upper layer are blurred, with lower gradient values. By calculating the global gradient map, the difference in sharpness can be transformed from visual perception into quantifiable data, providing an objective basis for subsequent stacking direction determination.
[0032] For the preprocessed original cell grayscale image (which must retain global illumination and texture information, and cannot use the contour map of a single cell), the gradient operator is used to calculate the horizontal gradient components separately. and vertical gradient components In this embodiment, the Sobel operator is used as the gradient operator. The gradient magnitude of each pixel is calculated based on the horizontal and vertical gradient components. .
[0033] To facilitate intuitive comparison and numerical processing, the gradient magnitudes are linearly normalized to the range of 0-255, generating a global gradient magnitude map. High values (bright areas) correspond to sharp, clear edges, while low values (dark areas) correspond to softer, blurred edges. Areas with values of 255 represent the sharpest edges (likely upper-layer cells), while areas with values close to 0 are blurry (likely lower-layer cells). The final output normalized gradient magnitude map transforms the differences in sharpness between cell layers into a globally indexable quantized data matrix, allowing for intuitive differentiation of gradient distributions using ordinary image viewing tools.
[0034] Step S4: Screen candidate cell pairs based on the fitted ellipse parameters. Candidate cell pairs include overlapping cell pairs and adjacent cell pairs.
[0035] Spatial association between cells is necessary for stacking occlusion to occur. This step aims to efficiently screen for overlapping or closely adjacent cell pairs from all cells, forming a candidate set for subsequent hierarchical analysis and significantly reducing unnecessary computation. Figure 2 As shown, the screening of candidate cell pairs includes two parts: overlapping cell pair detection and adjacent cell pair supplementation detection.
[0036] For overlapping cell pair detection, the elliptical binary mask generated in step S2 is used to detect any two cells. and A bitwise AND operation is performed on the masks. If two cells overlap, the pixels in the overlapping area are all 1 in both masks, and the result of the bitwise AND operation is 1; if there is no overlap, the result is 0. The number of non-zero pixels in the bitwise AND operation result is counted. If it exceeds a preset overlapping pixel threshold (set to 5 pixels in this embodiment to avoid misjudgment due to pixel errors), it is determined to be an overlapping cell pair and denoted as . .
[0037] For supplementary detection of adjacent cell pairs, some cells, although not overlapping, are still close together and may still have an occlusion relationship. For two cells that are not identified as overlapping cell pairs, the center coordinates of their fitted ellipses are extracted. and Calculate the distance between the two centers. If the distance Meet the conditions If so, then the two cells are determined to be an adjacent cell pair. and Cells The lengths of the major and minor axes of the fitted ellipse. and Cells The lengths of the major and minor axes of the fitted ellipse. The preset pixel tolerance value is used (set to 2 pixels in this embodiment). Finally, all overlapping cell pairs are merged with adjacent cell pairs to form a potential stacking candidate set. .
[0038] Step S5: For each pair of cells in the candidate cell pair, extract the contour points of each cell located in the overlapping area, obtain the gradient value corresponding to the contour point from the global gradient magnitude map, and calculate the average gradient value respectively. Determine the hierarchical relationship between the two cells by comparing the average gradient values.
[0039] This is the core step in determining cell hierarchy in this invention. Its physical basis is that within overlapping areas, the edges of upper-layer cells are clearly imaged with a high gradient, while the edges of lower-layer cells are blurred with a low gradient. For example... Figure 3 As shown, for the candidate set Each pair of cells This step quantifies the differences in sharpness between them in overlapping (or adjacent) regions.
[0040] First, calculate the coordinate range of the theoretically overlapping region (e.g., the upper left corner) based on the ellipse parameters of both. Go to the bottom right corner Then, cells are selected from the original contours extracted in step S1. and cells The contour points located within this overlapping area form two local contour segments. and Next, on the global gradient magnitude map output in step S3, extract the gradient values of all pixels on these two local contour segments, and calculate the average gradient value for each. and .
[0041] The hierarchical relationship between two cells is determined by comparing their average gradient values. The specific rules are as follows: Calculate the gradient difference. If the gradient difference Greater than the preset gradient difference threshold (In this embodiment, it is set to 30), indicating that the cells Above, determine the cells. Located in cells Above, the cells are obscured. If the gradient difference Less than the gradient difference threshold The negative value (i.e. ), indicating cells Above, determine the cells. Located in cells Above; if gradient difference The absolute value is not greater than the gradient difference threshold. This indicates that there is no obvious obstruction between the two, thus determining the cells. With cells This represents a hierarchical relationship. The final output contains a hierarchical table showing the occlusion directions between all cell pairs.
[0042] Step S6: Construct an attribute graph by treating each cell as a node and the hierarchical relationship as an edge, perform topological sorting on the attribute graph, and output the global stacked hierarchy sequence.
[0043] When there are multiple stacked cells within the field of view, it is necessary to integrate the pairwise relationships into a clear hierarchical sequence for easy use in subsequent modeling. This step constructs an attribute graph by treating each cell as a node and the hierarchical relationships as edges. The attribute graph is then topologically sorted to output a global stacked hierarchical sequence. By using the attribute graph and topological sorting, each cell is treated as a node, and the hierarchical relationships between cells are distinguished by directed or undirected edges. After constructing the attribute graph, the improved Kahn algorithm eliminates cyclic relationships, balancing strict hierarchy with equality within the same layer, resulting in an intuitive hierarchical sequence.
[0044] The specific method for constructing the attribute graph is as follows: Each valid cell is treated as a graph node, and the node attributes include cell identifier (ID), fitted ellipse parameters (for subsequent modeling), and global average gradient value. For the candidate set... Each pair of cells Edges are established according to the hierarchical relationship type. For cell pairs determined to be in a hierarchical relationship (such as...), ... exist Above, that is ), establishing a structure from upper cells Pointing to lower cells Directed edge The directed edges are set to blue (indicating a clear occlusion relationship), and their weights are set to the absolute value of the average gradient difference between the two cells in the overlapping region (i.e., ...). The higher the weight, the more reliable the occlusion relationship. For cell pairs determined to be in the same layer (i.e., ), construct undirected edges The color of undirected edges is set to red (indicating equality within the same layer), and the weight of undirected edges is set to 0.
[0045] Topological sorting is an extension of Kahn's algorithm to handle relationships within the same level. The specific steps are as follows: The first step is to initialize the same-level node groups and the in-degree table. Traverse the red undirected edges, and aggregate the nodes connected by the undirected edges into same-level groups. Single nodes not connected to other nodes by undirected edges form their own groups (single-node groups). Count the in-degree of each same-level group. The in-degree is the total number of directed edges (blue directed edges) pointing to any node in the same-level group.
[0046] The second step is to initialize the queue. Groups with an in-degree of 0 (without any upper-layer occlusion, located at the top layer) are added to the queue. If there are multiple groups in the queue, they are sorted in descending order of the average global gradient value of the nodes within the group before being added to the queue (the higher the gradient, the more the group is biased towards the top layer).
[0047] The third step is iterative processing. One node from each layer of the same node group is sequentially added to the sorting result. If it's a single-node group, the node is directly recorded; if it's a multi-node group, the nodes within the group are sorted in ascending order by the average gradient value of their local overlapping regions (this only indicates the order within the same plane and does not represent hierarchical relationships). All outgoing edges (blue directed outgoing edges) of all nodes in the same layer group are deleted, and the in-degree of the pointed-to group is updated (the in-degree of the pointed-to group is decremented by 1). If the in-degree of a group drops to 0 as a result, it is added to the queue according to the rules of the second step (in descending order by average global gradient value).
[0048] Step 4: Loop until completion. Repeat step 3 until all cells in the same layer have been processed, ultimately outputting a linear global stacked hierarchy sequence, where cells in the same layer are aggregated and displayed, visually reflecting the stacking order from top to bottom.
[0049] like Figure 4 and Figure 5As shown, this invention can be applied to both two-cell stacking scenarios and complex multi-cell stacking scenarios. In two-cell stacking scenarios, the vertical relationship is determined by comparing the gradients of the intersecting regions. The contours of the fitted ellipses of cells A and B within the intersecting region are extracted, and their average gradient values are calculated. The cell with the higher gradient value is identified as the upper-layer cell. In complex multi-cell stacking scenarios, the local hierarchical relationships between pairs of cells are integrated into a globally consistent stacking hierarchy sequence through attribute graph construction and an improved Kahn topology sorting algorithm.
[0050] Through the aforementioned sequential steps, this invention, building upon existing cell contour extraction and analysis methods, introduces global gradient quantization and ellipse fitting and completion techniques, forming a clear and efficient automatic hierarchical determination chain. Researchers can obtain accurate intercellular layer relationships and global stacking sequences using only conventional cell microscopic images without requiring special equipment, providing crucial information for subsequent 3D reconstruction and statistical analysis.
[0051] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described; only preferred embodiments of the present invention are illustrated. The descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. As long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.
[0052] It should be noted that those skilled in the art can make various modifications and improvements without departing from the inventive concept, and these all fall within the scope of protection of this invention. Therefore, the scope of protection of this invention should be determined by the appended claims.
Claims
1. A method for determining stacked cell hierarchy based on contour completion and gradient quantization, characterized in that, Includes the following steps: Step S1: Extract the set of visible contour points of each cell in the cell micrograph; Step S2: Perform ellipse fitting on the set of visible contour points of each cell to obtain the fitting ellipse parameters of each cell. The fitting ellipse parameters include the center coordinates, the length of the major axis, the length of the minor axis, and the rotation angle. Step S3: Calculate the global gradient magnitude map for the cell microscopic image; Step S4: Screen candidate cell pairs based on the fitted ellipse parameters. The candidate cell pairs include overlapping cell pairs and adjacent cell pairs. Step S5: For each pair of cells in the candidate cell pairs, extract the contour points of each cell located in the overlapping area, obtain the gradient value corresponding to the contour points from the global gradient magnitude map, and calculate the average gradient value respectively. Determine the hierarchical relationship between the two cells by comparing the average gradient values. Step S6: Construct an attribute graph by treating each cell as a node and the hierarchical relationship as an edge, perform topological sorting on the attribute graph, and output a global stacked hierarchical sequence.
2. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 1, characterized in that, In step S2, the least squares method is used to fit the ellipse, with the optimization objective being to minimize the sum of the geometric distances from all visible contour points to the fitted ellipse equation.
3. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 1, characterized in that, Step S3 includes: The gradient operator was used to calculate the horizontal gradient components of the cell micrographs. and vertical gradient components ; According to the horizontal gradient component and the vertical gradient component Calculate the gradient magnitude for each pixel; The gradient magnitude is linearly normalized to generate a global gradient magnitude map.
4. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 3, characterized in that, The gradient operator is the Sobel operator; the linear normalization range is 0 to 255.
5. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 1, characterized in that, The methods for screening overlapping cell pairs in step S4 include: An elliptical binary mask is generated based on the fitted ellipse parameters of each cell. Perform a bitwise AND operation on the elliptic binary mask of any two cells; If the number of non-zero pixels in the bitwise AND operation result exceeds a preset overlapping pixel threshold, then the two cells are determined to be an overlapping cell pair.
6. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 5, characterized in that, The methods for screening adjacent cell pairs in step S4 include: For two cells that are not identified as overlapping cell pairs, extract the center coordinates of their fitted ellipses and calculate the distance between the two centers. ; If the distance Meet the conditions If so, then the two cells are determined to be an adjacent cell pair; in, and Cells The lengths of the major and minor axes of the fitted ellipse. and Cells The lengths of the major and minor axes of the fitted ellipse. This is the preset pixel tolerance value.
7. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 5, characterized in that, The threshold for overlapping pixels is 5 pixels.
8. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 1, characterized in that, The methods for determining hierarchical relationships in step S5 include: Calculate cells separately and cells Average gradient value of contour points within the overlapping region and ; Calculate gradient difference ; If the gradient difference Greater than the preset gradient difference threshold Then determine the cell Located in cells Above; if the gradient difference Less than the gradient difference threshold If the value is negative, then the cell is determined to be negative. Located in cells Above; if the gradient difference The absolute value is not greater than the gradient difference threshold. Then determine the cell With cells They are at the same level.
9. The method for determining stacked cell levels based on contour completion and gradient quantization according to claim 1, characterized in that, The methods for constructing the attribute graph in step S6 include: Each cell is treated as a graph node, and the node attributes include cell identifier, fitted ellipse parameters, and global average gradient value. For cell pairs that are determined to be in a hierarchical relationship, a directed edge is established from the upper cell to the lower cell, and the weight of the directed edge is the absolute value of the average gradient difference between the two cells in the overlapping region. For cell pairs that are determined to be in the same layer, an undirected edge is established, and the weight of the undirected edge is zero.
10. The method for determining stacked cell hierarchy based on contour completion and gradient quantization according to claim 9, characterized in that, The method for topological sorting the attribute graph in step S6 includes: Nodes connected by undirected edges are aggregated into groups of the same level, while individual nodes not connected to other nodes by undirected edges form their own groups. Calculate the in-degree of each group at the same level, where the in-degree is the total number of directed edges pointing to any node within that group. Add the same-level groups with zero in-degree to the queue after sorting them in descending order by the average global gradient value of the nodes in the group. Take out the same level group from the queue in order and add it to the sorting result. Delete the outgoing edges of all nodes in the same level group and update the in-degree of the pointed-to same level group. If the in-degree of a certain same level group drops to zero, add it to the queue in descending order of the average global gradient value. Repeat the previous step until all groups at the same level have been processed, and output the global stacking hierarchy sequence.