A post-processing method and system for vitiligo lesion boundary
By employing edge detection, gradient analysis, and morphological manipulation, the problem of inaccurate boundary recognition of vitiligo lesions has been solved, achieving high-precision boundary reconstruction in complex scenarios. This method is applicable to the identification of vitiligo and other skin diseases with fuzzy boundary features.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- PEOPLES HOSPITAL OF XINJIANG UYGUR AUTONOMOUS REGION
- Filing Date
- 2026-02-24
- Publication Date
- 2026-06-02
AI Technical Summary
Existing technologies cannot accurately identify the boundaries of vitiligo lesions in complex real-world scenarios, leading to a systematic overestimation or underestimation of the lesion area in the segmentation results, and they cannot effectively reconstruct irregular contours with pathological significance.
Edge detection is performed on grayscale images to filter out blurred transition zone boundary segments. Gradient direction consistency analysis and adaptive grayscale enhancement are then performed to remove isolated noise clusters. Morphological dilation is used to fuse irregular structures, and finally, smooth interpolation is performed to generate clear lesion contours.
It achieves high-fidelity reconstruction of vitiligo lesion boundaries, significantly reduces area misjudgment, improves the robustness and geometric accuracy of boundary recognition, and is suitable for high-fidelity reconstruction of real pathological edges in complex backgrounds.
Smart Images

