Image segmentation methods and systems
By constructing local structural feature regions of an image and combining them with an adaptive region growing and constrained splitting segmentation method, the problem of difficulty in simultaneously considering the relationship between pixels and the continuity of grayscale changes in existing image segmentation methods is solved. This achieves stable and controllable image segmentation and improves the accuracy and reliability of the segmentation results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DONGGUAN PEOPLES HOSPITAL
- Filing Date
- 2026-01-16
- Publication Date
- 2026-06-02
AI Technical Summary
Existing image segmentation methods struggle to simultaneously consider both the spatial adjacency of pixels and the continuity of grayscale changes, leading to oversegmentation or undersegmentation. Furthermore, the lack of constraints on the overall structural distribution results in insufficient global structural consistency and coarse boundary processing, impacting the accuracy and reliability of the segmentation results.
Based on the regional association mechanism of local structural features in the image, the spatial adjacency relationship and grayscale change continuity between pixels are extracted to construct local structural feature regions. A segmentation process combining adaptive region growth and constrained splitting is performed, and boundary correction is carried out to ensure the consistency of the segmentation results in terms of structural features and spatial continuity.
It improves the stability and controllability of image segmentation, reduces the impact of noise, avoids excessive merging or disordered splitting, enhances the accuracy and reliability of segmentation results, and ensures the stable performance of segmentation boundaries.
Smart Images

