Contrast enhancement method based on image features

By calculating the grayscale histogram of the image and optimizing the mapping range using the cropping scaling factor, the adaptability problem of the image contrast stretching algorithm in different scenarios is solved, achieving intelligent and natural image enhancement effects.

CN121660950APending Publication Date: 2026-03-13CHANGCHUN INST OF OPTICS FINE MECHANICS & PHYSICS CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-03-13

Smart Images

  • Figure CN121660950A_ABST
    Figure CN121660950A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image enhancement, in particular to a contrast enhancement method based on image features, and the method comprises the steps: S1, obtaining a gray histogram of an image; s2, determining an effective gray interval and a mode gray value of the image; and S3, taking the mode gray value as a reference, combining a preset basic cutting scale factor, and cutting out an optimized mapping interval in the effective gray interval. And S4, mapping the gray value of the image into the optimized mapping interval, cutting the gray value outside the interval, and linearly mapping the gray value to a full range of [0, 255] to obtain a contrast-enhanced image. The method has the advantages that by accurately setting the mapping interval, the unimportant background or noise area can be prevented from being excessively enhanced, so that the processing result better conforms to the expectation, and the visual effect is more natural. The calculation efficiency is high. In many scenes without extremely complex processing, the method can obtain a satisfactory enhancement effect with the minimum calculation cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image enhancement technology, and in particular to a contrast enhancement method based on image features. Background Technology

[0002] Image enhancement aims to improve the visual recognizability of images. Under different imaging conditions, the information features of acquired images vary significantly. For example, in scenes with excessively strong or weak lighting, the distribution of image grayscale values ​​is uneven, and the contrast between light and dark is insufficient, resulting in a decrease in overall contrast. This manifests as blurry images, loss of detail, and can easily cause visual fatigue in observers. To address this problem, image contrast stretching algorithms can be used to improve image readability. However, a single contrast stretching algorithm lacks scene adaptability and is difficult to universally apply to various imaging environments.

[0003] Histograms are a statistical image analysis method where the horizontal axis represents gray levels and the vertical axis represents the pixel distribution frequency corresponding to each gray level. By analyzing histograms, the gray-level distribution characteristics of an image can be effectively understood, thereby determining its brightness and contrast. If the image is dark, the histogram will be biased towards the low gray-level range; conversely, if the image is bright, the histogram will be concentrated in the high gray-level range. By adjusting the gray-level distribution, the brightness of the image can be corrected. Histogram equalization is a classic enhancement technique. Its core idea is to transform the histogram distribution of the original image into an approximately uniform distribution to improve the visual effect of the image. However, existing methods often suffer from distortion, such as the overall darkening or brightening of the enhanced image, due to interference from image edge regions or invalid information. Summary of the Invention

[0004] Based on this, this invention proposes a contrast enhancement method based on image features. By precisely setting the mapping interval, over-enhancement of unimportant background or noisy areas can be avoided, resulting in processing results that better meet expectations and produce a more natural visual effect. It also boasts high computational efficiency. In many scenarios where extremely complex processing is not required, it can achieve satisfactory enhancement results with minimal computational cost.

[0005] To achieve the above objectives, the technical solution of this invention is implemented as follows: a contrast enhancement method based on image features, comprising: S1: Obtain the grayscale histogram of the image.

[0006] S2: Based on the gray-level histogram, determine the effective gray-level range of the image and the mode gray-level value of the image.

[0007] S3: Based on the mode grayscale value, optimize the effective grayscale range by combining the preset basic cropping ratio factor, and extract the optimized mapping range within the effective grayscale range.

[0008] S4: Map the gray values ​​of the image to the optimized mapping range, crop the gray values ​​outside the optimized mapping range to obtain the processed mapping range, and linearly map the gray values ​​in the processed mapping range to the full range of [0, 255] to obtain the contrast-enhanced image.

[0009] Furthermore, the effective grayscale range is determined by traversing the grayscale histogram; the mode grayscale value refers to the grayscale level with the highest probability of occurrence.

[0010] Furthermore, the formula for calculating the probability of grayscale level occurrence is: ; in, M×N represents the probability of the k-th gray level appearing in the image, and M×N represents the size of the image. This indicates the number of times the k-th gray level appears.

[0011] Furthermore, step S3 includes the following steps: S31: Based on the relative position of the mode grayscale value within the effective grayscale range, and combined with the preset basic cropping factor, the effective grayscale range is adjusted to obtain the minimum cropping factor and the maximum cropping factor, as shown in the following formula: ; ; Where P represents the basic cutting ratio factor. This represents the minimum cropping ratio factor. Indicates the maximum cropping ratio factor; This represents the smallest gray level whose probability of appearing in the effective grayscale range is not zero. The highest gray level whose probability of appearing in the effective gray range is not zero is represented by... ; S32: Sort all gray levels in the image according to their gray values ​​to obtain an ordered sequence; S33: Based on the minimum and maximum cropping ratio factors, the optimized mapping interval is calculated within the effective grayscale range according to the ordered sequence. ; ; Where Z represents an ordered sequence, and L represents the length of the ordered sequence Z. This represents the minimum gray level of the optimized mapping interval. This represents the maximum gray level of the optimized mapping interval.

