Detail-preserving multi-scale local histogram equalization method
By employing a multi-scale local histogram equalization method that preserves detail, the problems of detail loss and noise amplification in image enhancement are solved. This method achieves contrast enhancement and detail preservation, eliminates block artifacts, and provides a natural image enhancement effect.
Patent Information
- Application Number
- CN202511395649.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-12-16
AI Technical Summary
Existing technologies cannot effectively preserve image details during image enhancement and suffer from problems such as insufficient local contrast enhancement, noise amplification, and block artifacts.
A multi-scale local histogram equalization method that preserves detail is adopted. By dividing the image into blocks, selecting multi-scale windows, performing local histogram equalization and fusing the results, combined with filtering and noise reduction and contrast limiting, the method achieves contrast enhancement and detail preservation.
It effectively enhances image contrast, significantly preserves image details, suppresses noise, eliminates blockiness, and provides a natural image enhancement effect.
Smart Images

Figure CN121147076A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computer vision, in particular to an image enhancement method, and more particularly to a multi-scale local histogram equalization method with detail preservation. BACKGROUND
[0002] Image enhancement is a key technology in the field of digital image processing, and its purpose is to improve the visual effect of the image and highlight its detail information. Histogram equalization (HE) is one of the most commonly used contrast enhancement techniques, which is simple and effective. The core idea is to redistribute the pixel gray value to transform the output image histogram into a uniform distribution, thereby expanding the dynamic range.
[0003] However, the traditional global histogram equalization (GHE) method operates on the entire image, ignoring the local features of the image, resulting in limited local contrast enhancement effect. In images with large differences in background and foreground brightness, it is easy to produce over-enhancement and lose details, and it will also amplify the overall noise.
[0004] CLAHE limits the amplification factor by clipping the histogram, effectively suppressing noise amplification, and has become a mainstream algorithm. However, CLAHE still has some shortcomings: lack of adaptability, insufficient enhancement ability for fine details such as texture, and sometimes even smoothing out relevant details. In the process of processing complex images, the problem of block effect has not been fundamentally solved.
[0005] Therefore, there is an urgent need in the prior art for a new image enhancement method that can enhance the overall and local contrast of the image while effectively preserving image details and suppressing noise. SUMMARY
[0006] The purpose of the present application is to overcome the shortcomings of the prior art and provide a multi-scale local histogram equalization method with detail preservation. This method not only effectively enhances the contrast of the image, but also significantly preserves the image details and suppresses the noise.
[0007] To achieve the above purpose, the technical solution adopted by the present application is as follows:
[0008] The multi-scale local histogram equalization algorithm with detail preservation includes the following steps:
[0009] Step 1), image blocking, the input image is divided into multiple overlapping or non-overlapping sub-blocks. The block size is usually determined according to the image content and the target detail scale, and can be fixed or adaptive, ensuring the effective extraction of local region statistical characteristics while avoiding block effect;
[0010] Step 2), selection of multi-scale windows, define multiple local neighborhood windows of different scales for each pixel point (for example, set three different radius circular or square windows), so as to collect gray scale distribution information in different spatial ranges. The specific algorithm process is as follows: for each pixel point in the image, select windows of different sizes with the point as the center. Each window is used to extract local gray scale statistical characteristics at different scales to provide a basis for subsequent multi-scale fusion.
[0011] Step 3), local histogram equalization (LHE) algorithm, histogram statistics are performed on the pixels in each local window of each scale, and gray scale mapping is performed based on the cumulative distribution function (CDF) of the window, so as to realize local contrast enhancement. This step independently processes each window, enhances details, and also needs to suppress noise amplification.
[0012] Step 4), multi-scale result fusion, the results of equalization of the same pixel under different scale windows are fused by weighting. The weight can be adaptively assigned according to the window size, local contrast or entropy value, etc. Generally, large windows are used to maintain overall brightness consistency, and small windows are used to enhance details, so as to enhance local details while maintaining natural appearance;
[0013] Step 5), post-processing optimization: filtering and denoising and contrast limiting processing are performed on the fused image to suppress possible noise or halo artifacts, and brightness adjustment is performed to ensure overall visual consistency, and finally an enhanced image is output.
[0014] Preferably, in step 2), the setting of window size follows the following principles: the physical size and distribution range of the details to be enhanced in the target image are selected; the scale selection covers a continuous range from micro features to macro features, and a square window size sequence of [16, 32, 64, 128, 256, 512, 1024] is used.
[0015] Preferably, in step 2), the sliding step length of the multi-scale window when traversing the image is set to half of the current window size, so as to ensure the sufficiency of sampling and calculation efficiency.
[0016] Preferably, in step 3), the gray scale mapping transformation formula based on the cumulative distribution function is:
[0017]
[0018] Wherein, L is set as the gray scale, which is defined as 1048576 in the present example, n i is the number of pixels of gray scale i, and N is the total number of pixels in the window.
[0019] Preferably, in step 4), the calculation formula of the weighted fusion is:
[0020] I final (x,y)=∑ s∈scales w s ·I s (x,y)
[0021] Among them, I s (x,y) represents the augmentation result at scale s, w s For the corresponding weights.
[0022] Preferably, the weight w s The weight is automatically assigned based on the window size. The smaller the window size, the greater the weight is assigned to emphasize details and enhance the effect; the larger the window size, the smaller the weight is assigned to maintain the integrity of the background. The specific weight assignment can be adjusted according to the actual application scenario.
[0023] Preferably, in step 5), the filtering and denoising process uses Gaussian filtering to suppress high-frequency noise that may be introduced by grayscale mapping; the contrast limiting process is implemented by setting a clipping threshold (Clip Limit) to limit the slope of the local histogram and avoid over-enhancement, and the Clip Limit value is set to 2.
[0024] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method as described in any one of claims 1 to 7.
[0025] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method as described in any one of claims 1 to 7.
[0026] Advantages or beneficial results of the present invention:
[0027] (1) The present invention can enhance details in a targeted manner by multi-scale histogram equalization, thus avoiding the smoothing of details.
[0028] (2) This invention improves noise suppression by using multi-scale histogram equalization and dynamically adjusts the contrast clipping threshold based on the variance of the local area.
[0029] (3) This invention can effectively eliminate the block effect by using multi-scale histogram equalization and utilize multi-scale smooth fusion to achieve a natural and smooth transition, thereby avoiding sharp discontinuous linearity at the boundary and fundamentally eliminating the block effect. Attached Figure Description
[0030] Figure 1 The flowchart shows the detail-preserving multi-scale local histogram equalization algorithm in this embodiment.
[0031] Figure 2 The image shown is the original image of cotton defects captured in the example.
[0032] Figure 3 The image shown in the example is processed by the detail-preserving multi-scale local histogram equalization algorithm.
[0033] Figure 4 This is a histogram of the original image obtained from the examples;
[0034] Figure 5 The histogram is the image statistically obtained after the detail-preserving multi-scale local histogram equalization algorithm in the embodiment. Detailed Implementation
[0035] The present invention will now be described in detail with reference to the accompanying drawings and embodiments, examples of which are illustrated in the drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0036] Example:
[0037] To illustrate the detail-preserving multi-scale local histogram equalization algorithm of the present invention, cotton defect recognition is used as a typical scenario and image enhancement as a typical task, but it is not limited to this scenario and task. This recognition method can also be used in other scenarios and other tasks.
[0038] like Figure 1 As shown, the detail-preserving multi-scale local histogram equalization algorithm includes the following steps:
[0039] Step (1), image segmentation;
[0040] The specific implementation method is as follows:
[0041] For the original image of cotton defects with a pixel size of 3468×4624, the overlapping block algorithm is used to divide the image into blocks of 1024×1024 with an overlap rate of 50%.
[0042] Step (2), selection of multi-scale windows;
[0043] Define a set of sliding windows of different sizes to select the window size based on the distribution of defects;
[0044] In this example, the selected multi-scale window is [16,32,64,128,256,512,1024], and the weights are set to [0.5,0.45,0.4,0.35,0.3,0.2,0.1], covering a scale range from tiny defects to larger sizes, while ensuring an overlap rate of 50%.
[0045] Step (3), local histogram equalization;
[0046] The specific implementation method is as follows:
[0047] A sliding window with a step size S = window size / 2 is used to traverse the entire image, processing the pixels of each window.
[0048] The grayscale values are used to calculate the histogram and then undergo equalization mapping. The mapping changes are shown in Equation (1):
[0049]
[0050] Where L is defined as the number of gray levels, which is 1048576 in this example, n i Where i is the number of pixels at gray level i, and N is the total number of pixels within the window;
[0051] Then, bilinear interpolation is used to smooth out abrupt changes at the window edges for boundary processing;
[0052] Step (4), multi-scale result fusion;
[0053] The specific implementation method is as follows:
[0054] Step (4-1) involves weight allocation, assigning different weights based on the window size, defining small windows for enhanced details and large windows for smoothed backgrounds;
[0055] Assign a weight of 0.5 to a 16×16 window, 0.45 to a 32×32 window, 0.4 to a 64×64 window, 0.35 to a 128×128 window, 0.3 to a 256×256 window, 0.2 to a 512×512 window, and 0.1 to a 1024×1024 window.
[0056] Step (4-2) involves pixel-level fusion. For each pixel's position, the enhancement results at each scale are weighted and summed. The weighting algorithm is shown in Equation (2):
[0057] I final (x,y)=∑ s ∈ scales w s ·I s (x,y) (2)
[0058] Among them, I s (x,y) represents the augmentation result at scale s, w s For the corresponding weights;
[0059] Step (5), post-processing optimization;
[0060] The specific implementation method is as follows:
[0061] Step (5-1) suppresses image noise by using Gaussian filtering to denoise the high-frequency noise generated by introducing histogram equalization.
[0062] Step (5-2) limits the slope of the local histogram. Borrowing from CLAHE's method, we avoid over-enhancement by setting Clip Limit to 2.
[0063] The above description is merely a preferred embodiment of the present invention, intended to help readers understand the implementation method of the present invention. It should be understood that the scope of protection of the present invention is not limited to such specific statements and embodiments. Any equivalent structural or procedural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A multi-scale local histogram equalization method that preserves details, characterized in that, Includes the following steps: Step 1), Image segmentation, divides the input image into multiple overlapping or non-overlapping sub-blocks. The block size is usually flexibly determined according to the image content and target detail scale. Fixed block size or adaptive segmentation strategy can be adopted to ensure effective extraction of local region statistical characteristics while avoiding block artifacts. Step 2) Selection of multi-scale windows: Define multiple local neighborhood windows of different scales for each pixel to collect gray-scale distribution information in different spatial ranges. The specific algorithm flow is as follows: For each pixel in the image, select windows of different sizes centered on that point. Each window is used to extract local gray-scale statistical characteristics at different scales, providing a basis for subsequent multi-scale fusion. Step 3) Local Histogram Equalization Algorithm: Histogram statistics are performed on the pixels in each local window at each scale, and grayscale mapping is performed based on the cumulative distribution function of the window to achieve local contrast enhancement. This step processes each window independently, enhancing details while suppressing noise amplification. Step 4) Multi-scale result fusion: The results of equalization of the same pixel under different scale windows are weighted and fused. The weights can be adaptively allocated according to criteria such as window size, local contrast or entropy value. Usually, large windows are used to maintain overall brightness consistency, and small windows are used to enhance details, so as to enhance local details while maintaining a natural appearance. Step 5), Post-processing optimization: The fused image is filtered and denoised and contrast limited to suppress any noise or halo artifacts that may be introduced, and brightness is adjusted to ensure overall visual consistency, and finally the enhanced image is output.
2. The method according to claim 1, characterized in that, In step 2), the window size is set according to the following principles: it is selected based on the physical size and distribution range of the details to be enhanced in the target image; the scale selection covers a continuous range from small features to macro features, using a square window size sequence of [16,32,64,128,256,512,1024].
3. The method according to claim 1 or 2, characterized in that, In step 2), when the multi-scale window traverses the image, its sliding step size is set to half of the current window size to ensure sufficient sampling and computational efficiency.
4. The method according to claim 1, characterized in that, In step 3), the gray-level mapping transformation formula based on the cumulative distribution function is: Where L is defined as the number of gray levels, which is 1048576 in this example, n i is the number of pixels at gray level i, and N is the total number of pixels within the window.
5. The method according to claim 1, characterized in that, In step 4), the calculation formula for the weighted fusion is: I final (x,y)=∑ s ∈ scales w s ·I s (x,y) Among them, I s (x,y) represents the augmentation result at scale s, w s For the corresponding weights.
6. The method according to claim 5, characterized in that, The weight w s The weight is adaptively allocated based on the window size; the smaller the window size, the greater the weight is allocated to emphasize details and enhance the effect. The larger the window size, the smaller the weight assigned to it, in order to maintain the integrity of the background. The specific weight assignment can be adjusted according to the actual application scenario.
7. The method according to claim 1, characterized in that, In step 5), the filtering and denoising process uses Gaussian filtering to suppress high-frequency noise that may be introduced by grayscale mapping; the contrast limiting process is implemented by setting a clipping threshold ClipLimit to limit the slope of the local histogram and avoid over-enhancement, and the ClipLimit value is set to 2.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method as described in any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method as described in any one of claims 1 to 7.
