An image normalization method and system based on adaptive piecewise gray scale transformation
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-09
- Publication Date
- 2026-08-11
AI Technical Summary
[0006]尽管上述现有技术方案在一定程度上实现了灰度归一化,但在面对复杂的实际应用场景时,它们存在显著的局限性,这些缺点正是本发明旨在解决的核心问题
1.极强的鲁棒性,有效抑制离群点影响。 本发明通过引入基于百分位修剪的稳健累积分布函数来确定有效灰度区间
,完全避免使用原始的全局极小值
和极大值
。即使图像中存在少数极端噪声点或高光/暗斑,
和
的值也能稳定地反映主体内容的灰度边界。此外,对于区间外的灰度(即可能的离群点),本发明采用平滑的非线性压缩函数进行处理,而不是粗暴地将其截断或进行线性拉伸,这防止了在极端值附近产生不自然的灰度阶跃或斑块,使得归一化过程对噪声和异常值具有先天的免疫力。
Smart Images

Figure CN122550719A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image normalization technology, and specifically relates to an image normalization method and system based on adaptive piecewise grayscale transformation. Background Technology
[0002] In the fields of machine vision, digital image processing and analysis, image acquisition equipment (such as industrial cameras, surveillance cameras, medical imaging equipment, etc.) is affected by many factors such as changes in ambient light, differences in sensor characteristics, exposure time settings, and uneven surface reflectivity of the target object, resulting in variations in the acquired raw image (denoted as ). ,in The grayscale distribution (using pixel coordinates) exhibits significant differences. These differences manifest in several ways: the overall brightness of the same scene may be too dark or overexposed under different lighting conditions; the grayscale range (dynamic range) of the same type of object may be compressed or shifted under different imaging conditions; and different batches or models of acquisition devices may produce inconsistent response outputs to the same stable light source. This uncertainty in grayscale distribution severely interferes with the stability and accuracy of subsequent image processing algorithms. For example, in key tasks such as feature extraction, template matching, object detection and recognition, and image segmentation, algorithm performance is often extremely sensitive to the grayscale characteristics of the input image (such as overall brightness and contrast). Therefore, image normalization or grayscale standardization, as a preprocessing step, aims to transform the input image into a standard space with preset statistical characteristics (such as a specific grayscale mean, variance, or a fixed grayscale range), thereby eliminating content-independent grayscale variations and enhancing the robustness and generalization ability of the algorithm.
[0003] Numerous scholars and research institutions have conducted in-depth research on image normalization techniques and proposed various implementation schemes. Among them, the most classic and widely used method is a linear or nonlinear transformation based on global statistical characteristics. The most similar implementation scheme to this invention among existing technical solutions can be summarized as "linear normalization based on global mean and standard deviation," and an improved version of it—"linear stretching based on global grayscale upper and lower limits."
[0004] Existing technologies, including global linear normalization, assume that an ideal normalized image should have a globally standardized gray level. The operation typically involves two steps: first, calculating the input image... The most common global statistic is the global grayscale mean. and global grayscale standard deviation The calculation formula is as follows: ; ; in, and These represent the height and width of the image, respectively. Then, a linear transformation is applied to map the input image to the target grayscale space: ; In order to achieve the set target mean and target standard deviation Transformation coefficients and This can be determined through the following relationship: ; Therefore, the final normalization transformation formula is: ; The purpose of this method is to make the output image The global mean is exactly The global standard deviation is exactly 1 .
[0005] Existing technologies also include global grayscale linear stretching (contrast stretching). Another widely used and simple approach is global grayscale linear stretching. This method does not pre-determine the target mean and variance, but rather aims to fully utilize the dynamic range of the image. It first determines the actual grayscale range of the input image. ,in: ; Then, through a linear mapping, Stretch or compress to a preset target range (For example, the standard [0, 255] for an 8-bit image). The transformation formula is: ; This method directly processes extreme gray values, aiming to unify the gray value range of all images.
[0006] Although the aforementioned existing technical solutions have achieved grayscale normalization to a certain extent, they have significant limitations when facing complex real-world application scenarios. These shortcomings are precisely the core problems that this invention aims to solve.
[0007] Disadvantage 1: It is overly sensitive to outlier gray values (outliers). Whether the method is based on the mean / standard deviation or on extreme values, its statistical measures ( , , , These are all global and treat all pixels equally. In actual images, there may be a very small number of noise points, bad pixels, highlighting points, or dark impurities. The grayscale values of these anomalous points may deviate significantly from the grayscale distribution of the main content. For example, an extremely bright highlighting point may cause... Abnormally high; a single bad pixel could cause this. Abnormally low. In this situation, extremum-based stretching compresses the grayscale of the vast majority of effective pixels into a very narrow range, resulting in a severe loss of effective contrast. Similarly, an abnormally bright or dark point will significantly affect the global mean. It has a significant impact and greatly increases the standard deviation. This causes the normalization results based on the mean / standard deviation to deviate from the true characteristics of the main content.
[0008] Disadvantage 2: Ignoring the local gray-level distribution characteristics of image content leads to loss of detail or contrast reversal. Global normalization methods process the entire image using a uniform transformation function. For images with uneven gray-level distribution (e.g., images with uneven lighting, or images with significant differences in brightness between the background and foreground), the global transformation cannot simultaneously meet the optimal contrast requirements of different regions. In order to bring dark areas into the visible range, bright areas may be overexposed and saturated; conversely, in order to compress bright details, dark details may be compressed to even darker levels and lost. This "one-size-fits-all" approach may disrupt the inherent and meaningful contrast relationships in local areas of the image, and may even produce undesirable contrast reversals in some areas.
[0009] Disadvantage 3: Fixed target parameters ( The existing methods lack adaptability to different image content. They typically pre-set fixed target parameters for all images. However, the optimal grayscale level for image content may differ across application scenarios. For example, text scans may require a high-contrast binarization bias; medical X-rays may need to preserve a specific tissue density grayscale range; and natural scenes may require maintaining visual naturalness. Fixed target parameters cannot flexibly adapt to these diverse needs, potentially resulting in normalized images that, while statistically "standard," are not conducive to subsequent specific analytical tasks. Summary of the Invention
[0010] To address the shortcomings of the existing technologies, this invention provides a novel, more robust, and adaptive image normalization method and system. Specific objectives include: 1. Improve robustness: Invent a normalization method that is insensitive to abnormal gray values (outliers) in the image, avoiding the deterioration of the overall normalization effect due to a few noise or extreme pixels.
[0011] 2. Enhance local adaptability: Invent a normalization method that can take into account the local gray-level distribution characteristics of an image, so as to maintain or optimize the detail contrast of local areas of the image while unifying the global gray-level.
[0012] 3. Introducing content adaptability: Invent a method that can adaptively determine or adjust the target gray level parameters according to the characteristics of image content (such as the gray level distribution of the main object, the complexity of image texture, etc.), so that the normalization result is more in line with the needs of subsequent processing tasks.
[0013] To achieve the above objectives, this invention provides an image normalization method based on adaptive piecewise grayscale transformation, comprising the following steps: S10, Input the original image ; S20, Calculate the gray-level cumulative distribution function and its robust estimate; S30, adaptive segmentation points are determined based on robust gray-level cumulative distribution function; S40, construct the piecewise grayscale transformation function; S50, apply the transformation function to obtain the normalized image. ; S60 outputs a normalized image.
[0014] Preferably, in step S20, the input image is calculated first. grayscale histogram ,in , The image has several gray levels; based on the histogram, the original cumulative distribution function is calculated. : ; in, The number of rows in the input image. The number of columns in the image. This is the current grayscale threshold.
[0015] Preferably, S20 introduces a robust cumulative distribution function. First, the histogram is trimmed or adjusted based on percentiles, specifically by defining the lower percentile. and high percentile Then, calculate a trimmed histogram. : ; This is equivalent to temporarily ignoring both ends of the distribution when calculating robust statistics. and Extreme pixels in the scale; calculate a robust cumulative gray-level distribution function based on the cropped histogram: .
[0016] Preferably, in S30, the following is utilized To determine the key segmentation points, define three key gray levels: Main dark end quantile :satisfy The grayscale value is set. ≤0.1 represents the upper limit of focusing on the darker portion (≤10%) of the main content; Main bright end quantile :satisfy The grayscale value is set. ≥0.9 represents the lower limit of focusing on the brighter ≥90% portion of the main content; Main median :satisfy The gray value is the median of the gray distribution of the main content.
[0017] Preferably, in step S40, an adaptive piecewise grayscale transformation function is constructed. This function will take grayscale levels as input. Mapped to target gray level The preset target grayscale range is Transformation function Designed as a three-section structure: Downcompression, or saturation segment, corresponds to outlier dark regions: For The input grayscale value is non-linearly compressed and mapped to the lower end of the target range, specifically using a smooth mapping function. ,in, It's an offset, to ensure It will not be exactly equal to Avoid in Discontinuity occurs at this point; It is the attenuation coefficient, which controls the degree of compression and can be related to the local contrast of the image or Gradient correlation at point, ensuring that when Less than hour, Approaching And the changes are gradual; when near When connecting to the next paragraph; The main linear or nonlinear enhancement segment corresponds to the effective grayscale range. This is the core region of the transformation, where an adaptive gamma correction and linear mapping are combined. First, the adaptive gamma value is calculated. : ,in, It is the preset median gray level of the main body. The target value mapped to can specifically be set to ,in, It's about adjusting the weights. This reflects the skewness of the gray-level distribution in the main part of the image; then, for The transformation function is: when When the function is applied, it stretches the dark areas; when... When, it has a stretching effect on the bright areas; when At that time, it degenerates into a linear mapping; The upper compression, i.e., the saturation segment, corresponds to the outlier bright region: for The input grayscale is processed symmetrically with the next segment: ,in, Definition and Similarly, ensure that extreme bright spots are smoothly compressed to... nearby; The final transformation function It is a line from Starting nearby, passing through , , Finally arrived A continuous, monotonically increasing curve in the vicinity.
[0018] Preferably, the constructed lookup table in step S50 Applied to input image Each pixel: ; in, This indicates rounding to the nearest integer to obtain the final normalized image. .
[0019] To achieve the above objectives, the present invention also provides an image normalization system based on adaptive piecewise grayscale transformation, implementing the above method, comprising an image input module, a robust statistics calculation module, an adaptive piecewise function construction module, a grayscale transformation processing module, and an image output module connected in sequence, wherein: The image input module receives the original image. ; The robust statistics calculation module calculates the gray-level cumulative distribution function and its robust estimate. The adaptive piecewise function construction module determines the adaptive segmentation point based on the robust gray-level cumulative distribution function. The grayscale transformation processing module constructs a piecewise grayscale transformation function, applies the transformation function, and obtains a normalized image. ; The image output module outputs a normalized image.
[0020] Preferably, the robust statistics calculation module includes a histogram calculation unit, a percentile pruning unit, and a gray-level cumulative distribution function and quantile calculation unit.
[0021] Preferably, the adaptive piecewise function construction module includes a parameter calculation unit and a lookup table generation unit. The beneficial effects of the present invention include at least the following: 1. Extremely robust, effectively suppressing the influence of outliers. This invention introduces a robust cumulative distribution function based on percentile pruning. Determine the effective grayscale range Completely avoid using the original global minimum. and maximum value Even if there are a few extreme noise points or highlights / dark spots in the image, and The value can also stably reflect the grayscale boundaries of the main content. In addition, for grayscale values outside the range (i.e., possible outliers), this invention uses a smooth nonlinear compression function to process them, rather than brute-force truncating or linearly stretching them. This prevents unnatural grayscale steps or patches from being generated near extreme values, making the normalization process inherently immune to noise and outliers.
[0022] 2. Excellent local detail preservation and adaptive contrast enhancement capabilities. This invention abandons the global single linear transformation, focusing on the effective grayscale range of the subject. Internally, a nonlinear mapping based on adaptive gamma correction is employed. Key parameters. It is based on the statistical characteristics of the main content of the image itself (through... (Calculated) Dynamically generated. This means that for images that are generally dark ( near The algorithm will automatically calculate a The value of is adjusted to stretch dark areas more significantly during the transformation, revealing more shadow details while avoiding overexposure of highlights. Conversely, for images that are generally bright, the algorithm automatically enhances highlight details. For images with uniform grayscale distribution, Approximately 1, resembling a linear mapping, preserving natural contrast. This "figure-specific" non-linear processing achieves global normalization (by...). Mapped to While mapping the effective range to the main part of the target range, it cleverly performs adaptive contrast optimization, which maximizes the preservation and enhancement of the visibility of useful information in the image, and solves the pain point of the global linear method of "paying attention to one thing but losing another".
[0023] 3. High adaptability and task relevance. The target parameters of this invention (e.g.) It can be designed to be fixed, but more importantly, it provides an interface for associating it with image content. For example, it can be analyzed... To dynamically adjust the slope or texture features If the image content mainly consists of low-contrast textures, it can be improved. This allows for the use of brighter gray levels to reveal details; if the image needs to be prepared for binarization, parameters can be adjusted to make the transformed histogram exhibit stronger bimodal characteristics. Additionally, percentile parameters... It can also be adjusted according to the application scenario. This flexibility allows the present invention to go beyond simple "statistical standardization" and advance to a "perception-enhanced standardization" or "task-driven standardization", so as to better serve subsequent specific visual analysis tasks.
[0024] 4. Balancing computational efficiency and practicality. Although this invention relates to steps such as percentile calculation and nonlinear function construction, its core operation is still based on a global histogram, with a computational complexity of O(L) + O(M×N), where O(L) is the time required to construct the lookup table. The complexity of pixel mapping using a lookup table is O(M×N). This is on the same order of magnitude as calculating the global mean / standard deviation, and far lower than methods requiring local filtering or complex optimization algorithms. A single lookup table can be applied to the entire image, ensuring processing speed and making it suitable for real-time or near-real-time industrial vision applications. Attached Figure Description
[0025] To make the objectives, technical solutions, and beneficial effects of this invention clearer, the following figures are provided for illustration: Figure 1 This is a flowchart illustrating the steps of the image normalization method based on adaptive piecewise grayscale transformation according to an embodiment of the present invention. Figure 2 This is a schematic diagram comparing the original histogram, the pruned region, and the robust CDF of the image normalization method based on adaptive piecewise grayscale transformation according to an embodiment of the present invention. Figure 3 This is a schematic diagram of the S30 adaptive piecewise grayscale transformation function T(g) of the image normalization method based on adaptive piecewise grayscale transformation according to an embodiment of the present invention; Figure 4 This is a structural block diagram of an image normalization system based on adaptive piecewise grayscale transformation according to an embodiment of the present invention; Figure 5 This is a schematic diagram comparing the processing effects of the image normalization method based on adaptive segmented grayscale transformation according to an embodiment of the present invention. Detailed Implementation
[0026] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0027] See Figure 1 The image normalization method based on adaptive piecewise grayscale transformation of the present invention includes the following steps: S10, Input the original image ; S20, Calculate the gray-level cumulative distribution function and its robust estimate; S30, adaptive segmentation points are determined based on robust gray-level cumulative distribution function; S40, construct the piecewise grayscale transformation function; S50, apply the transformation function to obtain the normalized image. ; S60 outputs a normalized image.
[0028] S20 first calculates the input image. grayscale histogram ,in , The image has several gray levels; based on the histogram, the original cumulative distribution function is calculated. : ; in, The number of rows in the input image. The number of columns in the image. This is the current grayscale threshold.
[0029] However, directly using the original CDF will still be affected by outliers. Therefore, we introduce a robust cumulative distribution function. The concept is as follows. Its calculation method is not simply to accumulate all pixels, but rather to first perform a "gentle" winsorizing or percentile-based adjustment on the histogram. Specifically, we define two lower percentiles. (e.g., 1%) and a high percentile (For example, 99%). Then, we calculate a trimmed histogram. : ; In essence, this is equivalent to temporarily ignoring the two ends of the distribution when calculating robust statistics. and The extreme pixels of the scale. Then, a robust CDF is calculated based on the pruned histogram: ; this This describes the grayscale distribution of the main part of the image (excluding the darkest and brightest outliers), which forms the basis for all subsequent adaptive calculations. Please refer to... Figure 2 It illustrates the original histogram, the pruned region, and the comparison between the robust CDF and the original CDF.
[0030] See Figure 2 This is a schematic diagram comparing the original histogram, the trimmed region, and the robust cumulative distribution function (CDF). Graylevel g is the input gray level g; Frequency / Probability density is the frequency / probability density; Cumulative probability is the cumulative probability; Histogram H(g) is the original gray histogram H(g); Trimmedregion is the trimmed region (outlier region); Original CDF F(g) is the original cumulative distribution function F(g); RobustCDF Fr(g) is the robust cumulative distribution function Fr(g).
[0031] S30 utilize To determine the key segmentation points, define three key gray levels: Main dark end quantile :satisfy The grayscale value is set. ≤0.1 represents the upper limit of focusing on the darker portion (≤10%) of the main content; Main bright end quantile :satisfy The grayscale value is set. ≥0.9 represents the lower limit of focusing on the brighter ≥90% portion of the main content; Main median :satisfy The gray value is the median of the gray distribution of the main content.
[0032] This constitutes the "effective grayscale range" of the main content of the image. Compared to directly using the global minimum and maximum values... It is not sensitive to outliers and can better represent the grayscale range of meaningful information in an image.
[0033] Constructing an adaptive piecewise grayscale transformation function in S40 This function will take grayscale levels as input. Mapped to target gray level The preset target grayscale range is Transformation function Designed as a three-section structure: Downcompression, or saturation segment, corresponds to outlier dark regions: For The input grayscale value is non-linearly compressed and mapped to the lower end of the target range, specifically using a smooth mapping function. ,in, It's an offset, to ensure It will not be exactly equal to Avoid in Discontinuity occurs at this point; It is the attenuation coefficient, which controls the degree of compression and can be related to the local contrast of the image or The gradient at that point is related, for example , guarantee when Less than hour, Approaching And the changes are gradual; when near When connecting to the next paragraph; The main linear or nonlinear enhancement segment corresponds to the effective grayscale range. This is the core region of the transformation, where an adaptive gamma correction and linear mapping are combined. First, the adaptive gamma value is calculated. : ,in, It is the preset median gray level of the main body. The target value mapped to can specifically be set to ,in, It's about adjusting the weights. This reflects the skewness of the gray-level distribution in the main part of the image; then, for The transformation function is: when When the function is applied, it stretches the dark areas; when... When, it has a stretching effect on the bright areas; when At that time, it degenerates into a linear mapping; this enables automatic adjustment of the contrast enhancement direction based on the image content.
[0034] The upper compression, i.e., the saturation segment, corresponds to the outlier bright region: for The input grayscale is processed symmetrically with the next segment: ,in, Definition and Similarly, for example This ensures that extreme bright spots are smoothly compressed to... nearby; To ensure that the function is at the piecewise points and To ensure continuity and smoothness (continuity of the first derivative), we need to adjust the parameters. Furthermore, it is possible to perform small-amplitude smoothing interpolation on piecewise functions at connection points (such as using cubic splines to connect a small region), which is a mature technique in both mathematics and engineering, and will not be elaborated here.
[0035] The final transformation function It is a line from Starting nearby, passing through , , Finally arrived A continuous, monotonically increasing curve in the vicinity.
[0036] The lookup table will be constructed in S50 Applied to input image Each pixel: ; in, This indicates rounding to the nearest integer to obtain the final normalized image. .
[0037] See Figure 3 This is a schematic diagram of the adaptive piecewise grayscale transformation function T(g), where Input gray level g is the input gray level g; Output gray level T(g) is the output gray level T(g). The lines in the diagram have the following meanings: Solid lines: process images that are generally dark (enhance shadows, γ<1\gamma<1γ<1); Dotted lines: normal contrast (approximately linear mapping); Dashed lines: process images that are generally bright (enhance brightness, γ>1\gamma>1γ>1).
[0038] See Figure 5 This is a schematic diagram comparing the processing effects of the method of the present invention. Figure 5 (a): Original input image (b): The result after applying existing technology (global linear stretching). Figure 5 (c): The result after applying the method of the present invention. Figure 5 (d): Histogram of the original image. Figure 5 (e): Histogram after global linear stretching. Figure 5 (f): Histogram after processing according to the present invention.
[0039] See Figure 4 This invention provides an image normalization system based on adaptive piecewise grayscale transformation. The method for implementing this invention includes, in sequence, an image input module 10, a robust statistics calculation module 20, an adaptive piecewise function construction module 30, a grayscale transformation processing module 40, and an image output module 50, wherein: Image input module 10 receives the original image. ; Robust statistics calculation module 20 calculates the gray-level cumulative distribution function and its robust estimate; Adaptive piecewise function construction module 30 determines adaptive segmentation points based on robust gray-level cumulative distribution function; The grayscale transformation processing module 40 constructs a piecewise grayscale transformation function, applies the transformation function, and obtains a normalized image. ; Image output module 50 outputs a normalized image.
[0040] Robust statistics calculation module 20 includes histogram calculation unit 31 (for calculating H(g)), percentile pruning unit 32, and gray-level cumulative distribution function and quantile calculation unit 33 (output). , , ).
[0041] The adaptive piecewise function construction module 30 includes a parameter calculation unit 31 (for calculating adaptive parameters). ) and lookup table generation unit 32 (constructing grayscale transformation function) ).
[0042] The key technologies and points to be protected in this invention include: 1. A technique for determining the effective grayscale range based on a robust cumulative distribution function. Specifically, this includes utilizing a predetermined low percentile. and high percentile The image grayscale histogram is pruned or masked to remove outliers; a robust cumulative distribution function is calculated based on the pruned histogram. ;use Solve for a specific cumulative probability (e.g.) gray level quantiles and with This serves as the effective grayscale range for the main content of the image. This technique is the core of achieving robustness.
[0043] 2. Construct an adaptive piecewise grayscale transformation function The technology. Specifically, it includes: The transformation function is divided into three segments: the lower compression segment ( ), main body transformation segment ( ), upper compression section ( ).
[0044] In the lower and upper compression segments, a smooth nonlinear function (such as an exponentially decaying function) is used to asymptotically compress the gray levels outside the interval to near the edge of the target range, ensuring that the function is continuous and smooth.
[0045] In the main transformation segment, adaptive parameters automatically calculated based on the image content are introduced. and adopts a form like The nonlinear mapping, where Depend on and their corresponding target mapping values The calculation yields the result (as described in the formula). This technique is central to achieving adaptive contrast enhancement and local detail preservation.
[0046] 3. Adaptive parameters The calculation method. Specific protection is achieved through image-specific statistics (…). ) and preset or adaptive target values ( The specific mathematical formula for calculating the nonlinear mapping exponent is: ; The preferred form is a logarithmic ratio, as described above. This formula is the mathematical core for achieving "variable depending on the graph" adaptability.
[0047] 4. Integrate the above methods into a complete image normalization processing system. Protect the system architecture, including the robust statistics calculation module and the adaptive piecewise function construction module, as well as the data flow and control flow relationships between the modules.
[0048] 5. Implementation methods of the described method in specific application scenarios (such as industrial defect detection, medical image standardization, face recognition preprocessing, document image binarization preprocessing, etc.). This protection applies to specific application schemes that combine the normalization method of the present invention as a preprocessing step with subsequent processing algorithms in specific domains (such as feature extractors, classifiers, segmentation networks).
[0049] Those skilled in the art can propose various functionally equivalent or partially alternative implementation schemes without departing from the overall concept of the present invention, and these alternative schemes can also achieve the purpose of the present invention.
[0050] Alternative Option 1: Use different outlier removal methods during the robust statistics calculation phase.
[0051] In addition to using percentile pruning (Winsorizing) to calculate robust CDF, another method can be used: The method based on median absolute deviation (MAD) first calculates the gray-level median. Then calculate the grayscale values of all pixels and... median of absolute deviation The grayscale value is in the range Pixels other than c are considered outliers and excluded (c is a constant, such as 3). Then, statistics are calculated using the remaining pixels to determine the outliers. .
[0052] The kernel density estimation (KDE)-based method: A gray-level histogram is fitted using kernel density estimation, and the gray values corresponding to the valleys on either side of the main peak of the fitted density function are used as... and This method provides a smoother estimation of the distribution pattern and is more robust to noise.
[0053] Alternative Solution 2: Use different nonlinear mapping forms in the main body of the piecewise transformation function.
[0054] In addition to power-law (gamma) transform, the following methods can also be used: S-shaped curves (such as the sigmoid function and the arctangent function): for example... Among them, the slope parameter According to Adaptive determination (e.g.) The S-curve function can also achieve the effect of enhancing the contrast in the middle area and compressing the ends, and it also has its own smoothing properties.
[0055] Variations of piecewise linear or adaptive histogram equalization (CLAHE): In Within an interval, it can be divided into several sub-intervals, and a linear mapping with a different slope can be applied to each sub-interval. The slope is determined by the proportion of pixels in that sub-interval to the total number of pixels in the main body. This is similar to a constrained local histogram equalization, but the calculation is more complex.
[0056] Alternative Option 3: Introduce a more advanced adaptive strategy in setting the target parameters.
[0057] As mentioned earlier It can adapt. Further alternatives include: Adaptive image content classification: First, classify the image content using a lightweight network or traditional features (e.g., "text", "face", "natural landscape", "industrial parts"). Then, select the most suitable feature from a predefined set based on the category. (or its computational method). This achieves a higher level of semantic adaptation.
[0058] Joint optimization with subsequent tasks: In an end-to-end deep learning framework, this normalization method can be designed as a differentiable network layer (input is an image, output is several transformation function parameters or a direct lookup table), and trained together with subsequent task networks (such as detection networks or segmentation networks). Through gradient backpropagation, the optimal normalization parameters best suited for the task are learned. This approach upgrades the adaptive capability of this invention from "based on feedforward statistics" to "based on task feedback optimization," representing a high-level alternative implementation of the invention's ideas in the deep learning era.
[0059] Alternative Solution 4: Combine global segmented transformation with local adjustments.
[0060] For images with extremely uneven illumination, a subsequent local gain compensation step can be introduced based on the global normalization of this invention. For example, the image can first be transformed to a standard intermediate state using the method of this invention, then a low-frequency illumination component map can be estimated, and this map can be used to perform local division or subtraction operations on the standard image to further eliminate illumination gradients. This two-stage scheme of "global normalization + local correction" can be regarded as a functional extension and alternative architecture of this invention for handling more complex situations.
[0061] In summary, the core protection point of this invention lies in using robust statistics to determine the effective grayscale range, and on this basis, constructing an adaptive piecewise nonlinear transformation function to achieve robust and adaptive image grayscale normalization. Any implementation scheme that adopts this core idea, even with variations in specific technical details (such as different outlier removal algorithms, different nonlinear function forms, or different parameter adaptation strategies), should be considered to fall within the protection scope of this invention.
[0062] Finally, it should be noted that the above preferred embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail through the above preferred embodiments, those skilled in the art should understand that various changes can be made to it in form and detail without departing from the scope defined by the claims of the present invention.
Claims
1. A method of image normalization based on adaptive piecewise gray scale transformation, characterized by, Includes the following steps: S10, inputting an original image ; S20, Calculate the gray-level cumulative distribution function and its robust estimate; S30, adaptive segmentation points are determined based on robust gray-level cumulative distribution function; S40, construct the piecewise grayscale transformation function; S50, apply a transform function to obtain a normalized image ; S60 outputs a normalized image.
2. The method according to claim 1, characterized in that, The gray level histogram of the input image is calculated in S20 wherein , is the number of gray levels of the image; Based on the histogram, the original cumulative distribution function is calculated : ; wherein, the number of rows of the input image, is the number of columns of the image, is the current grayscale threshold.
3. The method according to claim 2, characterized in that, S20 introduces a robust cumulative distribution function First, a pruning or percentile-based adjustment of the histogram is performed, including defining a low percentile and a high percentile Then, a pruned histogram is computed: ; This is equivalent to temporarily ignoring both ends of the distribution when calculating robust statistics. and Extreme pixels in the scale; calculate a robust cumulative gray-level distribution function based on the cropped histogram: 。 4. The method of claim 3, wherein, S30 utilizes To determine the key segmentation points, define three key gray levels: dark end of the body : the gray value satisfying , set ≤ 0.1, representing the upper limit of the ≤ 10% part of the darker part in the content of the subject of interest; subject bright end quantile : the gray value satisfying , set ≥ 0.9, representing the lower limit of the ≥ 90% part of the brighter part in the subject content concerned The median point of the body : the gray value satisfying the median of the body content gray scale distribution.
5. The method of claim 4, wherein, In S40, an adaptive piecewise grayscale transformation function is constructed. This function will take grayscale levels as input. Mapped to target gray level The preset target grayscale range is Transformation function Designed as a three-section structure: Downcompression, or saturation segment, corresponds to outlier dark regions: For The input grayscale value is non-linearly compressed and mapped to the lower end of the target range, specifically using a smooth mapping function. ,in, It's an offset, to ensure It will not be exactly equal to Avoid in Discontinuity occurs at this point; It is the attenuation coefficient, which controls the degree of compression and can be related to the local contrast of the image or Gradient correlation at point, ensuring that when Less than hour, Approaching And the changes are gradual; when near When connecting to the next paragraph; The main linear or nonlinear enhancement segment corresponds to the effective grayscale range. This is the core region of the transformation, where an adaptive gamma correction and linear mapping are combined. First, the adaptive gamma value is calculated. : ,in, It is the preset median gray level of the main body. The target value mapped to can specifically be set to ,in, It's about adjusting the weights. This reflects the skewness of the gray-level distribution in the main part of the image; then, for The transformation function is: when When the function is applied, it stretches the dark areas; when... When, it has a stretching effect on the bright areas; when At that time, it degenerates into a linear mapping; The upper compression, i.e., the saturation segment, corresponds to the outlier bright region: for The input grayscale is processed symmetrically with the next segment: ,in, Definition and Similarly, ensure that extreme bright spots are smoothly compressed to... nearby; The final constructed transformation function is a continuous, monotonically increasing curve starting near passing through , , and ending near .
6. The method of claim 5, wherein, The constructed look-up table in S50 is applied to each pixel of the input image ; wherein, represents rounding off to the nearest integer, resulting in the final normalized image .
7. A system for image normalization based on adaptive piecewise gray scale transformation, implementing the method according to any one of claims 1 to 6, characterized in that, It includes, in sequence, an image input module, a robust statistics calculation module, an adaptive piecewise function construction module, a grayscale transformation processing module, and an image output module, wherein: The image input module receives an original image ; The robust statistics calculation module calculates the gray-level cumulative distribution function and its robust estimate. The adaptive piecewise function construction module determines the adaptive segmentation point based on the robust gray-level cumulative distribution function. The gray scale conversion processing module constructs a segmented gray scale conversion function, and applies the conversion function to obtain a normalized image ; The image output module outputs a normalized image.
8. The system of claim 7, wherein, The robust statistics calculation module includes a histogram calculation unit, a percentile pruning unit, and a gray-level cumulative distribution function and quantile calculation unit.
9. The system according to claim 7, characterized in that, The adaptive piecewise function construction module includes a parameter calculation unit and a lookup table generation unit.