[0012] Furthermore, step S4 specifically includes: S41: Limit the grayscale values ​​of all pixels in the image to the optimized mapping range, with the following replacement rules: ; in, This represents the original grayscale value of the i-th pixel in the image; The replacement function represents the replacement of grayscale values. The result after the replacement; S42: By using a linear mapping function, all gray values ​​located within the processed mapping interval are mapped to the full gray range of [0, 255], thereby obtaining an image with enhanced contrast.

[0013] Furthermore, the linear mapping function is: ; in, This represents a linear mapping function.

[0014] The present invention can achieve the following beneficial effects: 1) This invention dynamically adjusts the cropping ratio factor based on the position of the mode of the image, and can automatically adapt to images with different brightness, achieving more intelligent and reasonable contrast stretching.

[0015] 2) The method of this invention maintains computational simplicity while adaptively adjusting. It achieves adaptive allocation of the clipping ratio through only a simple linear interpolation relationship, without introducing complex iterations or transformations, resulting in low computational cost and ease of understanding and implementation.

[0016] 3) Determining the new interval boundaries using the minimum and maximum cropping factors ensures that a few extreme outlier pixels in the image are effectively excluded from the optimized mapping interval after grayscale value sorting, thus preventing them from interfering with the contrast stretching effect of the main image. Finally, by generating an adaptive optimized mapping interval, the entire method can flexibly adapt to input images with different brightness and contrast.

[0017] 4) By selectively focusing on specific grayscale ranges in an image and linearly amplifying the grayscale differences within these ranges, the contrast of image details within that region is maximized, significantly improving the visual effect and analyzability of the image. Compared to other complex algorithms, this method, through precise setting of the mapping range, avoids over-enhancing unimportant background or noisy areas, resulting in more expected processing results and a more natural visual effect. It is computationally efficient. In many scenarios where extremely complex processing is not required, it can achieve satisfactory enhancement results with minimal computational cost. Attached Figure Description

[0018] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments and descriptions of the invention are used to explain the invention and do not constitute an undue limitation of the invention. In the drawings: Figure 1 This is a flowchart of a contrast enhancement method based on image features provided according to an embodiment of the present invention; Figure 2 This is a comparison image of processing by a traditional histogram equalization method and a contrast enhancement method based on image features, provided according to an embodiment of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not constitute a limitation thereof.

[0020] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other.

[0021] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation on this invention. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first," "second," etc., may explicitly or implicitly include one or more of that feature. In the description of this invention, unless otherwise stated, "a plurality of" means two or more.

[0022] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art will understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0023] The invention will now be described in detail with reference to specific embodiments.

[0024] like Figures 1 to 2 As shown in the figure, an embodiment of the present invention provides a contrast enhancement method based on image features, comprising: S1: Obtain the grayscale histogram of the image.

[0025] It should be noted that obtaining the grayscale histogram of an image is an existing technique and will not be described in detail here.

