An image structured segmentation method, system, computer device and medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NORTHWEST A & F UNIV
- Filing Date
- 2026-05-27
- Publication Date
- 2026-08-07
AI Technical Summary
[0004]为了解决现有图像分割方法无法满足下游任务对不同尺度结构表达需求的问题,本发明提供了一种图像结构化分割方法、系统、计算机设备及介质
由于本发明基于颜色相似性对初步分割结果进行合并,随后依据步进递增的几何尺度阈值序列,迭代地执行色差与外接方形尺寸双重约束下的相邻区域融合,从而能够自动生成并输出对应于不同尺度阈值的、一系列从细粒度到粗粒度的图像分割结果。下游应用可根据具体任务的需要,从该多粒度结果集合中灵活选取最适宜尺度的结构化分块方案,实现了分割粒度的动态可调和按需选择,显著提升了图像分割面对不同应用场景的实用性。
Smart Images

Figure CN122265328B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing, and specifically relates to an image structured segmentation method, system, computer equipment, and medium. Background Technology
[0002] Image segmentation, a fundamental task in computer vision and intelligent image analysis, aims to divide an input image into a set of visually or semantically consistent regions to achieve a structured and hierarchical image representation. High-quality segmentation results require accurate depiction of object boundaries and geometric shapes while maintaining good regional consistency in color and texture, thus providing a reliable intermediate representation for subsequent object recognition, semantic understanding, line drawing extraction, digital art redrawing, and structural analysis. Traditional image segmentation methods often rely on strategies such as global or local thresholding, edge detection, region growing, or color clustering. When dealing with complex colors, strong lighting variations, and high-density texture regions, these methods are prone to oversegmentation, blurred boundaries, region adhesion, or uneven color, making it difficult to simultaneously maintain consistency within regions and the integrity of the overall structure.
[0003] To address the aforementioned shortcomings, existing technologies have incorporated deep learning models for image segmentation, such as using convolutional neural networks and multi-scale feature fusion to improve segmentation accuracy in complex scenes. These methods fully utilize large-scale labeled data and deep feature representations, often achieving high pixel-level accuracy under static conditions. However, the segmentation results output by the model are fixed by the network structure and training data. Once the model is trained, the same input image typically yields only a fixed-scale, fixed-level-of-detail segmentation result, making it difficult to flexibly adjust the granularity during inference and failing to meet the needs of downstream tasks for structural representation at different scales. Summary of the Invention
[0004] To address the problem that existing image segmentation methods cannot meet the requirements of downstream tasks for structural representation at different scales, this invention provides an image structured segmentation method, system, computer equipment, and medium.
[0005] To achieve the above objectives, the present invention provides the following technical solution: An image structured segmentation method, comprising: The image to be segmented is obtained, and the image to be segmented is segmented based on pixel color and spatial proximity to obtain a preliminary segmentation result; the color blocks with color difference between adjacent color blocks in the preliminary segmentation result are merged to obtain a preliminary image merging result. Based on a preset incremental scale, the preliminary image merging results are fused with color patches to obtain image segmentation results at multiple scales. At each scale, color patches in the image segmentation results of the previous scale whose color difference is less than a preset fusion threshold and whose bounding square side length is less than the bounding square side length threshold corresponding to the current scale are fused together to obtain the image segmentation result at the current scale. The bounding square side length threshold of the current scale is greater than the bounding square side length threshold of the previous scale. The bounding square side length threshold corresponding to each scale is set by incremental step. The image segmentation result at the first scale is determined by fusion of color patches in the preliminary image merging results whose color difference is less than the preset fusion threshold and whose bounding square side length is less than the bounding square side length threshold corresponding to the current scale. The structured segmentation result of the image to be segmented is determined based on the image segmentation results at multiple scales.
[0006] Optionally, the image structured segmentation method provided by the present invention further includes: The image to be segmented is input into a pre-trained image editing model based on generative rectified flow matching to obtain a flat-painted image with compressed texture and color; the flat-painted image is then converted to the Lab color space to obtain a normalized image to be segmented.
[0007] Optionally, in the image structured segmentation method provided by the present invention, the image editing model based on generative rectified flow matching is a FLUX.1-Kontext diffusion model based on LoRA fine-tuning pre-training.
[0008] Optionally, the image structured segmentation method provided by the present invention further includes: The Quickshift algorithm divides the image to be segmented into multiple non-overlapping initial block sets, and the initial block sets determine the preliminary segmentation results.
[0009] Optionally, the image structured segmentation method provided by the present invention further includes: Calculate the CIEDE2000 color difference between adjacent initial blocks; When the CIEDE2000 color difference between adjacent initial blocks is less than the color merging threshold, the adjacent initial blocks are merged to obtain the preliminary image merging result.
[0010] Optionally, the image structured segmentation method provided by the present invention further includes: For the image segmentation results at each scale, the color difference between the color block with a pixel count less than a preset value and its neighboring color blocks is calculated. The color block is then merged into the neighboring color block with the smallest color difference and the largest pixel count to obtain the image segmentation result after the smallest block absorption at each scale. The structured segmentation result of the image to be segmented is determined by the image segmentation result after the smallest block absorption at each scale.
[0011] Optionally, the image structured segmentation method provided by the present invention further includes: The color block boundaries of the image segmentation results at multiple scales are superimposed on the image to be segmented to obtain a boundary superimposition map at multiple scales. By superimposing the color block boundaries of image segmentation results at multiple scales onto a white background, a white background comparison image at multiple scales is obtained. Pseudo-color codes are assigned to each color patch in the image segmentation results at multiple scales to obtain pseudo-color label maps at multiple scales.
[0012] The present invention also provides an image structured segmentation system, comprising: The preliminary segmentation module is used to acquire the image to be segmented, segment the image based on pixel color and spatial proximity, and obtain preliminary segmentation results; and merge color blocks in the preliminary segmentation results whose color difference between adjacent color blocks is less than a preset color merging threshold to obtain preliminary image merging results. The multi-threshold filtering module is used to perform color patch fusion on the preliminary image merging results based on a preset incremental scale to obtain image segmentation results at multiple scales. Specifically, at each scale, color patches in the image segmentation results of the previous scale whose color difference is less than a preset fusion threshold and whose bounding square side length is less than the bounding square side length threshold corresponding to the current scale are fused together to obtain the image segmentation result at the current scale. The bounding square side length threshold of the current scale is greater than the bounding square side length threshold of the previous scale. The bounding square side length threshold corresponding to each scale is set by incremental step. The image segmentation result at the first scale is determined by fusion of color patches in the preliminary image merging results whose color difference is less than the preset fusion threshold and whose bounding square side length is less than the bounding square side length threshold corresponding to the current scale. The structured segmentation module is used to determine the structured segmentation result of the image to be segmented based on the image segmentation results at multiple scales.
[0013] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement any of the steps in an image structured segmentation method.
[0014] The present invention also provides a computer-readable storage medium storing a computer program that, when loaded by a processor, can execute any step of an image structured segmentation method.
[0015] The image structured segmentation method provided by this invention has the following beneficial effects: Because this invention merges the initial segmentation results based on color similarity, and then iteratively performs adjacent region fusion under the dual constraints of color difference and circumscribed square size according to a progressively increasing geometric scale threshold sequence, it can automatically generate and output a series of image segmentation results from fine-grained to coarse-grained, corresponding to different scale thresholds. Downstream applications can flexibly select the most suitable scale of structured block segmentation scheme from this multi-granularity result set according to the needs of specific tasks, realizing dynamic adjustment and on-demand selection of segmentation granularity, significantly improving the practicality of image segmentation for different application scenarios. Attached Figure Description
[0016] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram of an image structured segmentation method provided in an embodiment of the present invention; Figure 2 This is an example of the overall image segmentation process provided in this embodiment of the invention; Figure 3 This is an example of an unprocessed raw image provided in an embodiment of the present invention; Figure 4 This is an example of a style-normalized image compressed into a flat painting style, provided as an embodiment of the present invention. Figure 5 This is an example of a boundary overlay map of the overlaid red region provided in an embodiment of the present invention; Figure 6 This is an example of a white background comparison diagram showing the outline of a structure on a white background, provided as an embodiment of the present invention. Figure 7 This is an example of a pseudo-color label image displaying each segmented region using pseudo-color encoding, provided as an embodiment of the present invention. Detailed Implementation
[0018] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0019] Traditional image segmentation methods often rely on strategies such as global or local thresholding, edge detection, region growing, or color clustering. However, these methods are susceptible to complex colors, strong lighting variations, and high-density textures, making it difficult to simultaneously maintain consistency within regions and the integrity of the overall structure. Even with preprocessing techniques like superpixel segmentation, they remain highly sensitive to original image noise, stylistic differences, and texture details, resulting in insufficient robustness when applied across different scenes and data sources. Building on this, to better reflect the human eye's perception of color differences, the CIE Lab color space and its corresponding ΔE perceptual color difference metric have been widely adopted in high-precision image analysis tasks. While this has improved upon traditional grayscale thresholding or simple clustering to some extent, it still largely falls within the traditional image processing paradigm and remains highly sensitive to lighting variations, imaging noise, and sensor imaging conditions. When scene lighting is uneven or textures are complex, these thresholding and clustering results are prone to drift. Furthermore, most methods rely on fixed or single-scale thresholds or clustering parameters, lacking the ability to adaptively adjust the fusion scale according to the image content. They also lack a systematic dynamic constraint and absorption mechanism for small blocks and noise regions generated during the segmentation process, which can easily lead to unstable structural hierarchy and label fragmentation. In multi-scale structural processing, it is difficult to simultaneously take into account the integrity of local details and the coherence of large-scale regions.
[0020] Image segmentation methods based on deep learning models struggle to respond promptly to the dynamic demands of downstream tasks for different granularities of region segmentation (coarse-medium-fine), and lack explicit, controllable multi-stage region merging and hierarchical optimization mechanisms. Furthermore, even deep models may exhibit boundary jitter and pseudo-response enhancement when faced with strong lighting variations, noise interference, or cross-device / cross-style images, indicating room for improvement in robustness across styles and domains.
[0021] In summary, traditional methods are generally sensitive to lighting, noise, and imaging conditions, while deep learning methods produce relatively fixed segmentation results that are difficult to adjust granularity flexibly during inference. To address these shortcomings, this invention considers the rapid development of generative image editing techniques such as diffusion models and flow matching, which are widely used in image inpainting, colorization, and style transfer. Generative image editing techniques perform fine-grained style shaping and content editing on images in the latent space, enabling a novel workflow where a large generative model is first used for structure-preserving color rectification before downstream segmentation tasks. Specifically, this invention normalizes the style and color domain of the input image using a large flowing diffusion model and a style adapter, mitigating instability caused by lighting and noise. Furthermore, this invention introduces a multi-stage, multi-threshold segmentation and region merging mechanism on the normalization results, explicitly generating multi-level block results from fine-grained to medium and large scales. This achieves adaptive optimization from local color consistency to global structural integrity, significantly improving the robustness, perceptual fidelity, and cross-style consistency of complex, multi-source image segmentation.
[0022] Example 1 This invention provides a structured image segmentation method, specifically as follows: Figure 1 As shown, it includes the following steps: Step 11: Obtain the image to be segmented. Segment the image based on pixel color and spatial proximity to obtain preliminary segmentation results. Merge adjacent color blocks in the preliminary segmentation results where the color difference is less than a preset color merging threshold to obtain preliminary image merging results. Furthermore, before segmenting the image based on pixel color and spatial proximity, the image to be segmented can be input into a pre-trained image editing model based on generative rectified flow matching to obtain a flat-painted image with compressed texture and color. Convert the flat-painted image to the Lab color space to obtain a normalized image to be segmented.
[0023] Among them, the image editing model based on generative rectified flow matching is the FLUX.1-Kontext diffusion model based on LoRA fine-tuning pre-training.
[0024] Specifically, such as Figure 2 As shown, taking a single color image as an example, the overall data flow of the scheme is as follows: the image to be segmented I is normalized by Kontext+LoRA to obtain a flat-style RGB image I, then color space conversion is performed to obtain a Lab image I; the Lab image I is then segmented using Quickshift superpixel segmentation to obtain a preliminary segmentation result. Preliminary segmentation results based on perceived color difference By merging the color blocks, a preliminary merging result can be obtained. Next, multi-scale threshold block filtering is performed under dual constraints of size and color difference, and the blocks are merged scale by scale. Combined with a minimum block absorption strategy, the final structured segmentation result is obtained. In addition, it can also combine the segmentation and merging of multiple stages for visual output.
[0025] For example, the image structured segmentation method provided by this invention includes two stages: streaming large model style normalization and perceptual-driven multi-threshold block-level segmentation. In the first stage, a streaming diffusion image editing large model based on generative rectified flow matching is used to perform flat-paint style normalization and color repainting on input images of arbitrary sources and styles. This compresses complex textures and style differences into a small number of stable representative colors, significantly reducing the impact of illumination changes, noise interference, and device differences on subsequent segmentation while strictly maintaining the object boundaries and structural morphology. In the second stage, on the normalized flat-painted image, Quickshift superpixel segmentation, region disjoint-set data structure modeling, CIEDE2000 ΔE perceptual color difference constraint, multi-threshold block filtering, and minimum block absorption strategy are introduced to achieve multi-scale, controllable, and structured hierarchical segmentation. The overall method significantly improves the segmentation robustness and consistency across scenes, devices, and styles while ensuring the fidelity of local structural details and boundaries.
[0026] In addressing the significant differences in illumination, noise, and style of input images and the resulting problems of uneven region granularity, texture redundancy, and excessive fragmentation, this invention first takes a color image of arbitrary source and style, for example... Figure 3 The original image input shown is based on a generative rectified flow matching image editing model. A low-rank adaptation (LoRA) fine-tuning module, pre-trained for the target scene, is inserted to perform conditional editing operations in the image latent space. This compresses complex textures affected by lighting and noise into several relatively stable flat representative colors, while strictly maintaining the target structure outline and boundary morphology. This achieves style normalization and color gamut unification, resulting in the image shown. Figure 4 The style and colors shown are normalized flat-painted images. These images are then converted to the CIE Lab color space to obtain a chromaticity representation that better matches human visual perception, providing a clean, uniform, and robust color foundation for subsequent region merging and structured segmentation based on perceived color differences.
[0027] For example, the original image I to be segmented is defined on a pixel grid. Above, represented as Then, I is used as the context image y for the Kontext image editing model, combined with a conditional vector or text c, such as "flat colorpainting style, keep structure and edges," to allow the model to learn the conditional distribution. Kontext employs a rectified flow matching paradigm, learning from noise in the latent space. The velocity field of the target image x enables the sampling process to generate structure-preserving editing results quickly and stably.
[0028] Building upon this, this invention inserts Low-Rank Adaptation modules into several key Transformer linear layers of the pre-trained Kontext diffusion model, forming a Kontext-LoRA structure. This structure, while keeping the parameters of the Kontext backbone Transformer network frozen, trains only the newly added low-rank adaptation branches, thereby significantly reducing computational and storage overhead while achieving efficient domain adaptation for this task.
[0029] Specifically, the core idea of LoRA is based on the low-rank decomposability of linear transformation weights. The weight matrix of a certain linear transformation is... This invention adds a low-rank increment term to the weight matrix. The linear mapping with LoRA at this time is shown in equation (1): (1) Among them, the low-rank increment term , and For trainable parameters, the original weights Keep frozen during training; scaling factor This is used to control the influence weight of low-rank branches in the overall output, thereby flexibly balancing the contributions of backbone features and incremental features under different levels and task complexities. Due to the rank... Typically much smaller than the feature dimension, LoRA learns domain-related feature compensations only in a low-dimensional space, significantly reducing the number of new parameters and the scale of gradient updates.
[0030] Building upon this foundation, this invention embeds a LoRA module into the Transformer backbone of the Kontext diffusion model. The Transformer module of the Kontext diffusion model is a key component for learning spatial semantics and texture patterns, consisting of a self-attention layer, a multi-head attention layer, and a feedforward network, and introducing external conditional information through an AddedKV branch. This Transformer module can organize visual semantics at multiple scales, achieving hierarchical feature modeling from local texture to global semantics. Therefore, to fully utilize the low-rank adaptation capability of LoRA, this invention inserts low-rank branches into multiple information paths within this Transformer module.
[0031] For example, this invention adds a LoRA branch to the projection matrix of the query vector (Q), key vector (K), and value vector (V) in the self-attention layer, enabling the calculation of attention weights to be finely adjusted according to the complex texture morphology and local structural differences in the image. Furthermore, this invention adds LoRA to the multi-head attention output projection layer, allowing different attention heads to perform directional compensation for domain features during fusion. Moreover, this invention embeds LoRA in the channel expansion and compression linear layers of the feedforward network to adapt to the dynamic distribution changes of features at different levels before and after nonlinear transformations. In addition, this invention adds low-rank mappings to the AddedKV branch and some normalized related linear transformations to enhance the model's flexibility in external condition fusion and feature distribution alignment.
[0032] In the self-attention path, LoRA primarily operates on the linear projection matrices of Q, K, and V, enabling the model to adaptively adjust the attention focus range within fine-grained regions. In the AddedKV channel, the introduction of LoRA enhances the model's adaptability to external conditions, allowing it to automatically adjust the attention distribution according to changes in conditions, resulting in a more robust domain representation. In the feedforward and normalization paths, LoRA's low-rank mapping helps the model finely refine the feature distribution after nonlinear activation, mitigating inter-layer feature drift and improving the stability of gradient propagation.
[0033] During LoRA training, flat-style normalized training samples are input into the model, and low-rank branch parameters are inserted into the aforementioned multiple information pathways based on the difference between the output results and the true results. The Kontext-LoRA model is optimized to produce biased editing capabilities in the direction of preserving structure and flattening texture. That is, it compresses the complex textures, lighting variations and style differences in the original image into a finite number of stable representative color clusters with almost no change to the object's boundaries and contours.
[0034] When LoRA parameter After optimization, during the inference process, based on the image to be segmented I, the conditional vector, or the text c, the flat-colored normalized image is obtained through the Kontext model with LoRA, as shown in formula (2): (2) in, This is a set of LoRA parameters. Because the rectified flow matching generation process rectifies high-frequency textures, combined with the style orientation constraints of LoRA, this invention achieves a visually flat painting effect, meaning that for most pixels... There are a small number of representative color sets. Make The set of object boundaries in the original input image The set of object boundaries after conversion to a flat-painted image They are basically consistent in geometric position, providing a clean and unified color foundation for subsequent color measurement and block-level segmentation.
[0035] Furthermore, the preliminary merge results can be determined through the following steps: Step 111: Divide the image to be segmented into multiple non-overlapping initial block sets using the Quickshift algorithm, and determine the preliminary segmentation result based on the initial block sets.
[0036] Step 112: Calculate the CIEDE2000 color difference between adjacent initial blocks.
[0037] Step 113: When the CIEDE2000 color difference between adjacent initial blocks is less than the color merging threshold, merge the adjacent initial blocks to obtain the preliminary image merging result.
[0038] Specifically, after color normalization and flat color processing to obtain a flat-colored image, in order to perform color measurement in a color space that is more in line with human visual perception, this invention converts I from the RGB space to the CIE Lab space, for example, by linearizing the RGB values to obtain linear colors. Then through The CIE XYZ spatial coordinates are obtained by linear transformation, as shown in formula (3): (3) After that, with Based on this, the formula (3) is used as a reference. Mapped to the CIE Lab space, as shown in Equations (4), (5), and (6): (4) (5) (6) in, , , L represents the reference white point tristimulus value corresponding to the CIE D65 standard illuminant, and is the normalized reference value in Lab space. * ,a * ,b * These are the lightness channel, red-green channel, and yellow-blue channel in the CIE Lab color space, used to characterize the perceived brightness and chromaticity of a pixel. For each pixel ,get This forms an image defined in Lab space. Because Lab space is more perceptually closer to the human eye's subjective experience of differences in brightness and chromaticity, all subsequent color distance measurements and region merging operations in this invention are performed within the Lab space. The above will be carried out.
[0039] This invention utilizes the color differences and spatial proximity between pixels in a flat-painted image to perform initial superpixel segmentation on the flat-painted image in Lab space using the Quickshift algorithm, resulting in fine-grained block-level partitions. By setting parameters such as the spatial kernel size, the maximum distance threshold (max_dist), and the weight ratio of color distance to spatial distance, the block scale is controlled, yielding an initial superpixel partitioning result that is simplified in color but still retains rich local structural information.
[0040] The Quickshift algorithm essentially performs density estimation and gradient ascent clustering in the joint space composed of spatial coordinates and color space. Control parameters include `kernel_size`, which corresponds to the spatial scale of the local neighborhood; a larger value results in clustering over a larger spatial range and generating larger superpixel blocks. `max_dist`, used to suppress long-distance faulty connections, limits the maximum adjacency distance of pixels that can be considered to belong to the same spatial cluster. `ratio` adjusts whether to prioritize color similarity or spatial compactness; a larger `ratio` increases the impact of color consistency on clustering. Therefore, by setting appropriate `kernel_size`, `max_dist`, and `ratio`, in... The image is divided into an initial set of non-overlapping blocks. At this point, these superpixels already have good internal color consistency in Lab space and closely adhere to the object boundaries preserved after Kontext-LoRA processing.
[0041] Building upon this foundation, the present invention can also perform topological analysis on the superpixel segmentation results to obtain a region adjacency graph. For each block, statistical features such as the number of pixels, average Lab color value, and circumscribed square boundary are calculated, forming the basic data structure for subsequent region aggregation. Then, using CIEDE2000 ΔE color difference as a perceptual measure of color similarity between regions, a region disjoint-set data structure with a versioned caching mechanism is constructed at the superpixel level to dynamically maintain the region mean, adjacency relationship, and version identifier. For adjacent regions with ΔE below a set threshold, a merging operation is performed sequentially, and the ΔE calculation results in the cache are efficiently reused and incrementally updated, thereby achieving perceptual correction that evolves synchronously with the region merging process. Leveraging the characteristic of the front-end streaming diffusion model that has already merged similar colors, this stage can further aggregate residual fragmented blocks of the same color, significantly reducing the number of small blocks with similar colors, and obtaining a preliminary homogeneous and perceptually consistent color region division, providing a stable color partitioning foundation for subsequent structured segmentation.
[0042] For example, when the initial set of regions is determined using the Quickshift algorithm... Then, adjacency relationships and statistical characteristics are constructed at the regional level. For example, for each region... , For the number of pixels, The average Lab color of the region is given by formula (7): (7) in, These represent the average brightness, average red-green channel value, and average yellow-blue channel value of region Rk(0), respectively. The side length of the circumscribed square is calculated from the minimum or maximum row and column coordinates of the region's pixels, thus representing the geometric scale of the region or color block. Simultaneously, based on the 8-neighborhood relationship of pixels, it is... Transform into a region-level undirected graph When there are pixels And when they are adjacent on the pixel grid, record .
[0043] Furthermore, in order to accurately characterize the perceived color difference between regions, this invention uses CIEDE2000 color difference. As a distance metric, let the average Lab colors of two regions i and j be respectively... , Colorimetrics as defined by the CIEDE2000 standard and As shown in formula (8): (8) Then, chromaticity correction was introduced. and correction factor Construct the modified and Calculate the brightness difference between regions i and j. Color difference and hue difference and combined with scale factor , and and chroma-hue interaction items The CIEDE2000 color difference between regions i and j is obtained. The definition is shown in formula (9): (9) in, These are weighting coefficients, and for example, all can be set to 1. This is compared to calculations based on Euclidean distance. , The perceptual nonlinearity of brightness, high chromaticity areas, and special color gamuts such as blue has been corrected to make the numerical differences more consistent with the subjective perception of the human eye, thereby meeting the measurement requirements of regional color similarity in this invention.
[0044] For example, first, a disjoint-set data structure U is constructed for each color patch. Each initial color patch obtained by the Quickshift algorithm is treated as an independent set. For each adjacent edge... The color difference between the two corresponding color blocks is determined by the CIEDE2000 color difference. That is, the color difference d between regions i and j 00 (i,j). Then, combine the color merging threshold. Perform a merge judgment when Less than or equal to At that time, regions i and j are merged in the disjoint-set structure U to obtain a new region, and the average Lab value of the new region is recalculated. The number of pixels in the new region is determined by the sum of the number of pixels in region i and region j. And determine the side length of the circumscribed square of the new region. Furthermore, to improve efficiency, this invention employs a versioned caching strategy for each pair of calculated regions. Cache it Value, when regions are merged, its representative ID or mean. When changes occur, only the relevant cached flags are invalidated, while the remaining calculation results are retained to reduce redundant calculations.
[0045] In summary, through the above processing, while maintaining the regional boundaries and structure, a large number of small, closely colored patches can be aggregated into regions with more uniform color, thus obtaining a preliminary merging result. .
[0046] Step 12: Perform color patch fusion on the preliminary image merging results based on a preset incremental scale to obtain image segmentation results at multiple scales. Specifically, at each scale, color patches in the image segmentation results of the previous scale whose color difference is less than a preset fusion threshold and whose circumscribed square side length is less than the circumscribed square side length threshold corresponding to the current scale are fused together to obtain the image segmentation result at the current scale. The circumscribed square side length threshold of the current scale is greater than the circumscribed square side length threshold of the previous scale. The circumscribed square side length threshold corresponding to each scale is set by incremental step. The image segmentation result at the first scale is determined by fusion of color patches in the preliminary image merging results whose color difference is less than the preset fusion threshold and whose circumscribed square side length is less than the circumscribed square side length threshold corresponding to the current scale.
[0047] Specifically, to improve the hierarchical nature and semantic coherence of the segmentation results in spatial structure, this invention performs region filtering and fusion layer by layer by pre-setting the range of values for the side length of the circumscribed square and a stepping strategy, with the threshold increasing progressively. First, at each scale level, regions with a circumscribed square side length less than the current geometric scale threshold and a perceptual color difference ΔE with adjacent regions less than a preset limit are selected as candidates for fusion and merged with adjacent blocks. Furthermore, the objects of region filtering and fusion at each scale are the image segmentation results obtained from the region fusion or adjacent fusion at the previous scale, and the objects of region filtering and fusion at the smallest scale are the preliminary fusion results after merging adjacent initial blocks.
[0048] For example, to further achieve structural hierarchy on a geometric scale, the present invention surrounds the side length of the circumscribed square of the region. Design a multi-threshold block filtering process, with geometrically scaled threshold sequences. Then, at each scale level Above, all regions in the current set that satisfy... The region is considered as a candidate set to be merged. For any candidate color patch k, the set of its adjacent color patches is... Internal color difference calculation As shown in formula (10): (10) and in the set of adjacent color blocks Internal color difference selection Minimum Adjacency Area As shown in formula (11): (11) Next, the color difference Minimum Adjacency Area Color difference limitation with multi-threshold stage To make a comparison, when Less than At that time, in the disjoint-set data structure U, region k is merged into... Within the set, region fusion is achieved based on both set scale and color difference constraints. After fusion, the average Lab color, bounding square side length, and pixel count of each adjacent fused color patch are redefined, along with the adjacency relationships between the color patches, to facilitate color patch merging at the next scale. As the scale increases from small to large, regions with smaller geometric scales are gradually absorbed into regions of similar color and larger area, gradually forming a hierarchical structure from fine-grained local blocks to medium and large-scale structural regions. Furthermore, this invention addresses this at each scale level. Both can output the corresponding label image. This provides multi-granular structured block results for downstream tasks. It should be emphasized that in the above-mentioned color block merging stage, the threshold for ΔE to perceive color difference, such as the color merging threshold and the preset fusion threshold, can be set by those skilled in the art based on actual needs. For example, they can be set to the same value or different values, and this invention does not impose any restrictions.
[0049] This invention employs dual constraints of geometric scale and ΔE-perceptual color difference, allowing the region scale to gradually grow from fine-grained local color patches to medium- and large-scale structural regions, achieving a hierarchical optimization process from local fragments to macroscopic structured blocks. By extracting intermediate segmentation results based on different geometric threshold levels, coarse, medium, and fine-grained structured block schemes can be obtained on the same image to meet the needs of downstream tasks for structural representation at different scales.
[0050] Step 13: Determine the structured segmentation result of the image to be segmented based on the image segmentation results at multiple scales.
[0051] The structured segmentation result can be determined through the following steps: Step 131: For the image segmentation results at each scale, calculate the color difference between the color block with a pixel count less than a preset value and its neighboring color blocks, and merge the color block into the neighboring color block with the smallest color difference and the largest pixel count to obtain the image segmentation result after the smallest block absorption at each scale. The structured segmentation result of the image to be segmented is determined by the image segmentation result after the smallest block absorption at each scale.
[0052] Specifically, considering the areas that remain after multi-threshold block filtering that are too small, isolated, or suspected of being noise, this invention introduces a minimum block absorption strategy based on pixel number constraints: for regions with fewer than the preset min_pixels_merge threshold, the ΔE value between the region and all its adjacent regions is calculated, and the region is merged into the adjacent region with the smallest ΔE and a larger number of pixels. When there are multiple candidates with the same ΔE value, they are preferentially merged into the region with a larger number of pixels, thereby effectively suppressing pseudo-segmentation and isolated block phenomena, and improving the overall region coherence and boundary continuity.
[0053] For example, the present invention can set a pixel number threshold. , number of pixels Less than the pixel count threshold The color block k is taken as the smallest block k, and the smallest block k and its adjacent set are calculated by formula (10). CIEDE2000 color difference And select color difference based on formula (11) Minimum Adjacency Area And the smallest block k is compared with the adjacent regions. Fusion achieves minimal block absorption. Among these, color difference... Minimum Adjacency Area The number of pixels contained must be greater than the number of pixels in the smallest block k; and, when the color difference... Minimum Adjacency Area When multiple regions exist, the region with the largest number of pixels is selected as the absorption target. In summary, by traversing and processing all the smallest blocks, this invention can effectively eliminate isolated small blocks and noisy regions, avoid excessive fragmentation of labels, and make the final segmentation result more coherent and natural in terms of spatial topology and visual perception.
[0054] Step 14: Overlay the color block boundaries of the image segmentation results at multiple scales onto the image to be segmented to obtain a boundary overlay map at multiple scales; overlay the color block boundaries of the image segmentation results at multiple scales onto a white background to obtain a white background comparison map at multiple scales; assign pseudo-color codes to each color block in the image segmentation results at multiple scales to obtain a pseudo-color label map at multiple scales.
[0055] Specifically, to enhance the engineering visualization capabilities and result traceability of the method, this invention can overlay and merge results onto the original image or style-normalized flat-painted image and then output and display them. Furthermore, at each key stage, this invention also integrates a multi-stage visualization output and result recording mechanism, overlaying and outputting results onto the original image or style-normalized flat-painted image.
[0056] Specifically, this invention can generate a boundary overlay map by superimposing red region boundaries onto the original image or style-normalized flat-painted image. For example, it can extract the boundaries of each region after merging at each key stage, such as the initial merging stage and the multi-scale merging stage constrained by both geometric scale and perceptual color difference. It is overlaid on the image to be segmented I or the flat-colored image I, and displayed using high-contrast colors such as red. Figure 5 This allows for a direct visual inspection of the alignment between the segmentation boundaries and the actual structure; it also enables the generation of white-background comparison images by drawing structural outlines on a white background. For example, drawing the outlines or filling results of each region on a pure white background only displays the geometric structure and topological relationships, avoiding texture interference. Figure 6 Alternatively, pseudo-color labels can be generated to display each segmented region using random or fixed pseudo-color encoding, for example, by assigning a pseudo-color code to each region. The label image is rendered as a colored block structure, making it easier to distinguish different areas and compare the block shapes at different scales. Figure 7 .
[0057] Furthermore, this invention can also output corresponding cache files and region statistics during the segmentation process, recording the region merging status and hierarchical evolution process at each stage, facilitating manual inspection, parameter tuning, experimental reproduction, and result comparison and analysis. For example, it can output the region set and adjacency graph of each stage. Statistical characteristics The region merge log is saved in structured data format such as JSON or binary cache files, and records the processes from Kontext-LoRA flat normalization, RGBLab conversion, Quickshift superpixels, etc. The complete data stream from initial merging, multi-threshold block filtering, and minimum block absorption to the final structured segmentation result yields a complete evolutionary trajectory from the initial superpixel to the multi-scale structural region. This has good interpretability and engineering practical value, providing a traceable basis for subsequent parameter tuning, experimental reproduction, and engineering integration.
[0058] Example 2 The present invention also provides an image structured segmentation system, comprising: The preliminary segmentation module is used to acquire the image to be segmented, segment the image based on pixel color and spatial proximity, and obtain preliminary segmentation results; merge color blocks in the preliminary segmentation results whose color difference between adjacent color blocks is less than a preset color merging threshold, and obtain preliminary image merging results.
[0059] The multi-threshold filtering module is used to perform color patch fusion on the preliminary image merging results based on a preset incremental scale to obtain image segmentation results at multiple scales. Specifically, at each scale, color patches in the image segmentation results of the previous scale whose color difference is less than a preset fusion threshold and whose bounding square side length is less than the bounding square side length threshold corresponding to the current scale are fused together to obtain the image segmentation result at the current scale. The bounding square side length threshold of the current scale is greater than the bounding square side length threshold of the previous scale. The bounding square side length threshold corresponding to each scale is set by incremental step. The image segmentation result at the first scale is determined by fusion of color patches in the preliminary image merging results whose color difference is less than the preset fusion threshold and whose bounding square side length is less than the bounding square side length threshold corresponding to the current scale.
[0060] The structured segmentation module is used to determine the structured segmentation result of the image to be segmented based on the image segmentation results at multiple scales.
[0061] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps in an embodiment of an image structured segmentation method. Specific implementation methods can be found in the method embodiments, and will not be repeated here.
[0062] Furthermore, the present invention also provides a non-transitory computer-readable storage medium containing instructions on which a computer program is stored. For example, a memory containing instructions that can be executed by a processor of a computer device to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc. When the computer program is executed by the processor, it can implement the steps in an embodiment of an image structured segmentation method. Specific implementation methods can be found in the method embodiments, which will not be repeated here.
[0063] Those skilled in the art will understand that embodiments of the present invention can provide methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention 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.
[0064] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0065] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0066] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0067] It should be noted that the specific embodiments described above enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail in this specification and embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention; and all technical solutions and improvements that do not depart from the spirit and scope of the present invention are covered within the protection scope of the present invention patent. No reference numerals in the claims should be construed as limiting the scope of the claims. Any simple variations or equivalent substitutions of technical solutions that can be readily obtained by those skilled in the art within the scope of the technology disclosed in the present invention are within the protection scope of the present invention.
Claims
1. A structured image segmentation method, characterized in that, include: The image to be segmented is obtained, and the image to be segmented is segmented based on pixel color and spatial proximity to obtain preliminary segmentation results; The color blocks with a color difference of less than a preset color merging threshold between adjacent color blocks in the preliminary segmentation result are merged to obtain the preliminary image merging result; Based on a preset incremental scale, the preliminary image merging result is subjected to color patch fusion to obtain image segmentation results at multiple scales. Specifically, at each scale, adjacent color patches in the image segmentation result of the previous scale whose color difference is less than a preset fusion threshold and whose circumscribed square side length is less than the circumscribed square side length threshold corresponding to the current scale are fused together to obtain the image segmentation result at the current scale. The circumscribed square side length threshold of the current scale is greater than the circumscribed square side length threshold of the previous scale. The circumscribed square side length threshold corresponding to each scale is set by incremental step. The image segmentation result at the first scale is determined by fusion of adjacent color patches in the preliminary image merging result whose color difference is less than the preset fusion threshold and whose circumscribed square side length is less than the circumscribed square side length threshold corresponding to the current scale. The structured segmentation result of the image to be segmented is determined based on the image segmentation results at multiple scales; The color block boundaries of the image segmentation results at multiple scales are superimposed on the image to be segmented to obtain a boundary superimposed map at multiple scales; the color block boundaries of the image segmentation results at multiple scales are superimposed on a white background to obtain a white background contrast map at multiple scales; pseudo-color codes are assigned to each color block in the image segmentation results at multiple scales to obtain a pseudo-color label map at multiple scales.
2. The image structured segmentation method according to claim 1, characterized in that, Before segmenting the image to be segmented based on pixel color and spatial proximity, the process further includes: The image to be segmented is input into a pre-trained image editing model based on generative rectified flow matching to obtain a flat-painted image with compressed texture and color; the flat-painted image is then converted to the Lab color space to obtain a normalized image to be segmented.
3. The image structured segmentation method according to claim 2, characterized in that, The image editing model based on generative rectified flow matching is a FLUX.1-Kontext diffusion model pre-trained with LoRA fine-tuning.
4. The image structured segmentation method according to claim 1, characterized in that, The image to be segmented is segmented based on pixel color and spatial proximity to obtain preliminary segmentation results, including: The image to be segmented is divided into multiple non-overlapping initial block sets using the Quickshift algorithm, and the initial block sets determine the preliminary segmentation result.
5. The image structured segmentation method according to claim 4, characterized in that, The color blocks in the preliminary segmentation result that have a color difference less than a preset color merging threshold are merged to obtain the preliminary image merging result, including: Calculate the CIEDE2000 color difference between adjacent initial blocks; When the CIEDE2000 color difference between adjacent initial blocks is less than the color merging threshold, the adjacent initial blocks are merged to obtain the preliminary image merging result.
6. The image structured segmentation method according to claim 1, characterized in that, Determining the structured segmentation result of the image to be segmented based on image segmentation results at multiple scales includes: For the image segmentation results at each scale, the color difference between the color block with a pixel count less than a preset value and its neighboring color blocks is calculated. The color block is then fused into the neighboring color block with the smallest color difference and the largest pixel count to obtain the image segmentation result after the smallest block absorption at each scale. The structured segmentation result of the image to be segmented is determined by the image segmentation result after the smallest block absorption at each scale.
7. An image structured segmentation system, characterized in that, include: The preliminary segmentation module is used to acquire the image to be segmented, and to segment the image to be segmented based on pixel color and spatial proximity to obtain preliminary segmentation results. The color blocks with a color difference of less than a preset color merging threshold between adjacent color blocks in the preliminary segmentation result are merged to obtain the preliminary image merging result; A multi-threshold filtering module is used to perform color patch fusion on the preliminary image merging result based on a preset incremental scale to obtain image segmentation results at multiple scales. Specifically, at each scale, adjacent color patches in the image segmentation result of the previous scale whose color difference is less than a preset fusion threshold and whose circumscribed square side length is less than the circumscribed square side length threshold corresponding to the current scale are fused together to obtain the image segmentation result at the current scale. The circumscribed square side length threshold for the current scale is greater than that for the previous scale. The circumscribed square side length threshold for each scale is set by incremental increments. The image segmentation result at the first scale is determined by fusion of adjacent color patches in the preliminary image merging result whose color difference is less than the preset fusion threshold and whose circumscribed square side length is less than the circumscribed square side length threshold corresponding to the current scale. The structured segmentation module is used to determine the structured segmentation result of the image to be segmented based on the image segmentation results at multiple scales; The post-segmentation processing module is used to superimpose the color block boundaries of the image segmentation results at multiple scales onto the image to be segmented to obtain a boundary superimposition map at multiple scales; superimpose the color block boundaries of the image segmentation results at multiple scales onto a white background to obtain a white background comparison map at multiple scales; and assign pseudo-color codes to each color block in the image segmentation results at multiple scales to obtain a pseudo-color label map at multiple scales.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the image structured segmentation method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is loaded by the processor, it is able to execute the steps of the image structured segmentation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Sequence pulmonary nodule image segmentation method based on superpixels and density clustering
CN107341812A
Image matting method and device, medium and equipment
CN110751654A