Figure CN122134749A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of digital image processing technology, specifically to a post-processing method and system for the boundary of vitiligo lesions. Background Technology
[0002] Accurate quantitative assessment of vitiligo lesions is crucial for disease staging, efficacy monitoring, and individualized treatment. Currently, clinical practice and research primarily employ automated segmentation techniques based on digital image processing to replace subjective and inefficient manual delineation. Most existing solutions are grounded in color space analysis, utilizing the differences in chromaticity, brightness, or saturation between the vitiligo area and surrounding normal skin in RGB, HSV, or Lab color models. Pixel-level discrimination is achieved through global / local thresholding, region growing, or shallow machine learning classifiers. Under ideal imaging conditions of clear boundaries, high contrast, and uniform illumination, these methods can achieve basic segmentation functions and offer advantages such as computational simplicity and ease of implementation.
[0003] In real, complex clinical imaging environments, this color-difference-based recognition paradigm exposes fundamental technical flaws. The boundaries of vitiligo lesions are not ideal step edges at the physiological and physical level, but often appear as blurred transition zones affected by various factors. These factors include, but are not limited to: partial occlusion by hair leading to local information loss, shadows or highlights caused by non-uniform lighting, interference from skin texture (such as wrinkles and pores), and uneven post-inflammatory pigmentation. These interferences cause severe overlap in color statistical characteristics between the lesion area and the normal area, with the color values of pixels within the transition zone exhibiting a continuous gradient. This makes it difficult for classifiers based on fixed thresholds or static color models to accurately define the boundary location, generally resulting in a systematic overestimation or underestimation of the lesion area in the segmentation results. Furthermore, the error exhibits unpredictable fluctuations across different individuals and body parts, severely limiting its application in rigorous clinical quantitative studies.
[0004] For example, existing technology (CN107049263A) discloses a method for diagnosing vitiligo based on image processing. This method involves calibrating the image with a scale, converting it to grayscale, and then segmenting it by determining a single threshold based on the bimodal characteristics of the global grayscale histogram. Finally, the area is calculated by pixel counting. This method works under ideal conditions of uniform illumination and high contrast, but its core relies entirely on the global statistical distribution of grayscale values. Once the histogram lacks bimodal characteristics, the method fails.
[0005] Another existing technology (CN109741336B) proposes a vitiligo region segmentation method based on pixel clustering and segmentation thresholds. This method first performs superpixel clustering in the Lab color space to obtain spatially continuous small regions. Then, it determines the threshold range in the Lab space by manually sampling the color values of the vitiligo regions. Finally, it classifies the regions based on whether the average color of each superpixel block falls within this range. While this method introduces spatial constraints through clustering, improving noise resistance to some extent, its final classification decision boundary is still entirely defined by the numerical range in the Lab color space, and the threshold setting relies on manual intervention, making fully automated processing impossible.
[0006] Existing methods completely ignore the rich information and pathological significance inherent in the geometric morphology of lesion boundaries. Clinically, vitiligo edges can manifest as a variety of morphological spectra, ranging from sharp and smooth to irregular serrated, feathery, and even island-like discrete distributions. The direction and curvature of their local contours frequently change at the microscopic scale, and this geometric heterogeneity is closely related to the spatial patterns of melanocyte destruction activity. Traditional image segmentation algorithms, whether based on thresholding, edge detection (such as Sobel and Canny), or region clustering, lack the ability to explicitly model and adaptively process the local geometric structure of the boundaries. They typically use isotropic filters of a preset scale or direction-insensitive operators to process the entire image, failing to effectively capture and respond to the drastic changes in gradient direction within the neighborhood of boundary pixels. Therefore, even when using classic edge detection algorithms, the initial boundary output will inevitably contain a large number of breaks, redundant noise points, and topological errors. Especially in the aforementioned fuzzy transition region, the weak gradient magnitude and highly discrete gradient direction information make subsequent contour connection and reconstruction steps extremely difficult. It often requires a compromise between excessive smoothing (loss of details) and excessive fragmentation (inability to close), ultimately resulting in low geometric fidelity of the reconstructed contour.
[0007] Existing vitiligo lesion image segmentation technology faces two core challenges: first, its over-reliance on color features makes it insufficiently robust to blurred boundaries in complex real-world scenarios; second, the lack of modeling of local geometric structure information at the boundaries makes it unable to accurately reconstruct irregular contours with pathological significance. Summary of the Invention
[0008] The purpose of this invention is to provide a post-processing method and system for the boundary of vitiligo lesions, which solves the technical problems of inaccurate identification of blurred boundaries and distortion of irregular contour reconstruction caused by the inability of existing color feature-based identification methods to model local geometric heterogeneity.
[0009] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0010] A post-treatment method for the borders of vitiligo lesions includes the following steps:
[0011] Obtain the grayscale image of the target skin region;
[0012] Edge detection is performed on the grayscale image to obtain an initial set of boundary line segments;
[0013] The initial contour and its area are obtained based on the initial set of boundary line segments.
[0014] Based on the local neighborhood gradient features of each initial boundary segment, fuzzy transition zone boundary segments are selected from the set of initial boundary segments.
[0015] Heterogeneity analysis based on gradient direction consistency is performed on the image region covered by the blurred transition zone boundary segment, and adaptive grayscale enhancement operation is performed on the sub-regions determined to be heterogeneous to obtain the enhanced boundary region.
[0016] Within the enhanced boundary region, isolated noise clusters are eliminated based on the area of the connected region and the average gradient magnitude of the pixels within it on the original grayscale image, and the remaining connected regions are identified as irregular structures to be integrated.
[0017] Calculate the spatial distance between each of the irregular structures to be integrated and the main boundary set, which consists of all initial boundary segments not marked as fuzzy transition zone boundary segments. Then, according to the spatial distance from smallest to largest, each of the irregular structures to be integrated is fused into the main boundary set through a morphological dilation operation to form a preliminary extended contour.
[0018] The preliminary extended contour is then subjected to smooth interpolation to generate the final smooth closed lesion contour.
[0019] Furthermore, the step of filtering based on the local neighborhood gradient features of each of the initial boundary segments specifically includes:
[0020] Calculate the average gradient magnitude of all pixels within a preset neighborhood window on both sides of each initial boundary line segment, and use it as the local average gradient magnitude of that line segment.
[0021] The initial boundary line segment whose local average gradient magnitude is lower than a preset gradient magnitude threshold is marked as the fuzzy transition zone boundary segment; wherein, the preset gradient magnitude threshold is dynamically determined based on the global average gradient magnitude of the grayscale image.
[0022] Furthermore, the heterogeneity analysis based on gradient direction consistency specifically includes:
[0023] Within a neighborhood window of a predetermined size centered on the current pixel, the weighted distribution of gradient magnitudes in different gradient direction intervals is statistically analyzed.
[0024] Calculate the directional entropy value of the neighborhood based on the weighted distribution;
[0025] If the directional entropy value exceeds a preset heterogeneity threshold, it is determined that the sub-region containing the neighborhood has significant texture inhomogeneity and belongs to a heterogeneous region.
[0026] Furthermore, the adaptive grayscale enhancement operation specifically includes:
[0027] The image of the heterogeneous region is smoothed and filtered to obtain the filtered pixel values;
[0028] Based on the original image gradient magnitude at the corresponding location of the heterogeneous region, the filtered pixel value is subjected to gain modulation, wherein the location with the larger gradient magnitude obtains a higher gain ratio.
[0029] The gain-modulated pixel values are subjected to non-linear grayscale mapping to compress the dynamic range and improve the contrast, resulting in an enhanced pixel value output.
[0030] Furthermore, the step of removing isolated noise clusters based on the area and gray-level uniformity of connected regions specifically includes:
[0031] The enhanced boundary region is labeled with connected components to obtain multiple connected regions;
[0032] For each connected region, calculate its total number of pixels as its area, and calculate the average gradient magnitude of all pixels within it on the original grayscale image.
[0033] If the area of a connected region is less than a first preset threshold and its average gradient magnitude is less than a gradient magnitude threshold, then the connected region is identified as the isolated noise cluster and is removed; wherein, the first preset threshold is determined based on the total number of pixels in the image, and the gradient magnitude threshold is determined based on the global average gradient magnitude of the grayscale image.
[0034] Furthermore, the step of obtaining the initial contour and its area based on the initial set of boundary line segments specifically includes:
[0035] A morphological closing operation is performed on the initial set of boundary line segments to connect the breakpoints, and the closed contour with the largest area is extracted as the initial contour, thereby obtaining its area.
[0036] Furthermore, the present invention also includes an area correction step:
[0037] Calculate the ratio of the area enclosed by the smooth closed lesion contour to the area of the initial contour;
[0038] If the ratio exceeds the preset area expansion threshold, the merged structures are removed from the current contour in reverse order of the previous fusion of the irregular structures to be integrated.
[0039] After each structure is removed, a smooth closed contour is regenerated and a new area ratio is calculated until the new area ratio does not exceed the area expansion threshold or all fused structures are removed.
[0040] The smooth, closed contour that last meets the conditions is output as the final lesion contour.
[0041] Furthermore, in the step of merging according to spatial distance from small to large, the size of the structural element used in the morphological expansion operation is positively correlated with the spatial distance from the current irregular structure to be integrated to the main boundary set.
[0042] Furthermore, the edge detection employs the Canny edge detection algorithm.
[0043] Furthermore, the gradient features are calculated using the Scharr operator.
[0044] Furthermore, the smooth interpolation process employs a cubic spline interpolation algorithm based on arc length parameterization.
[0045] Furthermore, the method receives an initial binarized mask from a deep learning segmentation network as input, and processes the edges of the initial binarized mask as the initial set of boundary segments.
[0046] Furthermore, the grayscale image is acquired by a dermoscope equipped with a ring-shaped LED light source.
[0047] The present invention also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of a post-processing method for the boundary of vitiligo lesions as described above.
[0048] This invention also discloses a post-processing system for the boundary of vitiligo lesions, comprising:
[0049] The image acquisition module is used to acquire grayscale images of the target skin area;
[0050] An edge detection module is used to perform edge detection on the grayscale image to obtain an initial set of boundary line segments;
[0051] The gradient analysis module is used to filter out fuzzy transition zone boundary segments from the set of initial boundary segments based on the local neighborhood gradient features of each initial boundary segment.
[0052] The transition zone processing module is used to perform heterogeneity analysis based on gradient direction consistency on the image region covered by the blurred transition zone boundary segment, and to perform adaptive grayscale enhancement operation on the sub-regions determined to be heterogeneous to obtain the enhanced boundary region.
[0053] The structural integration module is used to, within the enhanced boundary region, eliminate isolated noise clusters based on the area of the connected region and the average gradient magnitude of the pixels within it on the original grayscale image, and determine the remaining connected regions as irregular structures to be integrated; and to calculate the spatial distance between each of the irregular structures to be integrated and the main boundary set, wherein the main boundary set consists of all initial boundary segments not marked as fuzzy transition zone boundary segments, and to sequentially fuse each of the irregular structures to be integrated into the main boundary set through morphological dilation operation according to the spatial distance from smallest to largest, forming a preliminary extended contour;
[0054] The contour optimization module is used to perform smooth interpolation on the preliminary expanded contour to generate a smooth closed lesion contour.
[0055] The area output module is used to output the final skin lesion outline and calculate its area.
[0056] Compared with the prior art, the present invention has the following beneficial effects:
[0057] This invention overcomes the over-reliance on color features in existing technologies and establishes a novel processing method based on local gradient and geometric structure analysis. By directly analyzing gradient information that characterizes the essential structure of an image and explicitly modeling the directional heterogeneity of boundaries, the solution exhibits unprecedented robustness in the face of color aliasing and blurred transition zones caused by hair occlusion, non-uniform lighting, and skin texture. It can effectively distinguish between real pathological edges and imaging artifacts, and significantly reduce systematic misjudgments of area caused by overlapping color statistical features.
[0058] The local gradient directional entropy screening-adaptive pixel gain core coupling mechanism proposed in this invention achieves intelligent and targeted enhancement of blurred boundaries. Gradient directional entropy accurately quantifies the degree of texture disorder in local regions, serving as the criterion for activation enhancement; while gain modulation based on the original gradient magnitude ensures that the enhancement intensity is positively correlated with the edge salience. This data-driven, non-uniform enhancement strategy can selectively enhance realistic but weak boundary responses while suppressing noise, thereby reconstructing clear edge cues with high fidelity in complex backgrounds.
[0059] The sequential decision-making process of screening, enhancement, purification, fusion, and correction designed in this invention constitutes a logically rigorous processing closed loop with inherent error correction capabilities. The process clearly distinguishes and differentiates between fuzzy transition zone boundary segments and clear main boundaries. Suspected noise is rigorously eliminated using a strategy based on area and local gradient intensity, while irregular structures to be integrated that may represent true skin lesions are fused using a morphological fusion strategy weighted by spatial distance. The final area correction step dynamically controls the degree of contour expansion through a reverse backtracking mechanism, effectively preventing over-fusion and ensuring an optimal balance between geometric accuracy and area accuracy in the final output contour.
[0060] This invention does not rely on large-scale labeled data training, and its core process possesses strong interpretability and high deployability. Furthermore, the solution can be seamlessly embedded into existing deep learning-based semantic segmentation networks as an independent boundary optimization module. Without altering the main network structure, it significantly improves the geometric precision of the output mask at local boundaries, achieving a complementary advantage between the rigor of traditional image processing and the semantic understanding capabilities of deep learning, thus broadening the practical scenarios and application value of the solution. Attached Figure Description
[0061] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.
[0062] Figure 1 This is an overall flowchart of the method described in this invention.
[0063] Figure 2 This is a schematic diagram illustrating the fuzzy transition zone boundary segment identification and enhancement processing of the present invention.
[0064] Figure 3 This is a schematic diagram illustrating the spatial distance fusion of the irregular structure to be integrated in this invention.
[0065] Figure 4 The image information of the affected area was collected.
[0066] Figure 5 This is a grayscale image of the affected area.
[0067] Figure 6 This is a smooth, closed lesion outline obtained after processing according to the present invention.
[0068] Figure 7 This is a system block diagram of the present invention.
[0069] Figure 8This is the patient information entry interface when using the system described in this invention.
[0070] Figure 9 This is the interface used when processing skin lesions in the system described in this invention.
[0071] Figure 10 This is the interface for displaying the processing results when the system described in this invention is used. Detailed Implementation
[0072] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the embodiments of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.
[0073] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0074] Example 1: See Figures 1-7 This invention provides a post-processing method and system for vitiligo lesion boundaries, which achieves high-fidelity reconstruction of vitiligo lesion boundaries with both blurred and clear features through multi-stage geometric and gradient response analysis.
[0075] The technical solution of this invention will be described in detail below, combining specific engineering implementation details, parameter configuration, algorithm flow and experimental data.
[0076] The system includes:
[0077] The image acquisition module is used to acquire grayscale images of the target skin area;
[0078] An edge detection module is used to perform edge detection on the grayscale image to obtain an initial set of boundary line segments;
[0079] The gradient analysis module is used to filter out fuzzy transition zone boundary segments from the set of initial boundary segments based on the local neighborhood gradient features of each initial boundary segment.
[0080] The transition zone processing module is used to perform heterogeneity analysis based on gradient direction consistency on the image region covered by the blurred transition zone boundary segment, and to perform adaptive grayscale enhancement operation on the sub-regions determined to be heterogeneous to obtain the enhanced boundary region.
[0081] The structural integration module is used to, within the enhanced boundary region, eliminate isolated noise clusters based on the area of the connected region and the average gradient magnitude of the pixels within it on the original grayscale image, and determine the remaining connected regions as irregular structures to be integrated; and to calculate the spatial distance between each of the irregular structures to be integrated and the main boundary set, wherein the main boundary set consists of all initial boundary segments not marked as fuzzy transition zone boundary segments, and to sequentially fuse each of the irregular structures to be integrated into the main boundary set through morphological dilation operation according to the spatial distance from smallest to largest, forming a preliminary extended contour;
[0082] The contour optimization module is used to perform smooth interpolation on the preliminary expanded contour to generate a smooth closed lesion contour.
[0083] The area output module is used to output the final skin lesion outline and calculate its area.
[0084] For specific implementation, please refer to Figures 4-6 The system first acquires a digital image of the target skin area using a standard dermoscopic imaging device. This device is equipped with a ring-shaped LED light source with a center wavelength of 590nm, a color temperature of 5500K, an image resolution of 1920×1080 pixels, and a lossless PNG output format. During image acquisition, the patient's skin surface is kept clean and dry, free of makeup residue, and the image is captured under constant ambient light conditions to ensure consistent illumination and color fidelity of the input image.
[0085] The acquired RGB image was then converted into a single-channel grayscale image. This serves as a unified input for subsequent processing.
[0086] Subsequently, the system calls the edge initial extraction module to execute the Canny edge detection algorithm to extract initial edges. The specific parameter settings of this algorithm are as follows: First, a 5×5 Gaussian filter kernel is applied to the grayscale image, and the standard deviation is... Next, the Scharr operator is used to calculate the image gradient, and the gradient magnitude is... = calculate;
[0087] in:
[0088] Calculated for the Scharr operator Oriented gradient components;
[0089] Calculated for the Scharr operator Oriented gradient components;
[0090] This represents the gradient magnitude of the pixel at coordinates (x, y) in the image, reflecting the degree of drastic change in pixel grayscale.
[0091] After nonmaximum suppression and double-threshold hysteresis connection, a binary image is output. The edge pixel value is 255, and the non-edge pixel value is 0.
[0092] Subsequently, the binary edge image was processed. Perform a morphological closing operation (using a 3×3 circular structuring element) to connect the broken sections, and extract the outer closed contour with the largest area using a contour tracking algorithm. Calculate its area as Outline Discretize into an ordered sequence of edge pixels To perform local gradient analysis, the sequence is divided into continuous segments of approximately equal length, resulting in an initial set of boundary segments. Each line segment It contains a set of consecutive edge pixels.
[0093] For each initial boundary segment The system performs local gradient strength filtering in the gradient analysis module. Specifically, it uses line segments... Take one as the center of each pixel. The square neighborhood (i.e., extending 5 pixels on each side of the line segment) is the union of all these neighborhoods, which constitutes the analysis region of the line segment. .
[0094] Calculate the average gradient magnitude of all pixels within this region. :
[0095] ;
[0096] in:
[0097] The local average gradient magnitude of the i-th initial boundary line segment is used to determine whether the line segment is a boundary segment of the fuzzy transition zone.
[0098] : The analysis region of the i-th initial boundary line segment (the union of 11×11 square neighborhoods centered on each pixel on the line segment);
[0099] Represents line segment Analysis area The total number of pixels within;
[0100] (x,y): The coordinates of the image pixels;
[0101] Let be the gradient magnitude of pixel (x, y).
[0102] Define global average gradient magnitude ,in Represents the entire image domain; For the image domain Total number of pixels included.
[0103] like , where gradient magnitude Then the line segment Marked as the boundary segment of the fuzzy transition zone. All marked line segments. The set of pixels on the surface is defined as the preprocessing transition zone region. .
[0104] exist Internally, the system first applies a Gaussian filter with a kernel size of 7×7 and a standard deviation of [missing information]. To further smooth high-frequency noise, a filtered image is obtained. .against For each pixel in the array, calculate its gradient direction and magnitude. Within a predetermined neighborhood window centered on that pixel, uniformly quantize the gradient direction from 0° to 180° into 8 intervals (each interval being 22.5°). Count the interval to which the gradient direction of all pixels within this window belongs, and using the gradient magnitude of each pixel as a weight, calculate the proportion of the weighted magnitude of each direction interval to the total weighted magnitude, denoted as . Calculate the directional entropy value of the neighborhood based on the stated ratio. :
[0105] ;
[0106] in:
[0107] : Neighborhood directional entropy value, used to quantify the degree of texture disorder in a local region (to determine whether it is a heterogeneous region);
[0108] : Index of the gradient direction interval (values 1 to 8, corresponding to 8 intervals of uniform quantization from 0° to 180°, each interval being 22.5°);
[0109] : The proportion of the weighted magnitude of the k-th direction interval to the total weighted magnitude (the weight is the gradient magnitude of the pixel in that interval);
[0110] Logarithmic operations with base 2 are used to calculate entropy.
[0111] like If the heterogeneity threshold is specified, then the sub-region is determined to have significant texture inhomogeneity; where the heterogeneity threshold is specified. The orientation entropy distribution of clear boundary regions in a large number of training images is statistically analyzed, and the 75th percentile is used to determine it. As an example, The typical range of values can be found in arrive between.
[0112] For all pixels within this sub-region, with Based on the original grayscale image Based on the gradient information, perform an adaptive gain operation:
[0113] ;
[0114] in:
[0115] Pixel values after gain modulation;
[0116] Pixel values in the blurred transition zone region after Gaussian filtering (7×7 kernel, standard deviation σ=1.2);
[0117] Gain coefficient (adjustable parameter, typically 0.4~0.7, 0.5 in this embodiment);
[0118] Gradient magnitudes of all pixels over the entire image domain Ω The maximum value;
[0119] : is a very small positive number (e.g. ), used to prevent the denominator from being zero; gain coefficient Its value can be determined by optimization on independent validation set images using a grid search method. A typical value range is... In this embodiment, take .
[0120] After gain is achieved, contrast-limited adaptive histogram equalization (CLAHE) or gamma correction is used. )right A non-linear mapping is performed to enhance local contrast, and the enhanced pixel values are output. .right The threshold is automatically calculated using Otsu's method. and pixel values greater than Region binarization yields enhanced boundary regions. (Binary image, edge pixel value is 255, non-edge pixel value is 0).
[0121] Enhanced boundary regions for binarization By performing 8-connected component labeling, multiple connected regions are obtained. For each connected region Calculate the total number of pixels as the area. To distinguish noise from true skin lesion structure, each connected region was calculated. All pixels in the original grayscale image Average gradient magnitude The calculation method is as follows:
[0122] );
[0123] in:
[0124] The average gradient magnitude of pixels within the i-th connected region on the original grayscale image, used to remove isolated noise clusters;
[0125] : Enhance the i-th connected region marked within the boundary region;
[0126] : The total number of pixels contained in the i-th connected region.
[0127] If both conditions are met and If the connected region is identified as an isolated noise cluster, it will be removed; where the area threshold is... Set to 0.03% of the total number of pixels in the image (for example, for a 1920×1080 pixel image). (approximately 622 pixels), gradient threshold Set as global average gradient magnitude of This is a multiple of the previous (i.e., more stringent than when filtering fuzzy boundaries). The remaining connected regions that were not eliminated are defined as the set of irregular structures to be integrated. .
[0128] For each structure to be integrated The system calculates its centroid coordinates. Furthermore, the search is accelerated using a KD-tree to calculate the minimum Euclidean distance from the centroid to any point on the nearest principal boundary segment. Principal Boundary Set It consists of all initial boundary segments not marked as fuzzy transition zones. According to... The sizes of the structures to be integrated are arranged in ascending order.
[0129] For each one in turn Perform a morphological dilation operation using a circle as the structuring element, with a radius of... Determined by the following formula:
[0130] ;
[0131] in, For the first The expansion radius (in pixels) of the structure to be integrated. This is a preset proportional coefficient. For the first The minimum Euclidean distance (in pixels) from the centroid of each structure to be integrated to the set of principal boundaries. This indicates the floor function.
[0132] In this embodiment, take Based on the calculated radius Generate a size of ( )× ( The circular structuring element is used, and a morphological dilation operation is performed on the irregular structure S_j to be integrated. After dilation, if... When the boundary intersects with the nearest main boundary, the fusion is complete, forming a preliminary extended outline. .
[0133] In obtaining Then, the system calls the contour optimization module to perform cubic spline interpolation to eliminate jagged edges. Specifically, this involves extracting the coordinate sequences of all vertices along the contour line. The cumulative chord length method is used to parameterize the parameter with respect to the arc length. The functions, respectively for and The `scipy.interpolate.CubicSpline` method is used to construct a cubic spline curve. After interpolation, the number of contour points remains constant. To ensure closure and topological consistency, a smooth, closed lesion contour is generated. .
[0134] To further correct the problem of excessive area expansion, the system calculates the area ratio of the region enclosed by the contour before and after expansion. ;
[0135] in:
[0136] The area enclosed by the largest closed contour (initial contour) extracted from the initial set of boundary line segments;
[0137] The area enclosed by the lesion outline after the initial extended outline is smoothed and interpolated;
[0138] The area ratio of the expanded smooth closed contour to the initial contour is used to correct for excessive area expansion.
[0139] like Then, the structures to be integrated are merged in reverse order (i.e., distance). (in descending order), remove the merged irregular structures from the outline one by one, and recalculate the area ratio after each removal. until This process continues until all merged irregular structures are removed; then, spline interpolation and smoothing are re-performed on the final determined contour. The final output closed contour is the recognition result.
[0140] The above process is deployed on an embedded GPU platform, specifically an NVIDIA Jetson AGXXavier module equipped with 32GB LPDDR4x memory, running Ubuntu 18.04 LTS operating system, and featuring CUDA 10.2 and cuDNN 7.6 acceleration libraries. Image processing is implemented using OpenCV 4.5 and NumPy 1.19, while spline interpolation utilizes the SciPy 1.5.2 library. The system can also be deployed on a cloud server, using Docker containers to encapsulate the functional modules, Kubernetes to schedule concurrent tasks, HTTPS for image transmission, and HIPAA-compliant data storage.
[0141] In some preferred embodiments, the method can be embedded as a post-processing module into a deep learning segmentation network. For example, the probability map output by U-Net is binarized with a threshold of 0.5 to generate an initial mask. This initial mask can then be used as input to a binary image, and its edges can be directly obtained through contour extraction techniques (such as contour finding algorithms). The resulting contours, after discretization, serve as the initial set of boundary line segments, replacing the aforementioned method of obtaining edges from grayscale images using Canny edge detection, thereby connecting to the subsequent filtering, enhancement, integration, and optimization processes of this invention. This hybrid architecture retains the global semantic understanding capability of deep models while significantly improving the local boundary geometric accuracy. In one patient case, as shown... Figures 8-10 As shown.
[0142] In one specific embodiment, the complete workflow of this invention was used to process 120 clinically acquired images of vitiligo lesions. The images, sourced from the dermatology department of a tertiary hospital, covered areas such as the face, limbs, and torso, and included various complex scenarios such as hair occlusion, pigmentation interference, and low-light conditions. The system output the final contour and compared it with the gold standard contour manually annotated by three senior dermatologists. Evaluation metrics included the Dice similarity coefficient (DSC), Hausdorff distance (HD), and boundary F1 score (BF).
[0143] Comparative Example 1: Using only Canny edge detection (parameters same as in this invention) to directly output the boundary without any subsequent processing.
[0144] Comparative Example 2: Contours are generated by combining traditional Otsu thresholding with morphological closing operations.
[0145] Comparative Example 3: The segmentation mask is directly output using U-Net (ResNet-34 encoder, training set is ISIC2018 extended dataset), without the post-processing of this invention.
[0146] All experiments were run on the same hardware platform (Jetson AGXXavier), with a uniform input image resolution of 1920×1080. The results are shown in Table 1 below:
[0147] Table 1:
[0148] method DSC (%) HD (pixels) BF(%) Average processing time (ms) Comparative Example 1 68.2±5.7 28.4±6.3 62.1±7.1 42 Comparative Example 2 71.5±6.1 25.8±5.9 65.3±6.8 38 Comparative Example 3 82.7±4.3 15.2±3.7 78.6±5.2 185 Example 1 89.4±2.8 8.7±2.1 86.9±3.4 210
[0149] Data shows that Example 1 significantly outperforms all comparative examples across all metrics. Particularly in the Hausdorff distance, it reduces the distance by approximately 43% compared to Comparative Example 3, demonstrating the invention's exceptional control over local boundary deviations. Although the processing time is slightly longer than pure deep learning methods, it remains within clinically acceptable limits (<250ms).
[0150] Furthermore, the data were grouped and analyzed based on subsets with different degrees of boundary blurring. The 120 images were divided into three groups according to physician assessment: "clear boundaries" (40 cases), "moderate blurring" (50 cases), and "severe blurring" (30 cases).
[0151] The results showed that in the "severely ambiguous" group, Example 1 had a DSC of 85.1%, while Comparative Example 3 only had 76.3%, demonstrating a more significant advantage. This proves that the present invention has irreplaceable value in dealing with the most challenging ambiguous boundary scenarios in real clinical practice.
[0152] Furthermore, the area measurement results output by the system are also calibrated using a physical ruler. A 1cm standard ruler is embedded in the image, and the system automatically identifies its pixel length, establishing a pixel-physical size mapping relationship. Tests were conducted on 30 skin lesion samples with known areas (measured using a laser scanner), and the relative area error in Example 1 was [missing information]. Significantly lower than Comparative Example 1 ( ) and Comparative Example 2 ( ).
[0153] In robustness testing, Gaussian noise of different intensities was applied to the same lesion image. The DSC fluctuation range of Example 1 was ±1.8%, while that of Comparative Example 3 was ±4.5%, indicating that the present invention has stronger stability against input disturbances.
[0154] This invention achieves high-precision and robust identification of vitiligo lesion boundaries through a multi-stage geometric and gradient analysis process. The technical solution is fully disclosed, with all parameters, algorithms, and implementation details clearly described. Those skilled in the art can reproduce all functions based on this document. This method is not only applicable to vitiligo, but its core mechanism—an adaptive enhancement and structural fusion strategy based on local gradient heterogeneity—can also be transferred to intelligent identification tasks for other skin diseases with fuzzy boundary features, such as psoriasis and lupus erythematosus, demonstrating broad application prospects.
[0155] Existing technologies (such as CN107049263A and CN109741336B) all focus on finding better segmentation thresholds or clustering criteria within the color feature space. Their technological improvement paths are convergent and cannot overcome the fundamental problem of color aliasing. This invention proposes for the first time that when color features fail in complex scenes, the focus should shift to the essential structural information of the image: the gradient field. This reconstructs the boundary definition problem into a local geometric texture analysis and spatial structure reasoning problem.
[0156] At the principle level, this invention utilizes a novel quantification metric for local heterogeneity—"gradient direction entropy"—and establishes a strong causal relationship and synergistic mechanism between it and "adaptive gain based on the original gradient magnitude," achieving intelligent and targeted enhancement of fuzzy transition zones. Simultaneously, a sequential decision-making closed loop of "screening-enhancement-purification-fusion-correction" is designed. This process is logically rigorous, with clearly defined and mutually supportive functions for each module, achieving robust evolution from defective initial boundaries to high-fidelity geometric contours. More importantly, this solution does not rely on specific color models or large-scale labeled data, possessing strong interpretability and high deployability. It can run as an independent post-processing system or as a plugin to significantly improve the accuracy of existing deep learning segmentation models in boundary details, achieving a unity of methodological universality and practicality.
[0157] Although preferred embodiments of the invention 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 both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0158] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. It should be noted that any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A post-processing method for the boundary of vitiligo lesions, characterized in that, Includes the following steps: Obtain the grayscale image of the target skin region; Edge detection is performed on the grayscale image to obtain an initial set of boundary line segments; The initial contour and its area are obtained based on the initial set of boundary line segments. Based on the local neighborhood gradient features of each initial boundary segment, fuzzy transition zone boundary segments are selected from the set of initial boundary segments. Heterogeneity analysis based on gradient direction consistency is performed on the image region covered by the blurred transition zone boundary segment, and adaptive grayscale enhancement operation is performed on the sub-regions determined to be heterogeneous to obtain the enhanced boundary region. Within the enhanced boundary region, isolated noise clusters are eliminated based on the area of the connected region and the average gradient magnitude of the pixels within it on the original grayscale image, and the remaining connected regions are identified as irregular structures to be integrated. Calculate the spatial distance between each of the irregular structures to be integrated and the main boundary set, which consists of all initial boundary segments not marked as fuzzy transition zone boundary segments. Then, according to the spatial distance from smallest to largest, each of the irregular structures to be integrated is fused into the main boundary set through a morphological dilation operation to form a preliminary extended contour. The preliminary extended contour is then subjected to smooth interpolation to generate the final smooth closed lesion contour.
2. The post-processing method for the boundary of vitiligo lesions according to claim 1, characterized in that, The step of filtering based on the local neighborhood gradient features of each initial boundary line segment specifically includes: calculating the average gradient magnitude of all pixels within a preset neighborhood window on both sides of each initial boundary line segment as the local average gradient magnitude of the line segment. The initial boundary line segment whose local average gradient magnitude is lower than a preset gradient magnitude threshold is marked as the fuzzy transition zone boundary segment; wherein, the preset gradient magnitude threshold is dynamically determined based on the global average gradient magnitude of the grayscale image.
3. The post-processing method for the boundary of vitiligo lesions according to claim 1, characterized in that, The heterogeneity analysis based on gradient direction consistency specifically includes: Within a neighborhood window of a predetermined size centered on the current pixel, calculate the weighted distribution of gradient magnitudes in different gradient direction intervals; Calculate the directional entropy value of the neighborhood based on the weighted distribution; If the directional entropy value exceeds a preset heterogeneity threshold, it is determined that the sub-region containing the neighborhood has significant texture inhomogeneity and belongs to a heterogeneous region.
4. The post-processing method for the boundary of vitiligo lesions according to claim 3, characterized in that, The adaptive grayscale enhancement operation specifically includes: The image of the heterogeneous region is smoothed and filtered to obtain the filtered pixel values; Based on the original image gradient magnitude at the corresponding location of the heterogeneous region, the filtered pixel value is subjected to gain modulation, wherein the location with the larger gradient magnitude obtains a higher gain ratio. The gain-modulated pixel values are subjected to non-linear grayscale mapping to compress the dynamic range and improve the contrast, resulting in an enhanced pixel value output.
5. The post-processing method for the boundary of vitiligo lesions according to claim 1, characterized in that, The step of removing isolated noise clusters based on the area and gray-level uniformity of connected regions specifically includes: The enhanced boundary region is labeled with connected components to obtain multiple connected regions; For each connected region, calculate its total number of pixels as its area, and calculate the average gradient magnitude of all pixels within it on the original grayscale image. If the area of a connected region is less than a first preset threshold and its average gradient magnitude is less than a gradient magnitude threshold, then the connected region is identified as the isolated noise cluster and is removed; wherein, the first preset threshold is determined based on the total number of pixels in the image, and the gradient magnitude threshold is determined based on the global average gradient magnitude of the grayscale image.
6. The post-processing method for the boundary of vitiligo lesions according to claim 1, characterized in that, The step of obtaining the initial contour and its area based on the initial set of boundary line segments specifically includes: A morphological closing operation is performed on the initial set of boundary line segments to connect the breakpoints, and the closed contour with the largest area is extracted as the initial contour, thereby obtaining its area.
7. The post-processing method for the boundary of vitiligo lesions according to claim 6, characterized in that, It also includes an area correction step: Calculate the ratio of the area enclosed by the smooth closed lesion contour to the area of the initial contour; If the ratio exceeds the preset area expansion threshold, the merged structures will be removed from the current outline in reverse order of the previous fusion of the irregular structures to be integrated. After each structure is removed, a smooth closed contour is regenerated and a new area ratio is calculated until the new area ratio does not exceed the area expansion threshold or all fused structures are removed. The smooth, closed contour that last meets the conditions is output as the final lesion contour.
8. The post-processing method for the boundary of vitiligo lesions according to claim 1, characterized in that, In the step of merging according to spatial distance from smallest to largest, the size of the structural element used in the morphological expansion operation is positively correlated with the spatial distance from the current irregular structure to be integrated to the main boundary set.
9. The post-processing method for the boundary of vitiligo lesions according to claim 1, characterized in that, The edge detection uses the Canny edge detection algorithm.
10. A post-processing system for the boundary of vitiligo lesions, used to perform the post-processing method for the boundary of vitiligo lesions according to any one of claims 1-9, characterized in that, include: The image acquisition module is used to acquire grayscale images of the target skin area; An edge detection module is used to perform edge detection on the grayscale image to obtain an initial set of boundary line segments; The gradient analysis module is used to filter out fuzzy transition zone boundary segments from the set of initial boundary segments based on the local neighborhood gradient features of each initial boundary segment. The transition zone processing module is used to perform heterogeneity analysis based on gradient direction consistency on the image region covered by the blurred transition zone boundary segment, and to perform adaptive grayscale enhancement operation on the sub-regions determined to be heterogeneous to obtain the enhanced boundary region. The structural integration module is used to eliminate isolated noise clusters within the enhanced boundary region based on the area of the connected region and the average gradient magnitude of the pixels within it on the original grayscale image, and to determine the remaining connected regions as irregular structures to be integrated. And calculate the spatial distance between each of the irregular structures to be integrated and the main boundary set, which consists of all the initial boundary segments that are not marked as fuzzy transition zone boundary segments, and merge each of the irregular structures to be integrated into the main boundary set through morphological dilation operation according to the spatial distance from small to large, to form a preliminary extended contour; The contour optimization module is used to perform smooth interpolation on the preliminary expanded contour to generate a smooth closed lesion contour. The area output module is used to output the final skin lesion outline and calculate its area.
Citation Information
Patent Citations
Method and system for leucoderma state diagnoses and therapeutic effect evaluation based on image processing
CN107049263A
A Vitiligo Region Segmentation Method Based on Pixel Clustering and Segmentation Threshold
CN109741336B