[0026] S2: Determine the effective gray-level range of the image based on the gray-level histogram. , and the mode gray value of the image. Specifically, this includes: Effective grayscale range [ , This is determined by traversing the grayscale histogram; where, This represents the smallest gray level with a non-zero probability of occurrence. The highest gray level with a non-zero probability of occurrence is represented as... The mode grayscale value is the grayscale level that appears with the highest probability.

[0027] S3: Using the mode grayscale value Based on this, and combined with a preset basic cropping ratio factor, the effective grayscale range is optimized, and within the effective grayscale range [ , Extract the optimized mapping interval within [ ] , Specifically, the steps include the following: S31: Based on the mode grayscale value Within the effective grayscale range, the relative position, combined with the preset basic cropping factor, determines the effective grayscale range [ , Adjustments are made to obtain the minimum and maximum cropping ratio factors, as shown in the following formulas: ; ; Where P represents the basic cutting ratio factor. ; This represents the minimum pruning ratio factor for the optimized mapping interval. This represents the maximum pruning ratio factor for the optimized mapping interval.

[0028] Mode gray value The relative position within the effective grayscale range is related to the probability of occurrence of each grayscale level. By calculating the probability of occurrence of each grayscale level in the image, the grayscale level corresponding to the highest probability is determined as the mode grayscale value. The probability formula is: ; in, M×N represents the probability of the k-th gray level appearing in the image, and M×N represents the size of the image. This indicates the number of times the k-th gray level appears.

[0029] This invention does not simply crop out data at the same proportion at both ends, but dynamically adjusts the cropping ratio factor based on the position of the mode of the image (which can approximately represent the most important gray level in the image).

[0030] When the mode is biased towards the low grayscale area (the overall image is dark): It will get smaller. It will become larger. At this point, the algorithm will retain more details in the shadows (because less is cropped at the minimum end) and crop more of the extreme values ​​in the highlights (because more are cropped at the maximum end).

[0031] When the mode is biased towards high grayscale areas (the overall image is brighter): the opposite is true. Get bigger Make it smaller. This will preserve more detail in the highlights and crop out more noise in the shadows.

[0032] The method of this invention can automatically adapt to images with different brightness levels, achieving more intelligent and reasonable contrast stretching.

[0033] The method of this invention maintains computational simplicity while adaptively adjusting. It achieves adaptive allocation of the clipping ratio through only a simple linear interpolation relationship, without introducing complex iterations or transformations, resulting in low computational cost and ease of understanding and implementation.

[0034] S32: Sort all gray levels in the image according to their gray values ​​to obtain an ordered sequence Z; the sorting can be done in ascending order or descending order of gray levels.

[0035] S33: Based on the minimum and maximum cropping factors, within the effective grayscale range [ , Within ], the optimized mapping interval is calculated based on the ordered sequence. , ]; ; ; Where Z represents an ordered sequence, and L represents the length of the ordered sequence Z. This represents the minimum gray level in the optimized mapping range. This represents the maximum gray level of the mapped range after optimization.

[0036] This method determines the new interval boundaries by using the minimum and maximum cropping factors, ensuring that any extreme outliers (such as CCD noise) in the image are effectively excluded from the optimized mapping interval after grayscale value sorting. , In addition, this prevents them from interfering with the contrast stretching effect of the main image. Finally, by generating an adaptive optimized mapping range, the entire method can flexibly adapt to input images with different brightness and contrast.

[0037] S4: Map the grayscale values ​​of the image to the optimized mapping range. , Within the range, the gray values ​​outside the range are cropped to obtain the processed mapping range. The gray values ​​within the processed mapping range are linearly mapped to the full range of [0, 255], and the contrast-enhanced image is output.

[0038] Specifically, the image's grayscale value is less than the minimum grayscale level of the optimized mapping interval. Set its grayscale value to The image's grayscale value is greater than the maximum grayscale level of the optimized mapping interval. Set its grayscale value to The mapping interval will be optimized. , The gray values ​​of the image within the range are mapped to the full gray range of [0, 255] using a linear mapping function.

[0039] By selectively focusing on specific grayscale ranges in an image and linearly amplifying the grayscale differences within those ranges, the contrast of image details in that area is maximized, significantly improving the visual quality and analyzability of the image.

[0040] Compared to other complex algorithms, this method, by precisely setting the optimization mapping interval, avoids over-enhancing unimportant background or noisy regions, resulting in more satisfactory processing results and a more natural visual effect. It is also computationally efficient. In many scenarios that do not require extremely complex processing, it can achieve satisfactory enhancement results with minimal computational cost.

[0041] Step S4 includes the following steps: S41: Limit the grayscale values ​​of all pixels in the image to the optimized mapping range. , Within this section, the replacement rules are as follows: ; in, This represents the original grayscale value of the i-th pixel in the image; The replacement function represents the replacement of grayscale values. The result after the replacement.

[0042] S42: Using a linear mapping function, all gray values ​​located within the mapping interval obtained in step S41 are mapped to the full gray range of [0, 255], thereby obtaining an image with enhanced contrast.

[0043] It should be noted that the mapping interval after step S41 is the same as the optimized mapping interval, both being [ , ].

[0044] The linear mapping function is: ; in, This represents a linear mapping function.

[0045] The optimized mapping range is linearly stretched to the full 0-255 dynamic range, proportionally amplifying the originally subtle grayscale differences within this range, thereby significantly improving the clarity and recognizability of image details. By employing linear transformation to strictly maintain the relative relationships of pixel grayscale, the enhanced image will not exhibit structural distortion or grayscale inversion, ensuring a realistic and natural enhancement result that conforms to visual perception.

[0046] The effectiveness of the method of the present invention will be illustrated below with a specific embodiment. We selected images from three typical scenarios—too dark, moderately bright, and too bright—for testing, and the results are as follows: Figure 2 As shown.

[0047] Figure 2 In the diagram: (a) shows the original images with three different brightness levels (too dark, moderate, and too bright). (b) shows the grayscale histograms of the three images in (a). (c) shows the results after applying traditional histogram equalization to the image in (a). (d) shows the results after applying the method of this invention to the image in (a).

[0048] The results clearly show that: For images that are too dark, the result of traditional histogram equalization is still too dark. However, after processing by the method of this invention, the image brightness is effectively corrected, and the visual effect is closer to the real scene.

[0049] For images with moderate brightness, traditional methods tend to result in darker images and may amplify noise; in contrast, the method of this invention improves contrast while better maintaining the natural look of the image.

[0050] For overly bright images, traditional methods still result in overly bright images with a loss of detail; however, the method of this invention can effectively suppress highlights, recover more details, and make the imaging effect more realistic.

[0051] In summary, the image feature-based contrast enhancement method of the present invention has the following advantages: 1) This invention dynamically adjusts the cropping ratio factor based on the position of the mode of the image, and can automatically adapt to images with different brightness, achieving more intelligent and reasonable contrast stretching.

[0052] 2) The method of this invention maintains computational simplicity while adaptively adjusting. It achieves adaptive allocation of the clipping ratio through only a simple linear interpolation relationship, without introducing complex iterations or transformations, resulting in low computational cost and ease of understanding and implementation.