Figure CN122134752A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image segmentation technology, and more specifically, to an image segmentation method and system. Background Technology
[0002] Image segmentation is a fundamental processing step in image analysis and computer vision. Its purpose is to divide an image into several semantically or structurally consistent regions based on the spatial distribution characteristics of pixels and information such as grayscale and texture. This provides reliable basic data for subsequent target recognition, feature extraction, quantitative analysis, and decision processing. In application scenarios such as remote sensing image analysis, medical image processing, industrial inspection, and intelligent sensing, the accuracy and structural consistency of image segmentation results directly affect the overall system's processing performance and application value.
[0003] However, existing image segmentation methods often rely on single features or local statistical information for region division, such as thresholding, edge detection, or simple region growing methods. These methods struggle to simultaneously consider the spatial adjacency of pixels and the continuity of grayscale variations, easily leading to oversegmentation or undersegmentation in images with complex structures or blurred target boundaries. Furthermore, some existing methods lack constraints on the overall structural distribution during the region merging stage, relying solely on local judgments for region aggregation. This results in insufficient global structural consistency in the segmentation results, unstable boundaries between regions, and an inability to accurately reflect the spatial morphology of the real target. In addition, traditional methods employ relatively crude boundary processing techniques after segmentation, failing to effectively correct boundary shifts caused by noise or local structural discontinuities, thus affecting the accuracy and reliability of the final segmentation results. Therefore, achieving stable and controllable image segmentation based on regional association mechanisms derived from local structural features has become a significant challenge for the industry. Summary of the Invention
[0004] This application provides an image segmentation method and system that can achieve stable and controllable segmentation of images based on the regional association mechanism of local structural features in the image.
[0005] In a first aspect, this application provides an image segmentation method, comprising the following steps: Perform basic preprocessing on the image to be processed to obtain initial image data with consistent structure; The spatial adjacency relationship and grayscale change continuity between pixels are extracted from the initial image data, and the local structural feature region of the image to be processed is constructed based on the extracted spatial adjacency relationship and grayscale change continuity. Perform regional association analysis on all local structural feature regions, and determine the regional aggregation value based on the comprehensive structural similarity between local structural feature regions that are adjacent in space. The region aggregation value is used to determine the region association map that reflects the overall structural distribution of the image to be processed. Based on the region association map, a segmentation process combining adaptive region growing and constrained splitting is performed to ensure that pixels in the same target region maintain consistency in structural features and spatial continuity. Boundary correction is performed on each segmented region to obtain the segmentation result of the image to be processed.
[0006] In conjunction with the first aspect, in one possible implementation, basic preprocessing of the image to be processed to obtain initial image data with consistent structure specifically includes: Adjust the raw data of the image to be processed to the preset image size; Convert the image data to a preset color space after unifying the size; Image quality enhancement processing is performed on the image data after color space conversion to obtain initial image data with consistent structure.
[0007] In conjunction with the first aspect, in one possible implementation, extracting the spatial adjacency relationship and grayscale change continuity between pixels from the initial image data specifically includes: For each pixel in the initial image data, analyze its connectivity with pixels within a preset neighborhood range to establish spatial adjacency relationships between pixels; The intensity and direction of grayscale change of each pixel in the initial image data within a preset neighborhood range are determined, thereby determining the continuity of grayscale change in the image to be processed.
[0008] In conjunction with the first aspect, in one possible implementation, constructing the local structural feature region of the image to be processed based on the extracted spatial adjacency relationships and grayscale change continuity specifically includes: Based on the extracted spatial adjacency relationships, the spatially directly connected pixels in the image to be processed are initially divided into multiple candidate pixel sets; For each candidate pixel set, the internal structural consistency measure of each candidate pixel set is determined based on the intensity and direction of grayscale changes of its internal pixels; By merging or splitting each candidate pixel set through each internal structure consistency metric, a local structural feature region with uniform internal structure in the image to be processed is obtained.
[0009] In conjunction with the first aspect, one possible implementation involves performing regional correlation analysis on all local structural feature regions. The determination of the regional aggregation value based on the comprehensive structural similarity between spatially adjacent local structural feature regions specifically includes: Regional correlation analysis is performed on all local structural feature regions to obtain all pairs of local structural feature regions whose spatial upper boundaries are directly adjacent. The corresponding comprehensive structural similarity score is determined based on the regional feature vector of each local structural feature region pair; The region aggregation value of the corresponding local structural feature region pair is determined by the comprehensive structural similarity scores.
[0010] In conjunction with the first aspect, in one possible implementation, determining the regional association map reflecting the overall structural distribution of the image to be processed through the regional aggregation value specifically includes: Each local structural feature region is used as a graph node; Establish an undirected edge between two graph nodes corresponding to two local structural feature regions that have a direct adjacency relationship on their spatial boundaries; By using the region aggregation values corresponding to the two local structural feature regions as the weights of the undirected edge, a weighted region adjacency graph is constructed. The obtained regional adjacency map is used as a regional association map that reflects the overall structural distribution of the image to be processed.
[0011] In conjunction with the first aspect, in one possible implementation, the segmentation process combining adaptive region growth and constrained splitting based on the aforementioned region association graph specifically includes: Repeatedly search for the edge with the largest edge weight in the region association graph. If its weight exceeds a preset growth threshold, merge the two local structural feature regions connected by it into a new region and update the region association graph. After each region growth and merging, the internal structure consistency metric of the newly generated region is calculated. If it is lower than the preset splitting threshold, the merging is canceled and the edge is prohibited from being merged again. The iteration stops when the weights of all edges in the region association graph are below the growth threshold, and the final adaptively segmented region is output.
[0012] Secondly, this application provides an image segmentation system, comprising: The preprocessing module is used to perform basic preprocessing on the image to be processed, so as to obtain initial image data with consistent structure. The processing module is used to extract the spatial adjacency relationship and grayscale change continuity between pixels from the initial image data, and to construct the local structural feature region of the image to be processed based on the extracted spatial adjacency relationship and grayscale change continuity. The processing module is also used to perform regional association analysis on all local structural feature regions and determine the regional aggregation value based on the comprehensive structural similarity between local structural feature regions that are adjacent in space. The processing module is further configured to determine a region association map reflecting the overall structural distribution of the image to be processed through the region aggregation value, and based on the region association map, perform a segmentation process that combines adaptive region growing and constrained splitting to ensure that pixels within the same target region maintain consistency in structural features and spatial continuity. The execution module is used to perform boundary correction on each segmented region to obtain the segmentation result of the image to be processed.
[0013] Thirdly, this application provides a computer device, the computer device including a memory and a processor, the memory for storing a computer program, and the processor for calling and running the computer program from the memory, so that the computer device performs the above-described image segmentation method.
[0014] Fourthly, this application provides a computer-readable storage medium storing instructions or code that, when executed on a computer, cause the computer to perform the aforementioned image segmentation method.
[0015] The technical solution provided in this application has the following beneficial effects: This application's approach, firstly, constructs local structural feature regions of the image to be processed based on extracted spatial adjacency relationships and grayscale variation continuity. This transforms the originally discrete, noise-sensitive single-pixel information into local structural feature regions with internal consistency, thereby reducing erroneous segmentation caused by local abrupt changes or isolated noise from the source. Secondly, it performs regional association analysis on all local structural feature regions, determining a regional aggregation value based on the comprehensive structural similarity between spatially adjacent local structural feature regions. This aggregation value reflects the proximity of adjacent regions at the structural feature level, thus avoiding unstable judgments based solely on local grayscale or single features, effectively suppressing excessive merging or disordered splitting, and transforming segmentation decisions from local experience to controlled regional-level judgments, enhancing the interpretability and controllability of the segmentation process. Then, it determines a regional association map reflecting the overall structural distribution of the image to be processed through the regional aggregation value. This regional association map establishes connections between regions at the spatial topology and structural similarity level, which can be used during the segmentation process. By comprehensively considering overall structural consistency and avoiding global structural destruction caused by local optima, the overall stability and structural integrity of the segmentation results in complex scenes are improved. Finally, based on the aforementioned region association map, a segmentation process combining adaptive region growing and constrained splitting is executed. Region growing can smoothly expand the target range among regions with high structural similarity, while constrained splitting prevents regions with significant structural differences from being erroneously merged. This process maintains the rationality of the segmentation boundaries while dynamically adjusting the region scale, achieving bidirectional control of the segmentation behavior, ensuring that the segmentation results are neither overly fragmented nor lose their structural distinguishability. Furthermore, boundary correction is performed on each segmented region to obtain the segmentation results of the image to be processed, which can further eliminate the influence of local errors on the overall segmentation results, ensuring the stable performance of region boundaries in terms of spatial continuity and structural consistency, thereby improving the accuracy and reliability of the segmentation results. In summary, this scheme can achieve stable and controllable segmentation of images based on the region association mechanism of local structural features in the image. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is an exemplary flowchart of an image segmentation method according to some embodiments of this application; Figure 2 This is an exemplary flowchart illustrating the construction of local structural feature regions according to some embodiments of this application; Figure 3 This is an exemplary flowchart illustrating the determination of region aggregation values according to some embodiments of this application; Figure 4 This is a schematic diagram of the structure of an image segmentation system according to some embodiments of this application; Figure 5 This is a schematic diagram of the structure of a computer device for implementing an image segmentation method according to some embodiments of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] refer to Figure 1 The figure is an exemplary flowchart of an image segmentation method according to some embodiments of this application. The image segmentation method mainly includes the following steps: In step 101, basic preprocessing is performed on the image to be processed to obtain initial image data with consistent structure.
[0020] In some embodiments, basic preprocessing of the image to be processed to obtain initial image data with consistent structure can be achieved by the following steps: Adjust the raw data of the image to be processed to the preset image size; Convert the image data to a preset color space after unifying the size; Image quality enhancement processing is performed on the image data after color space conversion to obtain initial image data with consistent structure.
[0021] In practice, the original data of the image to be processed can be uniformly adjusted to a preset image size in the following way: First, read the original data of the image to be processed and obtain its original height, width and number of channels; then, set a fixed target size, such as 512 pixels × 512 pixels, as a unified spatial reference for all subsequent processing; next, use an image resampling interpolation algorithm, such as bilinear interpolation or bicubic interpolation, to scale the pixel array of the original image to the target size proportionally; when scaling, if the aspect ratio of the original image does not match the target size, add a fixed value (such as 0) for edge padding or center cropping to make the input image strictly consistent in spatial dimension, thereby outputting image data with normalized size.
[0022] In practice, converting uniformly sized image data to a preset color space can be achieved in the following way: First, determine the original color space of the uniformly sized image data, which is usually RGB space; then, to optimize subsequent analysis of image structural features, especially the continuity of grayscale changes, convert the image from the original color space to a preset color space that is more suitable for structural perception and grayscale analysis; for example, it can be converted to the LAB color space to separate luminance information (L channel) from color information (A and B channels); or, to simplify calculation, the color image can be directly converted into a single-channel grayscale image using a weighted average method; this conversion process is completed by performing linear or nonlinear mapping calculations on the channel values of each pixel, and finally outputs the converted multi-channel or single-channel image data, whose pixel values represent the distribution in the new color or luminance dimensions, for subsequent image quality enhancement.
[0023] In specific implementation, image quality enhancement processing is performed on the image data after color space conversion to obtain initial image data with consistent structure. This can be achieved in the following way: First, the image data after color space conversion is received; then, in order to suppress noise and improve feature contrast, so that different images tend to be consistent in quality, the image data is enhanced. For example, a contrast-limited adaptive histogram equalization method can be used to stretch the gray-level distribution in local areas to enhance details while limiting noise amplification; or, Gaussian filtering or median filtering can be used for smoothing and denoising, combined with global histogram equalization to standardize the overall contrast of the image. This enhancement process adjusts the brightness and contrast values pixel by pixel or region by region, and finally outputs a set of initial image data that is consistent in size, color space, and visual quality. Other methods can also be used in other embodiments, which are not limited here.
[0024] It should be noted that the preset image size in this application refers to a unified image spatial resolution standard pre-set in the image segmentation process, which is used to eliminate the differences in spatial scale between images to be processed from different sources or under different acquisition conditions; the preset color space in this application refers to a color or brightness information representation system pre-selected to optimize image structural feature analysis, which is used to transform image information into a dimension that is more conducive to highlighting the continuity of grayscale changes and structural features between pixels; the structurally consistent initial image data in this application refers to image data that has reached a standardized state in terms of spatial size, information representation dimension, and intrinsic quality.
[0025] In step 102, the spatial adjacency relationship and grayscale change continuity between pixels are extracted from the initial image data, and the local structural feature region of the image to be processed is constructed based on the extracted spatial adjacency relationship and grayscale change continuity.
[0026] In some embodiments, extracting the spatial adjacency relationship and grayscale change continuity between pixels from the initial image data can be achieved using the following steps: For each pixel in the initial image data, analyze its connectivity with pixels within a preset neighborhood range to establish spatial adjacency relationships between pixels; The intensity and direction of grayscale change of each pixel in the initial image data within a preset neighborhood range are determined, thereby determining the continuity of grayscale change in the image to be processed.
[0027] In specific implementation, for each pixel in the initial image data, its connectivity with pixels within a preset neighborhood range is analyzed. The spatial adjacency relationship between pixels can be established in the following way: First, a preset neighborhood range can be defined for each pixel in the image to be processed using a four-neighbor or eight-neighbor connection method; then, each pixel in the image to be processed is traversed, and its direct adjacency relationship with pixels in the neighborhood is checked. This relationship can be recorded by constructing an adjacency list or adjacency matrix, where each pixel is regarded as a node. If two pixels are adjacent in the defined neighborhood, for example, sharing an edge or a corner, an undirected edge is established between them, thereby forming a graph structure representing the spatial connectivity between pixels; finally, the graph structure is output as the spatial adjacency relationship between pixels. This relationship will serve as the basic topological constraint for considering pixel aggregation when constructing local structural feature regions.
[0028] In specific implementation, determining the intensity and direction of grayscale change of each pixel in the initial image data within a preset neighborhood, and thus determining the continuity of grayscale change in the image to be processed, can be achieved in the following way: First, based on the initial image data, calculate the grayscale gradient of each pixel within its preset neighborhood; specifically, convolution operations can be used, for example, using the horizontal Sobel operator, such as [-1, 0, 1; -2, 0, 2; -1, 0, 1], and the vertical Sobel operator, such as [-1, -2, -1; 0, 0, 0; 1, 2, 1], respectively with... Convolution is performed on the pixel neighborhood to obtain the gradient components of the pixel in the x and y directions. Then, the intensity of the gray-level change of the pixel, i.e., the gradient magnitude, is calculated based on these two gradient components. It can be approximated by taking the square root of the sum of the squares of the two components or by summing their absolute values. The direction of the gray-level change, i.e., the gradient direction, is calculated by the arctangent function of the two components. After traversing all pixels, a gradient magnitude map and a gradient direction map are finally obtained. These two maps together characterize the continuity of gray-level changes in the image to be processed. Other methods can also be used to determine this in other embodiments, which are not limited here.
[0029] It should be noted that, in this application, the spatial adjacency relationship between pixels refers to the topological connection relationship formed between pixels based on their spatial proximity in the initial image data with consistent structure; the grayscale change intensity and direction in this application refer to a set of feature quantities used to quantify the degree and trend of grayscale value change of a single pixel in its local neighborhood, which are used to characterize the edge, texture and other features of the local microstructure of the image; the grayscale change continuity in this application refers to the overall attribute reflecting the spatial distribution and coherence of structural features in the image to be processed, which is the key intrinsic basis for determining whether adjacent regions should be merged or kept segmented, so as to ensure that the regions that are finally segmented have similar structural features inside, while there are identifiable discontinuities in structural features between regions.
[0030] In some embodiments, reference Figure 2 As shown, this figure is an exemplary flowchart for constructing local structural feature regions in some embodiments of this application. The construction of local structural feature regions of the image to be processed based on the extracted spatial adjacency relationship and grayscale change continuity can be achieved by the following steps: Based on the extracted spatial adjacency relationships, the spatially directly connected pixels in the image to be processed are initially divided into multiple candidate pixel sets; For each candidate pixel set, the internal structural consistency measure of each candidate pixel set is determined based on the intensity and direction of grayscale changes of its internal pixels; By merging or splitting each candidate pixel set through each internal structure consistency metric, a local structural feature region with uniform internal structure in the image to be processed is obtained.
[0031] In specific implementation, the initial division of spatially directly connected pixels in the image to be processed into multiple candidate pixel sets based on the extracted spatial adjacency relationships can be achieved in the following way: First, obtain a graph structure representing the spatial adjacency relationships between pixels, where pixels are nodes and adjacency relationships are edges; then, a connected component analysis algorithm based on depth-first or breadth-first search can be used to traverse the graph structure, and all pixel nodes directly connected by adjacent edges can be grouped into the same set, thereby dividing the image to be processed into several non-overlapping connected pixel blocks; finally, each connected pixel block is used as a candidate pixel set.
[0032] In practical implementation, for each candidate pixel set, the internal structure consistency metric for determining the grayscale change intensity and direction of its internal pixels can be achieved as follows: First, for a candidate pixel set, read the grayscale change intensity and direction of all pixels within it, i.e., gradient magnitude and gradient direction; then, calculate the statistical dispersion of the gradient magnitude of all pixels within the candidate pixel set, such as variance or standard deviation, and simultaneously calculate the concentration of gradient directions, for example, by using the proportion of the main peaks in the direction histogram or by calculating the average cosine value of the direction vector; next, weight and fuse the dispersion of gradient magnitude and the concentration of gradient direction to form a comprehensive scalar value, which serves as the internal structure consistency metric for the candidate pixel set; the smaller the metric value, the more uniform the grayscale change pattern and the more consistent the structure of the pixels within the corresponding candidate pixel set, and vice versa, the more chaotic the internal structure, which will not be elaborated further here.
[0033] In practice, the process of merging or splitting candidate pixel sets using each internal structure consistency measure to obtain locally structurally homogeneous feature regions in the image to be processed can be achieved as follows: First, a preset consistency threshold is set for the internal structure consistency measure; then, all candidate pixel sets are traversed. If the internal structure consistency measure value of a set is better than, i.e., less than or equal to, the consistency threshold, it is directly marked as a qualified locally structural feature region; if its consistency measure value is worse than, i.e., greater than, the consistency threshold, it indicates that the internal structure of the region is uneven and a splitting operation needs to be performed. For example, based on significant differences in pixel gradient directions or through iterative clustering, the pixel can be split into two or more new candidate pixel sets and re-evaluated. Simultaneously, all spatially adjacent qualified regions are examined. If their internal structural consistency metrics are very close and the grayscale changes in the boundary regions are gradual, they can be merged into a larger feature region. Finally, after iterative splitting, merging, and re-evaluation, all local structural feature regions with uniform internal structures are output, and the average grayscale and gradient statistics of each region are calculated as region feature vectors. Other methods can also be used to determine this in other embodiments, which are not limited here.
[0034] It should be noted that, in this application, the candidate pixel set refers to a spatially connected group of pixels in the image to be processed; the internal structure consistency metric in this application refers to a comprehensive scalar index used to quantify the uniformity and consistency of grayscale change patterns of all pixels within a candidate pixel set, which is used to provide an objective and comparable decision basis for determining whether the candidate pixel set needs to be merged or split; the local structural feature region in this application refers to an image sub-region in the image to be processed whose internal pixels have similar grayscale change patterns and are spatially connected.
[0035] In step 103, a regional association analysis is performed on all local structural feature regions, and the regional aggregation value is determined based on the comprehensive structural similarity between local structural feature regions that are adjacent in space.
[0036] In some embodiments, reference Figure 3 As shown, this figure is an exemplary flowchart for determining the region aggregation value in some embodiments of this application. In this embodiment, region association analysis is performed on all local structural feature regions. The determination of the region aggregation value based on the comprehensive structural similarity between local structural feature regions that are adjacent at the spatial upper boundary can be achieved by the following steps: First, in step 1031, a regional correlation analysis is performed on all local structural feature regions to obtain all pairs of local structural feature regions whose spatial upper boundaries are directly adjacent. Secondly, in step 1032, the corresponding comprehensive structural similarity score is determined based on the regional feature vector of each local structural feature region pair; Finally, in step 1033, the region aggregation value of the corresponding local structural feature region pair is determined by each comprehensive structural similarity score.
[0037] In practice, performing region association analysis on all local structural feature regions to obtain all pairs of local structural feature regions with directly adjacent spatial boundaries can be achieved in the following way: First, obtain the spatial location and boundary contour information of all local structural feature regions; then, determine whether the regions are directly adjacent by calculating whether the bounding rectangles of the regions intersect or by directly detecting whether the boundary pixel sets of two regions have common pixels; if two regions share at least one continuous boundary pixel, they are determined to constitute a pair of local structural feature regions with directly adjacent spatial boundaries; after traversing all region combinations, output a list that records all pairs of local structural feature regions that satisfy this adjacency condition.
[0038] In specific implementation, determining the corresponding comprehensive structural similarity score based on the regional feature vectors of each local structural feature region pair can be achieved in the following way: First, read the regional feature vectors calculated for each local structural feature region during the construction of the local structural feature regions. These vectors contain features such as the average color, texture statistics, and gradient direction distribution of the region. Then, for a pair of local structural feature regions, calculate the histogram intersection-union ratio (HUC) for color features, the Euclidean distance for texture features, and the similarity in gradient direction distribution for both regions. Next, assign a preset weight to each of the above feature differences, and fuse these difference measures into a single normalized value through weighted summation. This value is the comprehensive structural similarity score of the local structural feature region pair. The higher the score, the more similar the two local structural feature regions are in terms of structural features, which will not be elaborated further here.
[0039] In specific implementation, the determination of the region aggregation value of the corresponding local structural feature region pair based on the comprehensive structural similarity scores can be achieved in the following way: the comprehensive structural similarity score of each local structural feature region pair can be used as the region aggregation value between the local structural feature region pairs; preferably, in order to adapt to the specific needs of subsequent segmentation algorithms, the similarity scores can be mapped to a specified numerical range through a preset linear scaling function, and the mapped result is used as the final region aggregation value; this region aggregation value is a weight value, which will be used as a core parameter to construct a region association graph with regions as nodes and aggregation values as edge weights, thereby quantitatively representing the degree of closeness to which any two adjacent regions should be merged during the segmentation process; other methods can also be used to determine this in other embodiments, which are not limited here.
[0040] It should be noted that, in this application, a pair of local structural feature regions refers to a pair consisting of two local structural feature regions that are in direct contact on the spatial boundary; the region feature vector in this application refers to multidimensional data used to digitally represent the overall statistical characteristics of a single local structural feature region in terms of visual attributes such as color, texture, and gradient; the comprehensive structural similarity score in this application refers to an index used to quantify the degree of similarity between two adjacent local structural feature regions in their overall structure; and the region aggregation value in this application refers to a weight value assigned to the connecting edge of each pair of adjacent local structural feature regions in the region association graph, which is used to quantitatively represent the priority or closeness of merging the corresponding local structural feature region pairs in the subsequent segmentation process.
[0041] In step 104, a region association map reflecting the overall structural distribution of the image to be processed is determined by the region aggregation value. Based on the region association map, a segmentation process combining adaptive region growing and constrained splitting is performed to ensure that pixels within the same target region maintain consistency in structural features and spatial continuity.
[0042] In some embodiments, determining a region association map reflecting the overall structural distribution of the image to be processed using the region aggregation value can be achieved through the following steps: Each local structural feature region is used as a graph node; Establish an undirected edge between two graph nodes corresponding to two local structural feature regions that have a direct adjacency relationship on their spatial boundaries; By using the region aggregation values corresponding to the two local structural feature regions as the weights of the undirected edge, a weighted region adjacency graph is constructed. The obtained regional adjacency map is used as a regional association map that reflects the overall structural distribution of the image to be processed.
[0043] In practice, each local structural feature region can be used as a graph node in the following way: First, assign a unique region identifier to each local structural feature region; then, initialize a graph data structure in computer memory, create each local structural feature region as a node of the graph, and store the region identifier, spatial location, and pre-calculated region feature vector as attributes in the corresponding graph node.
[0044] In practice, establishing an undirected edge between two graph nodes corresponding to two local structural feature regions with directly adjacent spatial upper boundaries can be achieved in the following way: First, read the list of all pairs of local structural feature regions with directly adjacent spatial upper boundaries; then, traverse the list, and for each pair of adjacent local structural feature regions in the list, find the corresponding two graph nodes in the graph data structure according to their region identifiers; finally, create and add an undirected edge between these two graph nodes, thereby accurately establishing a connection reflecting the spatial adjacency relationship in the graph.
[0045] In practice, the weighted region adjacency graph can be constructed by using the region aggregation value corresponding to two local structural feature regions as the weight of the undirected edge. This can be achieved as follows: while establishing an undirected edge for a pair of graph nodes with adjacent local structural feature regions, obtain the corresponding region aggregation value based on the identifier of the local structural feature region pair; then, directly assign the region aggregation value to the newly established undirected edge as the weight attribute of the edge; after assigning weights to all edges established based on adjacency relationships in the graph, a complete weighted region adjacency graph is obtained.
[0046] In specific implementation, the obtained regional adjacency graph can be used as a regional association graph reflecting the overall structural distribution of the image to be processed in the following way: the constructed weighted regional adjacency graph is used as a regional association graph reflecting the overall structural distribution of the image to be processed; this regional association graph encapsulates the core attributes of all local structural feature regions with nodes, expresses the spatial adjacency relationship between regions with edges, and quantitatively characterizes the structural similarity and merging density of any two adjacent regions with edge weights, i.e., regional aggregation values; this data structure completely and uniquely reflects the overall structural distribution of the image to be processed from local structure to global association; other methods can also be used to determine this in other embodiments, which are not limited here.
[0047] It should be noted that the region association graph in this application refers to a graph data structure that encapsulates all local structural feature regions, spatial adjacency relationships between regions, and quantitative weights of structural similarity between regions in the image to be processed. It is used as a global operation framework for the subsequent adaptive segmentation process, and transforms the visual structural information and topological relationship information of the image into a mathematical model that can be directly traversed, evaluated, and modified by the algorithm.
[0048] In some embodiments, the segmentation process combining adaptive region growth and constrained splitting based on the region association graph can be implemented using the following steps: Repeatedly search for the edge with the largest edge weight in the region association graph. If its weight exceeds a preset growth threshold, merge the two local structural feature regions connected by it into a new region and update the region association graph. After each region growth and merging, the internal structure consistency metric of the newly generated region is calculated. If it is lower than the preset splitting threshold, the merging is canceled and the edge is prohibited from being merged again. The iteration stops when the weights of all edges in the region association graph are below the growth threshold, and the final adaptively segmented region is output.
[0049] In specific implementation, the process of repeatedly searching for the edge with the largest edge weight in the region association graph, and if its weight exceeds a preset growth threshold, then merging the two local structural feature regions connected by it into a new region and updating the region association graph can be achieved in the following way: First, from the region association graph, by traversing all edges and comparing their weight attributes, i.e., region aggregation values, find the edge with the largest weight value; then, compare the largest weight with a preset growth threshold. If the weight is greater than the growth threshold, perform a merging operation, for example: merging the two graph nodes connected by this edge, i.e., the two local structural feature regions, creating a new node in the graph to represent the merged new region, and fusing the region feature vectors of the original two nodes, such as taking the average as the attribute of the new node; next, the graph structure needs to be updated, for example: deleting the original two nodes and all edges associated with them, and recalculating and establishing new edges based on the spatial adjacency relationship between the new region and the remaining regions, while recalculating the weights of these new edges based on the attributes of the new region and the attributes of the adjacent regions; finally, using the updated graph as the region association graph for the next iteration.
[0050] In specific implementation, after each region growth and merging, the internal structure consistency metric of the newly generated region is calculated. If it is lower than a preset splitting threshold, the merging is cancelled and the edge is prohibited from being merged again. This can be achieved in the following way: After completing a region merging and graph update, the internal structure consistency metric of the newly generated region is calculated immediately. The calculation method of this metric is the same as that in the aforementioned steps of constructing local structural feature regions: that is, based on the gradient magnitude and direction of all pixels contained in the new region, the weighted comprehensive value of its statistical dispersion and directional concentration is calculated. Then, the calculated internal structure consistency metric value is compared with a preset splitting threshold. If the metric value is lower than the splitting threshold, it indicates that the merging has resulted in a region with uneven internal structure, and the cancellation operation is triggered. For example, the graph state is rolled back to before the merging, and the two original nodes that were merged and their original edges and weights are restored. At the same time, the original edge that triggered the cancellation operation, that is, the edge with the largest weight found in this iteration, is marked as prohibited from merging. For example, its weight can be set to a minimum value or a special mark can be added to ensure that the edge will not be selected as a merging candidate again in subsequent iterations.
[0051] In specific implementation, when the weights of all edges in the region association graph are lower than the growth threshold, the iteration stops and the final adaptively segmented region is output. This can be achieved in the following way: before each iteration or after each update of the region association graph, check the weights of all remaining edges in the region association graph. The checking logic can be: determine whether the weight values of all edges are lower than the preset growth threshold. If this condition is met, the iterative process of adaptive region growth and constraint splitting terminates. At this time, each graph node in the region association graph corresponds to a final adaptively segmented region, and the output result is the set of regions represented by all these nodes. Other methods can also be used in other embodiments, which are not limited here.
[0052] It should be noted that the growth threshold in this application refers to a preset parameter used to determine whether two local structural feature regions are sufficiently similar to be merged. The preset growth threshold can depend on the statistical distribution of the region aggregation values. Specifically, after the initial construction of the region association map, all edge weights in the map, i.e., the statistics of the region aggregation values, such as the mean, median, or specific percentile, can be calculated. This statistic can be multiplied by an empirical coefficient between 0.5 and 0.95, and the resulting product can be preset as the growth threshold. This allows the merging standard to adapt to the global similarity level of the current image: a higher threshold is used when regions are generally similar to avoid over-merging, and a lower threshold is used to promote necessary region aggregation. This will not be elaborated further here.
[0053] Additionally, it should be noted that the splitting threshold in this application refers to a preset parameter used to determine whether the internal structure of the merged region remains uniform. Specifically, the splitting threshold can be preset by calculating the statistical value of the average or median of the internal structural consistency measure of all initial local structural feature regions, and directly setting this statistical value as the splitting threshold. This establishes a clear uniformity quality standard for the merged new region: the merger is considered valid only when the internal consistency of the new region is not lower than the average level of the initial region before the merger. This ensures that all the final segmented regions can maintain a uniform and acceptable lower limit of structural uniformity, giving the constraint splitting an objective and consistent judgment basis, which will not be elaborated further here.
[0054] In step 105, boundary correction is performed on each segmented region to obtain the segmentation result of the image to be processed.
[0055] In specific implementation, boundary correction is performed on each segmented region to obtain the segmentation result of the image to be processed. This can be achieved in the following way: First, traverse all regions that have completed adaptive segmentation and accurately extract the set of common boundary pixels between every two spatially adjacent regions. Next, for each extracted boundary, calculate the significance of the difference in gradient features between the regions on both sides of the boundary line based on the intensity and direction of grayscale change of the corresponding pixel in the initial image data with consistent structure, i.e., gradient magnitude and gradient direction. If the calculated gradient difference value is lower than the preset boundary significance threshold, the boundary is determined to be in a grayscale ambiguity zone and marked as a boundary to be corrected. Then, optimization operations are performed on all marked boundaries to be corrected. For example, morphological closing operations can be used to smooth irregular gaps, or the boundary can be locally adjusted to the side with a more significant gradient based on the gradient direction field. For boundaries with extremely insignificant gradient differences, the regions on both sides are directly merged. Finally, the final boundaries of all regions after the above optimization and merging processes are output. These boundaries together constitute the pixel-accurate segmentation result of the image to be processed. Other methods can also be used in other embodiments, which are not limited here.
[0056] It should be noted that the boundary saliency threshold in this application refers to the discrimination criterion used to distinguish between real structural edges and blurred / false boundaries. The preset boundary saliency threshold can be dynamically determined by calculating the global gradient magnitude statistics of the initial image data, such as the average value, and multiplying it by an empirical coefficient between 0.1 and 0.5, so as to establish an objective judgment standard adapted to the texture and contrast level of the image itself: boundaries with gradient differences higher than this threshold are preserved and regarded as real structural edges; boundaries lower than this threshold are regarded as blurred or false boundaries, triggering subsequent optimization or merging operations, thereby ensuring that the boundaries of the final segmentation result strictly correspond to the real structural changes in the image. This will not be elaborated further here.
[0057] Furthermore, in another aspect of this application, in some embodiments, this application provides an image segmentation system, with reference to... Figure 4 The figure is a schematic diagram of the structure of an image segmentation system according to some embodiments of this application. The image segmentation system 400 includes: a preprocessing module 401, a processing module 402, and an execution module 403, which are described below: Preprocessing module 401, in this application, is mainly used to perform basic preprocessing on the image to be processed to obtain initial image data with consistent structure. Processing module 402, in this application, is mainly used to extract the spatial adjacency relationship and grayscale change continuity between pixels from the initial image data, and to construct the local structural feature region of the image to be processed based on the extracted spatial adjacency relationship and grayscale change continuity. The processing module 402 described in this application is also used to perform regional association analysis on all local structural feature regions and determine the regional aggregation value based on the comprehensive structural similarity between local structural feature regions that are adjacent to each other on the spatial upper boundary. The processing module 402 described in this application is further configured to determine a region association map reflecting the overall structural distribution of the image to be processed through the region aggregation value, and based on the region association map, perform a segmentation process that combines adaptive region growing and constrained splitting, so that pixels in the same target region maintain consistency in structural features and spatial continuity. The execution module 403 in this application is mainly used to perform boundary correction on each segmented region to obtain the segmentation result of the image to be processed.
[0058] The foregoing has detailed examples of the image segmentation method and system provided in the embodiments of this application. It is understood that the corresponding apparatus, in order to achieve the above functions, includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0059] In some embodiments, this application also provides a computer device, the computer device including a memory and a processor, the memory for storing a computer program, and the processor for calling and running the computer program from the memory, so that the computer device performs the image segmentation method described above.
[0060] In some embodiments, reference Figure 5 The dashed lines in the figure indicate that the unit or module is optional. This figure is a schematic diagram of the structure of a computer device implementing the image segmentation method of this application. The image segmentation method in the above embodiments can be achieved through… Figure 5 The computer device 500 shown is used to implement this, and the computer device 500 includes at least one processor 501, a memory 502 and at least one communication unit 505. The computer device 500 may be a terminal device, a server or a chip.
[0061] The processor 501 can be a general-purpose processor or a special-purpose processor. For example, the processor 501 can be a central processing unit (CPU). The CPU can be used to control the computer device 500, execute software programs, and process data from the software programs. The computer device 500 may also include a communication unit 505 for inputting (receiving) and outputting (transmitting) signals.
[0062] For example, computer device 500 may be a chip, communication unit 505 may be the input and / or output circuit of the chip, or communication unit 505 may be the communication interface of the chip, and the chip may be a component of terminal device, network device or other device.
[0063] For example, computer device 500 may be a terminal device or a server, and communication unit 505 may be a transceiver of the terminal device or the server, or communication unit 505 may be a transceiver circuit of the terminal device or the server.
[0064] The computer device 500 may include one or more memories 502 storing a program 504. The program 504 can be executed by a processor 501 to generate instructions 503, causing the processor 501 to perform the methods described in the above method embodiments according to the instructions 503. Optionally, the memory 502 may also store data (such as a target audit model). Optionally, the processor 501 may also read data stored in the memory 502, which may be stored at the same storage address as the program 504, or the data may be stored at a different storage address than the program 504.
[0065] The processor 501 and memory 502 can be configured separately or integrated together, for example, integrated on the system-on-chip (SOC) of the terminal device.
[0066] It should be understood that each step of the above method embodiment can be completed by hardware logic circuits or software instructions in the processor 501. The processor 501 can be a CPU, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.
[0067] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0068] For example, in some embodiments, this application also provides a computer-readable storage medium storing instructions or code that, when executed on a computer, cause the computer to perform the image segmentation method described above.
[0069] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0070] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. An image segmentation method, characterized in that, Includes the following steps: Perform basic preprocessing on the image to be processed to obtain initial image data with consistent structure; The spatial adjacency relationship and grayscale change continuity between pixels are extracted from the initial image data, and the local structural feature region of the image to be processed is constructed based on the extracted spatial adjacency relationship and grayscale change continuity. Perform regional association analysis on all local structural feature regions, and determine the regional aggregation value based on the comprehensive structural similarity between local structural feature regions that are adjacent in space. The region aggregation value is used to determine the region association map that reflects the overall structural distribution of the image to be processed. Based on the region association map, a segmentation process combining adaptive region growing and constrained splitting is performed to ensure that pixels in the same target region maintain consistency in structural features and spatial continuity. Boundary correction is performed on each segmented region to obtain the segmentation result of the image to be processed.
2. The method as described in claim 1, characterized in that, Basic preprocessing of the image to be processed to obtain initial image data with consistent structure includes: Adjust the raw data of the image to be processed to the preset image size; Convert the image data to a preset color space after unifying the size; Image quality enhancement processing is performed on the image data after color space conversion to obtain initial image data with consistent structure.
3. The method as described in claim 1, characterized in that, Extracting the spatial adjacency relationship and grayscale continuity between pixels from the initial image data specifically includes: For each pixel in the initial image data, analyze its connectivity with pixels within a preset neighborhood range to establish spatial adjacency relationships between pixels; The intensity and direction of grayscale change of each pixel in the initial image data within a preset neighborhood range are determined, thereby determining the continuity of grayscale change in the image to be processed.
4. The method as described in claim 1, characterized in that, The local structural feature regions of the image to be processed, constructed based on the extracted spatial adjacency relationships and grayscale change continuity, specifically include: Based on the extracted spatial adjacency relationships, the spatially directly connected pixels in the image to be processed are initially divided into multiple candidate pixel sets; For each candidate pixel set, the internal structural consistency measure of each candidate pixel set is determined based on the intensity and direction of grayscale changes of its internal pixels; By merging or splitting each candidate pixel set through each internal structure consistency metric, a local structural feature region with uniform internal structure in the image to be processed is obtained.
5. The method as described in claim 1, characterized in that, A region association analysis is performed on all local structural feature regions. The region aggregation value is determined based on the comprehensive structural similarity between adjacent local structural feature regions at their spatial upper boundaries. Specifically, this includes: Regional correlation analysis is performed on all local structural feature regions to obtain all pairs of local structural feature regions whose spatial upper boundaries are directly adjacent. The corresponding comprehensive structural similarity score is determined based on the regional feature vector of each local structural feature region pair; The region aggregation value of the corresponding local structural feature region pair is determined by the comprehensive structural similarity scores.
6. The method as described in claim 1, characterized in that, Determining the region association map reflecting the overall structural distribution of the image to be processed through the region aggregation value specifically includes: Each local structural feature region is used as a graph node; Establish an undirected edge between two graph nodes corresponding to two local structural feature regions that have a direct adjacency relationship on their spatial boundaries; By using the region aggregation values corresponding to the two local structural feature regions as the weights of the undirected edge, a weighted region adjacency graph is constructed. The obtained regional adjacency map is used as a regional association map that reflects the overall structural distribution of the image to be processed.
7. The method as described in claim 1, characterized in that, Based on the aforementioned region association graph, the segmentation process combining adaptive region growth and constrained splitting specifically includes: Repeatedly search for the edge with the largest edge weight in the region association graph. If its weight exceeds a preset growth threshold, merge the two local structural feature regions connected by it into a new region and update the region association graph. After each region growth and merging, the internal structure consistency metric of the newly generated region is calculated. If it is lower than the preset splitting threshold, the merging is canceled and the edge is prohibited from being merged again. The iteration stops when the weights of all edges in the region association graph are below the growth threshold, and the final adaptively segmented region is output.
8. An image segmentation system, characterized in that, include: The preprocessing module is used to perform basic preprocessing on the image to be processed, so as to obtain initial image data with consistent structure. The processing module is used to extract the spatial adjacency relationship and grayscale change continuity between pixels from the initial image data, and to construct the local structural feature region of the image to be processed based on the extracted spatial adjacency relationship and grayscale change continuity. The processing module is also used to perform regional association analysis on all local structural feature regions and determine the regional aggregation value based on the comprehensive structural similarity between local structural feature regions that are adjacent in space. The processing module is further configured to determine a region association map reflecting the overall structural distribution of the image to be processed through the region aggregation value, and based on the region association map, perform a segmentation process that combines adaptive region growing and constrained splitting to ensure that pixels within the same target region maintain consistency in structural features and spatial continuity. The execution module is used to perform boundary correction on each segmented region to obtain the segmentation result of the image to be processed.
9. A computer device, characterized in that, The computer device includes a memory and a processor, the memory being used to store a computer program, and the processor being used to call and run the computer program from the memory, causing the computer device to perform the image segmentation method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions or code that, when executed on a computer, cause the computer to perform the image segmentation method as described in any one of claims 1 to 7.