Dyeing area automatic labeling method based on image segmentation
By constructing a graph structure and using a multi-scale random walk method, the problems of manual dependence and boundary instability in stained image segmentation are solved, achieving automated and accurate stained region annotation, and adapting to the segmentation needs of complex stained regions.
Patent Information
- Application Number
- CN202511711012.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-20
- Publication Date
- 2026-03-06
Smart Images

Figure CN121617092A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an automatic annotation method for colored regions based on image segmentation. Background Technology
[0002] In the field of stained image analysis, commonly used region segmentation methods include thresholding, region growing, graph segmentation, clustering segmentation, and random walk segmentation. Among these, random walk segmentation has certain advantages in processing noisy and low-contrast images because it can determine region affiliation based on the connectivity probability between pixels. However, traditional random walk methods usually rely on manual annotation of seed points, which is easily influenced by user experience and cannot meet the automation requirements in large-scale image processing scenarios. Furthermore, the edge weights used to construct the graph structure in traditional methods are usually based on pixel value differences, making it difficult to accurately reflect common phenomena in stained images such as dye diffusion and color gradation.
[0003] Furthermore, existing stained images often suffer from problems such as blurred boundaries, uneven stained areas, and local noise interference in practical applications. This leads to unstable boundaries in the probability maps obtained from single-scale random walks, and the segmentation results are prone to boundary shifts or region breaks in complex stained areas. Current technologies lack a complete segmentation process that can take into account multi-scale features, automatically obtain classification criteria, and refine the initial segmentation boundaries, resulting in significant shortcomings in accurate, reliable, and automated annotation of stained regions.
[0004] Therefore, how to provide an automatic annotation method for colored regions based on image segmentation is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] One objective of this invention is to propose an automatic labeling method for colored regions based on image segmentation. This invention achieves accurate labeling of colored regions based on automatic seed points and multi-scale random walks, and has the advantages of high automation and strong stability.
[0006] An automatic annotation method for colored regions based on image segmentation according to an embodiment of the present invention includes the following steps:
[0007] Obtain the stained image to be processed, determine the neighboring pixels of each pixel according to the positional relationship of the pixels in two-dimensional space, and generate the corresponding initial edge connection weights based on the pixel value differences of the neighboring pixels.
[0008] A staining intensity statistical analysis is performed on the stained image to obtain a staining intensity histogram. The staining intensity threshold is determined based on the peak value of the staining intensity histogram, and seed points for high-stained and low-stained regions are automatically generated in the graph structure using the staining intensity threshold.
[0009] Perform color gradient calculation on each pair of adjacent pixels in the graph structure, and adjust the initial edge connection weights according to the color gradient to form an edge connection weight set;
[0010] Perform random walk calculations to obtain three random walk probability maps;
[0011] The three random walk probability maps are weighted and fused according to the fusion ratio to generate a fused probability map;
[0012] Based on the fusion probability map, pixel attribution is determined for all pixels in the graph structure, and the initial segmentation result of the colored region is generated based on the probability value of the pixel.
[0013] Based on the probability gradient changes in the fusion probability map, the initial segmentation results are refined to generate the final segmentation results of the stained regions;
[0014] The final segmentation results are used to generate stained region annotations, which are then output as the automatic annotation results of the stained image.
[0015] Optionally, the generation of the initial graph structure includes:
[0016] After acquiring the stained image to be processed, all pixels in the stained image are scanned point by point. Based on the horizontal and vertical positions of each pixel in the two-dimensional coordinates, the upper, lower, left, and right pixels that maintain direct spatial contact with the pixel under the condition of single-step spatial displacement are determined. Each pixel is combined with its corresponding upper, lower, left, and right pixels to form adjacent pixel pairs, and all adjacent pixel pairs constitute a candidate set.
[0017] All pixels in the stained image are used as nodes of the graph structure, and all adjacent pixel pairs are used as edges between nodes. All adjacent pixel pairs are added to the graph structure in an edge-by-edge manner.
[0018] For each edge in the graph structure consisting of adjacent pixel pairs, obtain the color intensity of the two pixels, perform an absolute difference operation on the color intensity of the two pixels, use the absolute difference as the base value of the initial edge connection weight corresponding to the edge, and generate the initial edge connection weight of the edge according to the preset monotonic mapping method.
[0019] After generating initial edge connection weights for all edges in the graph structure, all pixels, all edges, and all initial edge connection weights in the graph structure are combined to form the initial graph structure.
[0020] Optionally, the generation of the initial constraints includes:
[0021] After acquiring the stained image, perform stained intensity statistical analysis on the color intensity of all pixels in the stained image, accumulate the color intensity of all pixels according to the frequency of the numerical value, and generate a stained intensity histogram.
[0022] Peak value determination is performed on the position with the highest frequency in the staining intensity histogram;
[0023] A color intensity threshold is generated based on the position of the peak in the color intensity histogram. The color intensity of all pixels in the color image is divided according to the color intensity threshold. Pixels with color intensity not less than the color intensity threshold are labeled as pixels with high color attributes, and pixels with color intensity less than the color intensity threshold are labeled as pixels with low color attributes.
[0024] Based on pixels with high and low coloring attributes, pixels with high coloring attributes are designated as seed points for high coloring regions and pixels with low coloring attributes are designated as seed points for low coloring regions in the graph structure.
[0025] The seed points of all high-color regions and all low-color regions are combined according to the order of nodes in the graph structure to form the initial constraints for the random walk computation.
[0026] Optionally, the generation of the edge connection weight set includes:
[0027] Perform pairwise processing on all adjacent pixel pairs in the initial image structure. For each adjacent pixel pair, read the color intensity of the two pixels in the stained image and calculate the color gradient of the adjacent pixel pair based on the numerical change of the color intensity of the two pixels.
[0028] The connection weights of each initial edge consisting of adjacent pixel pairs in the initial graph structure are adjusted edge-by-edge based on the color gradient.
[0029] After adjusting all the initial edge connection weights, maintain the original correspondence between all the adjusted initial edge connection weights and all adjacent pixel pairs in the initial graph structure.
[0030] After adjusting all the initial edge connection weights, combine all the adjusted initial edge connection weights to form an edge connection weight set.
[0031] Optionally, the generation of the three random walk probability maps includes:
[0032] The set of edge connection weights and the seed points of high-coloring regions and low-coloring regions are added as input conditions to the random walk calculation process. The graph structure at the original resolution spatial scale is constructed, and random walk calculation is performed on the graph structure at the original resolution to generate the first random walk probability graph corresponding to the original resolution.
[0033] The graph structure at the original resolution is scaled down to a half-resolution spatial scale to form a graph structure at half resolution. At this half-resolution spatial scale, the set of edge connection weights and the seed points of high-coloring regions and low-coloring regions are used as input conditions to perform random walk calculations on the graph structure at half resolution, generating a second random walk probability graph corresponding to the half resolution.
[0034] The graph structure at half resolution is further reduced to a quarter resolution spatial scale to form a quarter resolution graph structure. At this quarter resolution spatial scale, the set of edge connection weights and the seed points of high-colored and low-colored regions are used as input conditions to perform random walk calculations on the quarter resolution graph structure, generating a third random walk probability graph corresponding to the quarter resolution.
[0035] After generating the first random walk probability map, the second random walk probability map, and the third random walk probability map, the three are used as the input probability map set when performing fusion processing.
[0036] Optionally, the generation of the fusion probability map includes:
[0037] The three random walk probability maps are used as the input probability map set for weighted fusion, while maintaining the one-to-one correspondence between the three random walk probability maps at all pixel positions;
[0038] The probability values of each corresponding pixel position in the three random walk probability maps are weighted according to the preset fusion ratio. The probability values of the three random walk probability maps at the same pixel position are added together according to the preset fusion ratio to generate the fusion probability value of that pixel position.
[0039] After generating the fusion probability values for all pixel positions, combine all the fusion probability values according to their corresponding pixel positions to form a fusion probability map.
[0040] Optionally, the initial segmentation result is formed by:
[0041] The fusion probability map is used as input for pixel attribution determination, and the probability values of all pixel positions in the fusion probability map are read pixel by pixel.
[0042] Perform pixel attribution determination for each pixel in the graph structure. At each pixel position, determine the attribution based on the corresponding probability value in the fused probability graph. Pixels whose probability values meet the preset attribution conditions are determined to belong to the stained region, and pixels whose probability values do not meet the preset attribution conditions are determined not to belong to the stained region.
[0043] All pixels identified as belonging to the stained region are combined according to their positions in the graph structure to form the initial segmentation result of the stained region.
[0044] Optionally, the generation of the final segmentation result includes:
[0045] The initial segmentation result and the fusion probability map are used as input data for boundary refinement, and the probability values of all pixel positions in the fusion probability map are read pixel by pixel.
[0046] Perform pixel-by-pixel probability gradient change calculation on the fused probability map, and determine the probability gradient change at each pixel position based on the probability value change between adjacent pixel positions;
[0047] The initial segmentation result is subjected to pixel-by-pixel boundary refinement. At each pixel position, the boundary of the corresponding pixel in the initial segmentation result is adjusted according to the probability gradient change in the fusion probability map. The boundary position of the pixel in the position of significant probability gradient change is adjusted.
[0048] The refined pixels are combined to form the final segmentation result of the stained region, so that the final segmentation result of the stained region has continuity and accuracy, and the final segmentation result of the stained region is output.
[0049] Optionally, the generation of the automatic annotation results includes:
[0050] The final segmentation result of the stained region is used as the input data for generating the stained region annotation output, and the positional relationship of all pixels in the final segmentation result is read pixel by pixel.
[0051] Based on the segmentation status of all pixels in the final segmentation result, mask data is generated, and all pixels that are determined to belong to the stained region are marked in the mask data.
[0052] Extract the region contour based on the spatial connectivity of consecutive pixels in the mask data;
[0053] Generate polygonal boundaries based on the positional relationships of pixel boundaries in the region outline;
[0054] The mask data, region contours, or polygon boundaries are combined to form the stained region annotation output, which is then output as the automatic annotation result of the stained image.
[0055] The beneficial effects of this invention are:
[0056] This invention constructs a graph structure with stained image pixels as nodes and adjacent pixel relationships as edges, assigning initial edge connection weights based on color intensity differences to each edge. This ensures a consistent representation of the stained image within the graph structure, laying a stable foundation for subsequent segmentation calculations. By performing statistical analysis of the stained image's stained intensity, the peak value of the stained intensity histogram is used to determine the stained intensity threshold. Furthermore, seed points for high-stained and low-stained regions are automatically labeled within the graph structure, allowing the initial constraints in random walk segmentation to be automatically derived from the image itself. This avoids the subjectivity and inconsistencies inherent in existing technologies that rely on manual seed point selection. Simultaneously, by calculating the color gradient between adjacent pixels and adjusting the initial edge connection weights edge-by-edge based on this gradient, the edge connection weights more accurately reflect color changes between pixels, particularly in areas of dye diffusion, color transition, or blurred boundaries. This makes the graph structure more sensitive to subtle changes in the true stained boundaries.
[0057] This invention further performs random walk calculations at three spatial scales: original resolution, half-resolution, and quarter-resolution. The three random walk probability maps are then weighted and fused pixel-by-pixel according to a preset fusion ratio to generate a fusion probability map. This allows the segmentation process to simultaneously absorb image features from different scales, thereby improving segmentation stability and adaptability to complex stained regions. Pixel attribution determination based on the fusion probability map avoids missegmentation caused by single-scale random walks in low-contrast or unevenly stained conditions. Subsequently, the initial segmentation result is refined using the probability gradient changes in the fusion probability map, enabling more accurate alignment of the segmentation boundary at locations of local gradient abrupt changes. This improves upon existing technologies that suffer from boundary breaks, offsets, and jagged edges. Finally, based on the refined segmentation result, this invention generates stained region annotations in the form of mask data, region contours, or polygonal boundaries. These outputs can be directly used for stained image recognition, computational analysis, or subsequent automated processing. Through these continuous processing steps, this invention effectively overcomes the problems of heavy reliance on manual intervention, insufficient boundary recognition capabilities, poor multi-scale adaptability, and limited annotation formats in existing technologies, achieving more stable, accurate, and automated annotation of stained regions. Attached Figure Description
[0058] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0059] Figure 1 This is a flowchart illustrating the overall process of an automatic color region annotation method based on image segmentation proposed in this invention.
[0060] Figure 2This is a schematic diagram illustrating the generation of random walk probability maps at different spatial scales in an automatic color region annotation method based on image segmentation proposed in this invention. Detailed Implementation
[0061] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0062] refer to Figure 1 and Figure 2 An automatic labeling method for colored regions based on image segmentation includes the following steps:
[0063] Obtain the stained image to be processed, determine the adjacent pixels of each pixel according to the positional relationship of the pixels in two-dimensional space, construct a graph structure based on the spatial adjacency relationship between pixels, construct a graph structure with each pair of adjacent pixels as edges, and generate the corresponding initial edge connection weights according to the pixel value difference of adjacent pixels.
[0064] Perform statistical analysis of staining intensity on the stained image to obtain a staining intensity histogram. Determine the staining intensity threshold based on the peak value of the staining intensity histogram. Use this staining intensity threshold to automatically generate seed points for high-staining regions and low-staining regions in the graph structure. Use the seed points for high-staining regions and low-staining regions as the initial constraints for random walk calculation.
[0065] Perform color gradient calculation on each pair of adjacent pixels in the graph structure, and adjust the initial edge connection weights according to the color gradient to form a set of edge connection weights for random walk calculation;
[0066] Using the set of edge connection weights and the seed points of the high-colored region and the low-colored region as input conditions, random walk calculations are performed at three spatial scales: the original resolution, half resolution, and quarter resolution, respectively, to obtain the corresponding three random walk probability maps.
[0067] The three random walk probability maps are weighted and fused according to a preset fusion ratio to generate a fused probability map;
[0068] Based on the fusion probability map, pixel attribution is determined for all pixels in the graph structure, and the initial segmentation result of the colored region is generated based on the probability value of the pixel.
[0069] Using the initial segmentation result and the fusion probability map as input, the boundary refinement process is performed on the initial segmentation result based on the probability gradient change in the fusion probability map to generate the final segmentation result of the colored region;
[0070] Based on the final segmentation result, a stained region annotation output is generated. The annotation output includes mask data, region contours or polygon boundaries, which are output as the automatic annotation result of the stained image.
[0071] In this embodiment, the generation of the initial graph structure includes:
[0072] After acquiring the stained image to be processed, all pixels in the stained image are scanned point by point. Based on the horizontal and vertical positions of each pixel in the two-dimensional coordinates, the pixels above, below, left, and right that maintain direct spatial contact with the pixel under the condition of single-step spatial displacement are determined. Each pixel is combined with its corresponding pixels above, below, left, and right to form adjacent pixel pairs, and all adjacent pixel pairs constitute a candidate set of edges for constructing the graph structure.
[0073] All pixels in the stained image are used as nodes of the graph structure, and all adjacent pixel pairs are used as edges between nodes. All adjacent pixel pairs are added to the graph structure in an edge-by-edge manner so that the graph structure completely contains all nodes and all edges.
[0074] For each edge in the graph structure consisting of adjacent pixel pairs, obtain the color intensity of the two pixels, perform an absolute difference operation on the color intensity of the two pixels, use the absolute difference as the base value of the initial edge connection weight corresponding to the edge, and generate the initial edge connection weight of the edge according to the preset monotonic mapping method, so that the adjacent pixel pairs with closer color intensities correspond to larger initial edge connection weights, and the adjacent pixel pairs with larger color intensity differences correspond to smaller initial edge connection weights.
[0075] After generating initial edge connection weights for all edges in the graph structure, all pixels, all edges, and all initial edge connection weights in the graph structure are combined to form the initial graph structure.
[0076] In this embodiment, the generation of the initial constraints includes:
[0077] After acquiring the stained image, a stained intensity statistical analysis is performed on the color intensity of all pixels in the stained image. The color intensity of all pixels is accumulated according to the frequency of the numerical value to generate a stained intensity histogram to represent the color intensity distribution.
[0078] Peak value determination is performed on the position with the highest frequency in the staining intensity histogram;
[0079] A color intensity threshold is generated based on the position of the peak in the color intensity histogram. The color intensity of all pixels in the color image is divided according to the color intensity threshold. Pixels with color intensity not less than the color intensity threshold are labeled as pixels with high color attributes, and pixels with color intensity less than the color intensity threshold are labeled as pixels with low color attributes.
[0080] Based on high-coloring-attribute pixels and low-coloring-attribute pixels, pixels with high-coloring-attribute pixels are designated as high-coloring-region seed points and pixels with low-coloring-attribute pixels are designated as low-coloring-region seed points in the graph structure, so that all high-coloring-region seed points and all low-coloring-region seed points in the graph structure are clearly marked.
[0081] The specific steps for designating high-staining and low-staining region seed points include: reading the corresponding staining intensity value of each pixel in the graph structure, marking pixels with staining intensity values not less than the staining intensity threshold as high-staining region seed points in the graph structure, and marking pixels with staining intensity values less than the staining intensity threshold as low-staining region seed points in the graph structure, so that each pixel forms a high-staining or low-staining region seed point according to its staining intensity value.
[0082] The seed points of all high-color regions and all low-color regions are combined according to the order of nodes in the graph structure to form the initial constraints for the random walk computation.
[0083] In this embodiment, the generation of the edge connection weight set includes:
[0084] Perform pairwise processing on all adjacent pixel pairs in the initial image structure. For each adjacent pixel pair, read the color intensity of the two pixels in the stained image and calculate the color gradient of the adjacent pixel pair based on the numerical change of the color intensity of the two pixels.
[0085] Based on the color gradient, the initial edge connection weights of each edge in the initial graph structure composed of adjacent pixel pairs are adjusted edge by edge. The initial edge connection weights of adjacent pixel pairs with smaller color gradients are increased, and the initial edge connection weights of adjacent pixel pairs with larger color gradients are decreased, so that the initial edge connection weights of each edge can reflect the color gradient changes of its adjacent pixel pairs after adjustment.
[0086] The process of adjusting the initial edge connection weights involves: reading the color gradient value of each pair of adjacent pixels in the initial graph structure; associating the color gradient value with the initial edge connection weights corresponding to the adjacent pixel pair; updating the initial edge connection weights according to the color gradient value, so that the edge connection weights corresponding to adjacent pixel pairs with larger color gradient values are adjusted in the direction representing larger pixel differences, and the edge connection weights corresponding to adjacent pixel pairs with smaller color gradient values are adjusted in the direction representing smaller pixel differences; after updating the edge connection weights of all adjacent pixel pairs, forming a set of edge connection weights for random walk calculation, so that each edge in the graph structure has edge connection weights adjusted based on the color gradient.
[0087] After adjusting all the initial edge connection weights, the original correspondence between all the adjusted initial edge connection weights and all adjacent pixel pairs in the initial graph structure is maintained, so that each edge composed of adjacent pixel pairs has an adjusted initial edge connection weight that matches its color gradient.
[0088] After adjusting all the initial edge connection weights, combine all the adjusted initial edge connection weights to form a set of edge connection weights for random walk computation.
[0089] In this embodiment, the generation of the three random walk probability maps includes:
[0090] The set of edge connection weights and the seed points of high-coloring regions and low-coloring regions are added as input conditions to the random walk calculation process. The graph structure at the original resolution spatial scale is constructed, and random walk calculation is performed on the graph structure at the original resolution to generate the first random walk probability graph corresponding to the original resolution.
[0091] The graph structure at the original resolution is scaled down to a half-resolution spatial scale to form a graph structure at half resolution. At this half-resolution spatial scale, the set of edge connection weights and the seed points of high-coloring regions and low-coloring regions are used as input conditions to perform random walk calculations on the graph structure at half resolution, generating a second random walk probability graph corresponding to the half resolution.
[0092] The graph structure at half resolution is further reduced to a quarter resolution spatial scale to form a quarter resolution graph structure. At this quarter resolution spatial scale, the set of edge connection weights and the seed points of high-colored and low-colored regions are used as input conditions to perform random walk calculations on the quarter resolution graph structure, generating a third random walk probability graph corresponding to the quarter resolution.
[0093] After generating the first, second, and third random walk probability maps, these three maps are used as the input probability map set for performing the fusion process, providing complete multi-scale random walk calculation results for generating the fused probability map.
[0094] In this embodiment, the generation of the fusion probability map includes:
[0095] The three random walk probability maps are used as the input probability map set for weighted fusion, while maintaining the one-to-one correspondence between the three random walk probability maps at all pixel positions;
[0096] The probability values of each corresponding pixel position in the three random walk probability maps are weighted according to the preset fusion ratio. The probability values of the three random walk probability maps at the same pixel position are added together according to the preset fusion ratio to generate the fusion probability value of that pixel position.
[0097] The generation of the fusion probability value specifically includes: performing pixel-by-pixel processing on the probability values of all corresponding pixel positions in the three random walk probability maps; reading the probability values of the first, second, and third random walk probability maps at each corresponding pixel position; and performing weighted processing on the three probability values according to a preset fusion ratio. The preset fusion ratio consists of three proportional values set for the first, second, and third random walk probability maps respectively. These three proportional values characterize the relative contribution of the three random walk probability maps in the weighted processing and preserve the... The process is as follows: At each corresponding pixel position, the probability values of the first random walk probability map are weighted according to the first ratio in the preset fusion ratio, the probability values of the second random walk probability map are weighted according to the second ratio in the preset fusion ratio, and the probability values of the third random walk probability map are weighted according to the third ratio in the preset fusion ratio. The three weighted probability values are then added together to generate the fusion probability value corresponding to that pixel position. The above weighting process is repeated for all pixel positions so that all pixel positions form a set of fusion probability values corresponding to the three preset fusion ratios, thereby constituting the complete fusion probability value required for the fusion probability map.
[0098] After generating the fusion probability values for all pixel positions, the fusion probability values are combined according to their corresponding pixel positions to form a fusion probability map, so that the fusion probability map contains the fusion probability values for all pixel positions.
[0099] In this embodiment, the formation of the initial segmentation result includes:
[0100] The fused probability map is used as input for pixel attribution determination. The probability values of all pixel positions in the fused probability map are read pixel by pixel, so that the probability value of each pixel position can be used as the basis for determining pixel attribution in the graph structure.
[0101] Perform pixel attribution determination for each pixel in the graph structure. At each pixel position, the attribution determination is made based on the corresponding probability value in the fused probability map. Pixels whose probability values meet the preset attribution conditions are determined to belong to the stained region, and pixels whose probability values do not meet the preset attribution conditions are determined not to belong to the stained region, so that each pixel has a clear attribution determination result.
[0102] All pixels identified as belonging to the stained region are combined according to their positions in the graph structure to form the initial segmentation result of the stained region, so that the initial segmentation result of the stained region is completely composed of pixels determined by pixel ownership.
[0103] In this embodiment, the generation of the final segmentation result includes:
[0104] The initial segmentation result and the fusion probability map are used as input data for boundary refinement. The probability values of all pixel positions in the fusion probability map are read pixel by pixel, so that the probability value of each pixel position can be used to determine the probability gradient change of that pixel position.
[0105] Perform pixel-by-pixel probability gradient change calculation on the fused probability map. At each pixel position, determine the probability gradient change of that pixel position based on the probability value change between adjacent pixel positions, so that each pixel position has corresponding probability gradient change data.
[0106] The initial segmentation result is subjected to pixel-by-pixel boundary refinement. At each pixel position, the boundary of the corresponding pixel in the initial segmentation result is adjusted according to the probability gradient change in the fusion probability map. The boundary position of the pixel in the position of significant probability gradient change is adjusted so that the boundary position in the initial segmentation result is consistent with the probability gradient change.
[0107] The boundary refinement process specifically includes: after obtaining the probability gradient changes of all pixel positions in the fusion probability map, reading the segmentation state of each pixel in the initial segmentation result and simultaneously reading the probability gradient change value of the corresponding pixel position in the fusion probability map; after completing the pixel-by-pixel reading, performing boundary adjustment processing on each pixel in the initial segmentation result, determining whether the pixel is at the boundary position that needs adjustment based on its corresponding probability gradient change value, shifting the boundary position of pixels with significant probability gradient changes according to the direction of probability gradient change, and maintaining the original segmentation state of pixels with insignificant probability gradient changes.
[0108] The refined pixels are combined to form the final segmentation result of the stained region, so that the final segmentation result of the stained region has continuity and accuracy, and the final segmentation result of the stained region is output.
[0109] In this embodiment, the generation of the automatic annotation results includes:
[0110] The final segmentation result of the stained region is used as the input data for generating the stained region annotation output. The positional relationship of all pixels in the final segmentation result is read pixel by pixel, so that the segmentation state of each pixel can be used as the basic data for generating mask data, region contour or polygon boundary.
[0111] Based on the segmentation status of all pixels in the final segmentation result, mask data is generated. All pixels that are determined to belong to the stained area are marked in the mask data so that the mask data can completely represent the location range of the stained area.
[0112] The region contour is extracted based on the spatial connection relationship of continuous pixels in the mask data, so that the region contour can reflect the boundary shape of the stained region in two-dimensional space.
[0113] Based on the positional relationship of pixel boundaries in the region outline, a polygonal boundary is generated, so that the polygonal boundary can record the overall boundary shape of the colored region in a polygonal structure.
[0114] The mask data, region contours, or polygon boundaries are combined to form the stained region annotation output, which is then output as the automatic annotation result of the stained image.
[0115] Example 1:
[0116] To verify the feasibility of this invention in practice, it was applied to the digital pathology slide analysis work of the pathology department of a tertiary hospital in a certain city of a province. This hospital extensively uses HE staining, specific antibody staining, and various high-contrast or low-contrast histological staining methods in its daily pathological diagnosis, generating a large number of digital slides with significant variations in staining, including uneven dye distribution, obvious color gradations, local staining spillover, and blurred tissue outlines. Pathologists typically need to manually select stained areas under a high-power microscope or in a digital pathology system for subsequent structural analysis or region statistics. However, manual selection is time-consuming, has high repetition rates, and suffers from inconsistent labeling. Early attempts to use traditional segmentation algorithms, relying on fixed thresholds or simple region growth strategies, were prone to boundary breaks or erroneous region expansion when encountering dye diffusion, background noise, or complex tissue structures. Random walk segmentation, on the other hand, faces the limitation of requiring pre-selection of seed points manually, making automated processing difficult to implement. Furthermore, differences in seed point selection among different physicians can lead to inconsistent segmentation results.
[0117] In the aforementioned practical application environment, the method of this invention was deployed to the digital slide processing system of a pathology department for trial operation on stained images from different patient samples from the same batch. The method first automatically reads the full-frame stained image generated by the medical institution's scanning equipment. By analyzing the positional relationships of all pixels in the image, a graph structure for subsequent processing is constructed, and initial edge connection weights are generated for each pair of adjacent pixels without manual intervention. This process avoids the need for manually configuring adjacency relationships or manually selecting structural parameters, making the processing more stable and consistent. In real-world scenarios, pathological slides exhibit significant irregularities in pixel differences due to imaging variations and varying color intensities. However, this method, by establishing edge connection weights based on pixel value differences, enables the entire graph structure to accurately represent the color relationships of the actual stained areas.
[0118] In field applications, this invention utilizes staining intensity information from a large number of slide images to generate staining intensity histograms and further automatically determines staining intensity thresholds. Because these images exhibit dye buildup and discontinuous staining gradients, manually setting thresholds often leads to inconsistencies between different batches of images. This invention, through automatic peak analysis, adaptively determines the threshold within each image, thereby automatically generating seed points for high-staining and low-staining regions. Addressing the high workload of clinical pathology departments, this invention eliminates the need for manual seed point selection in this step, enabling continuous processing of slide data by the system without relying on interactive input from pathologists.
[0119] In the trial operation environment of this medical institution, pathological images often have practical problems such as complex tissue layers and different local staining conditions. This invention calculates the color gradient between adjacent pixels and adjusts the initial edge connection weights so that the edge connection weights can better match the changes in the actual staining boundaries. For example, in areas where staining changes rapidly around the cell nucleus, this invention can automatically reduce the connection weight of the edge, while maintaining a higher connection weight in continuously stained background areas, so that the generated graph structure can stably support subsequent segmentation processing.
[0120] In further processing, this invention performs random walk calculations at three spatial scales: original resolution, half-resolution, and quarter-resolution, thereby obtaining three random walk probability maps with different analytical characteristics. During hospital applications, multi-scale processing effectively reduces segmentation offset problems caused by local blurring or over-staining, enabling the system to balance global structure and local details at different scales. Subsequently, the three probability maps are weighted and fused according to a preset ratio to generate a fused probability map, which significantly enhances the stability of the fused probability map when processing high-noise stained regions.
[0121] During automatic annotation, a fused probability map is used to determine pixel affiliation, enabling the system to automatically identify whether each pixel belongs to a stained region. In this step, traditional methods used in pathology departments, due to fixed thresholds or localized differences, are prone to misidentifying intercellular spaces as stained regions or missing areas with significant variations in dye concentration. This invention, by fusing multi-scale information, makes the initial segmentation results more closely resemble the actual tissue structure. Subsequently, this invention refines the boundaries of the initial segmentation results based on the probability gradient changes of the fused probability map, making the boundaries of stained regions more accurate in complex tissue structures. Especially in highly sensitive areas such as around cell nuclei and glandular structures, this invention effectively avoids boundary misalignment, jaggedness, or breakage.
[0122] Throughout the trial period, this invention ultimately generates mask data, region contours, or polygon boundaries for the stained areas, and automatically annotates them for digital slide analysis. Pathologists can directly use these annotation results for subsequent image measurements, region statistics, or further automated analysis tasks. The automatic annotation capability of this invention significantly reduces the time spent on manual selection, minimizes operational differences between physicians, and maintains higher consistency in the analysis of samples from the same batch. Furthermore, because this invention can complete stained area annotation without requiring manual input of seed points, the system can process large-scale images in batches, improving the overall efficiency of the digital pathology workflow.
[0123] Through continuous application in this medical institution over a period of time, the present invention has achieved significant improvements in solving problems such as unstable staining region segmentation, blurred boundaries, and strong dependence on manual input, verifying the effectiveness and feasibility of the present invention in actual pathological business scenarios. The method of the present invention exhibits good adaptability under different staining methods, different tissue types, and different image quality conditions, providing a reliable technical foundation for large-scale automated processing of pathological images.
[0124] Table 1. Performance comparison between image segmentation-based automatic region annotation method and traditional methods.
[0125] method Boundary accuracy (%) Regional consistency (%) Processing time (seconds) Dependence on human resources Traditional threshold segmentation 82.3 78.9 2.4 The threshold needs to be manually adjusted. Region Growing Algorithm 85.1 81.4 3.1 The growth point needs to be set manually. Traditional random walk 88.7 84.2 5.6 Artificial seed points are needed Method of the present invention 94.8 92.6 4.3 No manual input required
[0126] As shown in Table 1, the method of this invention significantly outperforms traditional methods in several key performance indicators. Regarding boundary accuracy, the method of this invention achieves 94.8%, significantly higher than the traditional threshold segmentation (82.3%), region growing (85.1%), and traditional random walk (88.7%). This is mainly due to the color gradient weight adjustment and multi-scale random walk strategy introduced in this invention, enabling the model to more accurately locate actual boundaries when facing dye diffusion or blurred boundary regions. In terms of region consistency, the method of this invention achieves 92.6%, a significant improvement compared to other methods, indicating that it can maintain good region integrity even under conditions of uneven staining and complex tissue structures. Regarding processing time, although the method of this invention is slightly longer than basic threshold segmentation, it is significantly faster than traditional random walk methods. This is mainly attributed to the automatic seed point generation reducing the time cost of manual input and repeated attempts. Finally, this invention does not rely on manual input of seed points, while traditional methods all require varying degrees of human intervention. This gives the invention a significant efficiency and consistency advantage in large-scale stained image processing tasks.
[0127] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. An automatic labeling method of a staining region based on image segmentation, characterized by, The method comprises the following steps: obtaining a to-be-processed stained image, determining adjacent pixels of each pixel according to the positional relationship of the pixels in the two-dimensional space, and generating corresponding initial edge connection weights according to the pixel value difference of the adjacent pixels; performing a staining intensity statistical analysis on the stained image to obtain a staining intensity histogram, determining a staining intensity threshold value based on the peak value of the staining intensity histogram, and automatically generating high-staining region seed points and low-staining region seed points in the graph structure using the staining intensity threshold value; performing color gradient calculation on each pair of adjacent pixels in the graph structure, adjusting the initial edge connection weights according to the color gradient, and forming a set of edge connection weights; performing random walk calculation to obtain three random walk probability maps; performing weighted fusion on the three random walk probability maps according to the fusion ratio to generate a fusion probability map; performing pixel attribution determination on all pixels in the graph structure according to the fusion probability map, and generating an initial segmentation result of the staining region according to the probability value corresponding to the pixel; performing boundary refinement processing on the initial segmentation result according to the probability gradient change in the fusion probability map to generate a final segmentation result of the staining region; generating a staining region label output based on the final segmentation result as an automatic labeling result of the stained image for output.
2. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The generation of the initial graph structure comprises: after obtaining the to-be-processed stained image, performing point-by-point scanning on all pixels in the stained image, determining the upper pixel, the lower pixel, the left pixel and the right pixel that maintain direct spatial contact with the pixel under the condition of single-step spatial displacement according to the horizontal position and the vertical position of each pixel in the two-dimensional coordinates, combining each pixel with its corresponding upper pixel, lower pixel, left pixel and right pixel to form an adjacent pixel pair, and constructing a candidate set by combining all adjacent pixel pairs; adding all adjacent pixel pairs to the graph structure as edges between nodes according to the edge-by-edge addition mode; obtaining the color intensity of the two pixels of each edge composed of adjacent pixel pairs in the graph structure, performing absolute difference value operation on the color intensity of the two pixels, taking the absolute difference value as the basis value of the initial edge connection weight of the edge, and generating the initial edge connection weight of the edge according to a preset monotonic mapping mode; after generating the initial edge connection weight for all edges in the graph structure, combining all pixels, all edges and all initial edge connection weights in the graph structure to form an initial graph structure.
3. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The generation of the initial constraint condition comprises: after obtaining the stained image, performing staining intensity statistical analysis on the color intensity of all pixels in the stained image, accumulating the color intensity of all pixels according to the value size to generate a staining intensity histogram; performing peak value determination operation on the position with the highest frequency in the staining intensity histogram; generating a staining intensity threshold value according to the position of the peak value in the staining intensity histogram, and performing intensity division on the color intensity of all pixels in the stained image using the staining intensity threshold value, marking the pixels with color intensity not less than the staining intensity threshold value as pixels with high staining attribute, and marking the pixels with color intensity less than the staining intensity threshold value as pixels with low staining attribute; According to the high dyeing attribute pixels and the low dyeing attribute pixels, the pixels with the high dyeing attribute are designated as high dyeing region seed points and the pixels with the low dyeing attribute are designated as low dyeing region seed points in the graph structure one by one; All the high dyeing region seed points and all the low dyeing region seed points are combined as initial constraint conditions for random walk calculation according to the arrangement order of nodes in the graph structure.
4. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The generation of the edge connection weight set comprises: pair-by-pair processing is performed on all adjacent pixel pairs in the initial graph structure, the color intensity of two pixels in each adjacent pixel pair in the dyeing image is read respectively, and the color gradient of the adjacent pixel pair is calculated according to the numerical change of the color intensity of the two pixels; each initial edge connection weight formed by an adjacent pixel pair in the initial graph structure is adjusted edge by edge according to the color gradient; after the adjustment of all the initial edge connection weights is completed, all the adjusted initial edge connection weights maintain the original corresponding relationship with all the adjacent pixel pairs in the initial graph structure; after the adjustment of all the initial edge connection weights is completed, all the adjusted initial edge connection weights are combined to form the edge connection weight set.
5. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The generation of the three random walk probability maps comprises: the edge connection weight set and the high dyeing region seed points and the low dyeing region seed points are taken as input conditions for the random walk calculation process, an original resolution graph structure is constructed in the original resolution space scale, and random walk calculation is performed on the graph structure in the original resolution to generate a first random walk probability map corresponding to the original resolution; the graph structure in the original resolution is reduced to a half resolution space scale to form a graph structure in the half resolution, and the edge connection weight set and the high dyeing region seed points and the low dyeing region seed points are continued to be taken as input conditions for the random walk calculation on the graph structure in the half resolution to generate a second random walk probability map corresponding to the half resolution; the graph structure in the half resolution is further reduced to a quarter resolution space scale to form a graph structure in the quarter resolution, and the edge connection weight set and the high dyeing region seed points and the low dyeing region seed points are continued to be taken as input conditions for the random walk calculation on the graph structure in the quarter resolution to generate a third random walk probability map corresponding to the quarter resolution; after the first random walk probability map, the second random walk probability map and the third random walk probability map are generated, the three are taken as an input probability map set for performing fusion processing.
6. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The generation of the fusion probability map comprises: the three random walk probability maps are taken as an input probability map set for weighted fusion, and the one-to-one correspondence relationship of the three random walk probability maps at all pixel positions is maintained; weighted processing is performed on the probability values of each corresponding pixel position in the three random walk probability maps according to a preset fusion ratio, the probability values of the same pixel position in the three random walk probability maps are added respectively according to the preset fusion ratio to generate a fusion probability value of the pixel position; and the fusion probability map is generated by taking the fusion probability value of each pixel position as the probability value of the pixel position in the fusion probability map. After the fusion probability values of all pixel positions are generated, all the fusion probability values are combined according to their corresponding pixel positions to form a fusion probability map.
7. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The forming of the initial segmentation result comprises: The fusion probability map is taken as input of pixel attribution determination, and the probability values of all pixel positions in the fusion probability map are read pixel by pixel; The pixel attribution determination is performed on each pixel in the graph structure, and attribution judgment is made at each pixel position according to the corresponding probability value in the fusion probability map. The pixel whose probability value meets the preset attribution condition is determined to belong to the stained region, and the pixel whose probability value does not meet the preset attribution condition is determined not to belong to the stained region; All pixels determined to belong to the stained region are combined according to their positions in the graph structure to form the initial segmentation result of the stained region.
8. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The generating of the final segmentation result comprises: The initial segmentation result and the fusion probability map are taken as input data of boundary refinement processing, and the probability values of all pixel positions in the fusion probability map are read pixel by pixel; The pixel-by-pixel probability gradient change calculation is performed on the fusion probability map, and the probability gradient change of each pixel position is determined according to the probability value change between adjacent pixel positions; The pixel-by-pixel boundary refinement processing is performed on the initial segmentation result, and the boundary of the corresponding pixel in the initial segmentation result is adjusted according to the probability gradient change in the fusion probability map at each pixel position. The boundary position of the pixel at a position with significant probability gradient change is adjusted; The pixels after refinement processing are combined to form the final segmentation result of the stained region, so that the final segmentation result of the stained region has continuity and accuracy, and the final segmentation result of the stained region is output.
9. The automatic labeling method of a staining region based on image segmentation according to claim 1, characterized in that, The generating of the automatic labeling result comprises: The final segmentation result of the stained region is taken as input data for generating the stained region labeling output, and the positional relationship of all pixels in the final segmentation result is read pixel by pixel; The mask data is generated according to the segmentation state of all pixels in the final segmentation result, and all pixels determined to belong to the stained region are marked in the mask data; The region contour is extracted according to the spatial connection relationship of the continuous pixels in the mask data; The polygon boundary is generated according to the positional relationship of the pixel boundaries in the region contour; The mask data, the region contour or the polygon boundary are combined to form the stained region labeling output, and the stained region labeling output is output as the automatic labeling result of the stained image.
Citation Information
Patent Citations
Automatic division method for pulmonary parenchyma of CT image
CN104992445A
Roof segmentation method, system and device based on multi-scale three-dimensional prior information
CN109215049A
A SegNet remote sensing image semantic segmentation method combined with random walk
CN109409240A
High-resolution image target extraction method based on extended random walk and GIS prior
CN114842352A