[0053] 3) Determining the new interval boundaries using the minimum and maximum cropping factors ensures that a few extreme outlier pixels in the image are effectively excluded from the optimized mapping interval after grayscale value sorting, thus preventing them from interfering with the contrast stretching effect of the main image. Finally, by generating an adaptive optimized mapping interval, the entire method can flexibly adapt to input images with different brightness and contrast.

[0054] 4) By selectively focusing on specific grayscale ranges in an image and linearly amplifying the grayscale differences within these ranges, the contrast of image details within that region is maximized, significantly improving the visual effect and analyzability of the image. Compared to other complex algorithms, this method, through precise setting of the mapping range, avoids over-enhancing unimportant background or noisy areas, resulting in more expected processing results and a more natural visual effect. It is computationally efficient. In many scenarios where extremely complex processing is not required, it can achieve satisfactory enhancement results with minimal computational cost.

[0055] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A contrast enhancement method based on image features, characterized in that, include: S1: Obtain the grayscale histogram of the image; S2: Based on the grayscale histogram, determine the effective grayscale range of the image and the mode grayscale value of the image; S3: Based on the mode grayscale value, optimize the effective grayscale range by combining the preset basic cropping ratio factor, and extract the optimized mapping range within the effective grayscale range. S4: Map the gray values ​​of the image to the optimized mapping range, crop the gray values ​​outside the optimized mapping range to obtain the processed mapping range, and linearly map the gray values ​​in the processed mapping range to the full range of [0, 255] to obtain the contrast-enhanced image.

2. The image feature-based contrast enhancement method according to claim 1, characterized in that, The effective grayscale range is determined by traversing the grayscale histogram; the mode grayscale value refers to the grayscale level with the highest probability of occurrence.

3. The image feature-based contrast enhancement method according to claim 2, characterized in that, The formula for calculating the probability of gray levels is: ; in, M×N represents the probability of the k-th gray level appearing in the image, and M×N represents the size of the image. This indicates the number of times the k-th gray level appears.

4. The image feature-based contrast enhancement method according to claim 1, characterized in that, Step S3 includes the following steps: S31: Based on the relative position of the mode grayscale value within the effective grayscale range, and in conjunction with a preset basic cropping factor, the effective grayscale range is adjusted to obtain the minimum cropping factor and the maximum cropping factor, as shown in the following formula: ; ; Where P represents the basic cutting ratio factor. This represents the minimum cropping ratio factor. Indicates the maximum cropping ratio factor; This represents the smallest gray level whose probability of appearing in the effective grayscale range is not zero. The highest gray level whose probability of appearing in the effective gray range is not zero is represented by... ; S32: Sort all gray levels in the image according to their gray values ​​to obtain an ordered sequence; S33: Based on the minimum and maximum cropping ratio factors, the optimized mapping interval is calculated within the effective grayscale range according to the ordered sequence. ; ; Where Z represents an ordered sequence, and L represents the length of the ordered sequence Z. This represents the minimum gray level of the optimized mapping interval. This represents the maximum gray level of the optimized mapping interval.

5. The image feature-based contrast enhancement method according to claim 1, characterized in that, Step S4 specifically includes: S41: Limit the grayscale values ​​of all pixels in the image to the optimized mapping range to obtain the processed mapping range. The replacement rules are as follows: ; in, This represents the original grayscale value of the i-th pixel in the image; The replacement function represents the replacement of grayscale values. The result after the replacement; S42: By using a linear mapping function, all gray values ​​located within the processed mapping interval are mapped to the full gray range of [0, 255], thereby obtaining an image with enhanced contrast.

6. The image feature-based contrast enhancement method according to claim 5, characterized in that, The linear mapping function is: ; in, This represents a linear mapping function.