A method, apparatus and terminal for enhancing image contrast
By segmenting the image into blocks and judging gradient values, the histogram distribution of the CLAHE algorithm is adjusted, which solves the problems of unnatural transitions at the junction of gray-level approximation regions and texture detail regions, as well as inconsistent contrast in flat regions, thus improving image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
- Filing Date
- 2022-12-22
- Publication Date
- 2026-04-24
AI Technical Summary
The existing CLAHE algorithm, after enhancing image contrast, results in unnatural transitions between large areas of similar grayscale and areas of detailed texture, and inconsistent contrast enhancement within flat areas.
The image is divided into multiple image blocks. The gradient value of each image block is calculated and its type is determined. The cumulative histogram average value of the flat region and the flat texture detail junction region are calculated respectively. The cumulative histogram distribution is adjusted according to the gray-scale average value of the adjacent image blocks. The contrast-limited adaptive histogram equalization algorithm is used for enhancement.
The algorithm improves the unnatural transition between large gray-scale approximation regions and texture detail regions in images processed by the CLAHE algorithm, and solves the problem of inconsistent contrast enhancement in flat areas, thus improving image quality.
Smart Images

Figure CN115880181B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of smart terminal technology, and in particular to a method, apparatus and terminal for enhancing image contrast. Background Technology
[0002] With the continuous development of technology, digital imaging technology has brought great convenience to people's lives. However, due to the influence of scene and equipment, the obtained digital images often suffer from problems such as overly concentrated gray-level histogram distribution and low image contrast. To improve visual quality and extract useful information from images, it is necessary to enhance image contrast. Histogram-based contrast enhancement methods are widely used in image contrast enhancement because they have relatively complete mathematical theory, low computational cost, and are easy to program. Currently, improvements have been made to the classic histogram equalization (HE) algorithm, resulting in several image contrast enhancement algorithms that have been widely applied, such as the Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm.
[0003] Although the CLAHE algorithm effectively solves the problem of amplifying noise in large areas of similar grayscale in the Adaptive Histogram Equalization algorithm, after the image is enhanced by the CLAHE algorithm, the transition between large flat areas with similar grayscale values and other texture details in the image is not natural. There will be obvious "halo" at the junction, and the processed image will also show obvious inconsistencies in contrast enhancement in flat areas. Summary of the Invention
[0004] This invention provides a method, apparatus, and terminal for enhancing image contrast, which can significantly improve the performance of the CLAHE algorithm while maintaining its characteristic of not amplifying noise in large areas of similar grayscale.
[0005] In a first aspect, the present invention provides a method for enhancing image contrast, the method comprising:
[0006] The image to be processed is divided into at least two image blocks according to a preset size;
[0007] Calculate the gradient value of each image patch, and determine whether the image to be processed contains flat region image patches or flat texture detail intersection region image patches based on the gradient value of each image patch;
[0008] When the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, 5 divides the flat texture detail intersection region image blocks into at least two groups, and calculates the average of the cumulative histogram distribution corresponding to each group.
[0009] Based on the image blocks adjacent to the flat region image block, the cumulative histogram distribution of the flat region image block is replaced with the average of the cumulative histograms of one of the groups;
[0010] The contrast of other image blocks is enhanced using a contrast-limited adaptive histogram equalization algorithm, and the output image is obtained.
[0011] Optionally, the step of calculating the gradient value of each image patch and determining whether the image to be processed contains flat region image patches or flat texture detail junction region image patches based on the gradient values of each image patch includes:
[0012] Calculate the mean gray level of pixels in the image to be processed, the image noise level, and the mean gray level of pixels in each image block;
[0013] 5. Calculate the gradient value of each image patch, statistically analyze the gradient value of each image patch, and compare it with the preset parameters.
[0014] The system then determines, based on the judgment result, whether the image to be processed contains flat region image blocks or flat texture detail intersection region image blocks.
[0015] Optionally, the step of calculating the gradient value of each image patch, statistically analyzing the gradient value of each image patch and comparing it with preset parameters, and determining whether the image to be processed contains flat region image patches or 0-flat texture detail junction region image patches based on the judgment result includes:
[0016] Calculate the gradient value for each image patch;
[0017] After obtaining the gradient values of each image block, the proportion of pixels with larger gradient values in each image block is calculated.
[0018] When the ratio is within the first preset range, the image block is a flat area image block; when the ratio is within the second preset range, the image block is a flat texture detail junction area image block.
[0019] Optionally, the image block gradient value being large is determined by comparing the gradient magnitude of the image block with a first threshold to determine whether the image block gradient value is large.
[0020] The first threshold corresponds to the image noise level.
[0021] Optionally, when the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, the flat texture detail intersection region image blocks are divided into at least two groups, and the average of the corresponding cumulative histograms is calculated for each group.
[0022] When the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, the histogram and cumulative histogram of the flat texture detail intersection region image blocks are calculated according to the limited contrast adaptive histogram equalization algorithm.
[0023] Based on the average pixel grayscale value of the image block in the flat texture detail junction region and the average pixel grayscale value of the image to be processed, the image block in the flat texture detail junction region is divided into at least two groups, and the average cumulative histogram of all image blocks in each group is calculated.
[0024] Optionally, the step of dividing the image patch of the flat texture detail junction region into at least two groups based on the average pixel grayscale value of the image patch and the average pixel grayscale value of the image to be processed, and calculating the average of the cumulative histograms of all image patches in each group, includes:
[0025] The image blocks in the flat texture detail junction region whose average pixel grayscale value is greater than the average pixel grayscale value of the image to be processed are taken as the first group, and the average of the cumulative histograms of all image blocks in the first group is calculated.
[0026] The image blocks in the flat texture detail junction region whose average pixel grayscale value is not greater than the average pixel grayscale value of the image to be processed are designated as the second group, and the average of the cumulative histograms of all image blocks in the second group is calculated.
[0027] Optionally, replacing the cumulative histogram distribution of the flat region image patch with the average of the cumulative histograms of one of the adjacent image patches includes:
[0028] Obtain image blocks adjacent to the flat region image block;
[0029] Determine the magnitude of the average pixel grayscale value of the adjacent image blocks and the average pixel grayscale value of the image to be processed;
[0030] When the average pixel gray value of the adjacent image blocks is greater than the average pixel gray value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the first group.
[0031] When the average pixel grayscale value of the adjacent image blocks is not greater than the average pixel grayscale value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the second group.
[0032] Optionally, the step of enhancing the contrast of other image patches according to the contrast-limited adaptive histogram equalization algorithm to obtain the output image includes:
[0033] After replacing the cumulative histogram distribution of the flat region image block, the cumulative histograms of other image blocks are calculated using a contrast-limited adaptive histogram equalization algorithm.
[0034] The contrast-enhanced output image is obtained by weighted averaging using a contrast-limited adaptive histogram equalization algorithm.
[0035] In a second aspect, the present invention provides an apparatus for enhancing image contrast, the apparatus comprising:
[0036] The segmentation unit is used to divide the image to be processed into at least two image blocks according to a preset size;
[0037] The first calculation unit is used to calculate the gradient value of each image patch;
[0038] The first judgment unit is used to determine whether the image to be processed has flat region image blocks and flat texture detail intersection region image blocks based on the gradient value of each image block;
[0039] The second calculation unit is used to divide the flat texture detail intersection area image block into at least two groups when the image to be processed contains flat area image blocks and flat texture detail intersection area image blocks, and calculate the average of the cumulative histogram distribution corresponding to each group respectively.
[0040] A designated unit is configured to replace the cumulative histogram distribution of the flat region image block with the average of the cumulative histograms of one of the adjacent image blocks of the flat region image block;
[0041] The contrast enhancement unit is used to enhance the contrast of other image blocks according to the limited contrast adaptive histogram equalization algorithm to obtain the output image.
[0042] Optionally, the first determination unit includes:
[0043] The first calculation module is used to calculate the average gray level of the pixels in the image to be processed, the image noise level, and the average gray level of the pixels in each image block.
[0044] The second calculation module is used to calculate the gradient values of each image patch;
[0045] The statistical judgment module is used to obtain the gradient value of each image block and then calculate the proportion of pixels with larger gradient values in each image block to the total number of pixels in the image block. If the proportion is within a first preset range, the image block is a flat region image block. If the proportion is within a second preset range, the image block is a flat texture detail junction region image block.
[0046] Optionally, the second computing unit includes:
[0047] The third calculation module is used to calculate the histogram and cumulative histogram of the flat texture detail intersection area image block according to the limited contrast adaptive histogram equalization algorithm when the image to be processed contains flat area image blocks and flat texture detail intersection area image blocks.
[0048] The grouping module is used to divide the image blocks of the flat texture detail junction region into at least two groups based on the average pixel grayscale value of the image blocks of the flat texture detail junction region and the average pixel grayscale value of the image to be processed, and to calculate the average of the cumulative histograms of all image blocks in each group.
[0049] Optionally, the designated unit includes:
[0050] The acquisition module is used to acquire image blocks adjacent to the flat region image block;
[0051] A designated module is used to determine the magnitude of the average pixel grayscale value of the adjacent image blocks and the average pixel grayscale value of the image to be processed. When the average pixel grayscale value of the adjacent image blocks is greater than the average pixel grayscale value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the first group. When the average pixel grayscale value of the adjacent image blocks is not greater than the average pixel grayscale value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the second group.
[0052] Optionally, the contrast enhancement unit includes:
[0053] The fourth calculation module is used to calculate the cumulative histogram of other image blocks by using a contrast-limited adaptive histogram equalization algorithm after replacing the cumulative histogram distribution of the flat region image blocks.
[0054] The enhancement module is used to perform weighted averaging using a contrast-limited adaptive histogram equalization algorithm to obtain a contrast-enhanced output image.
[0055] Thirdly, the present invention provides a terminal, the terminal including the above-described device for enhancing image contrast.
[0056] The method, apparatus, and terminal for enhancing image contrast provided by this invention can significantly improve the performance of the CLAHE algorithm while maintaining its characteristic of not amplifying noise in large areas of similar grayscale. On the one hand, it can greatly improve the unnatural halo phenomenon at the junction of large areas of similar grayscale and other texture detail areas in the image processed by the CLAHE algorithm; on the other hand, it can effectively improve the problem of inconsistent contrast enhancement in flat areas in the image processed by the CLAHE algorithm. Attached Figure Description
[0057] Figure 1 This is a flowchart of a method for enhancing image contrast according to an embodiment of the present invention;
[0058] Figure 2 A flowchart of a method for enhancing image contrast according to another embodiment of the present invention;
[0059] Figure 3 This is a flowchart of a method for enhancing image contrast according to another embodiment of the present invention;
[0060] Figure 4 This is a flowchart of a method for enhancing image contrast according to another embodiment of the present invention;
[0061] Figure 5 This is a schematic diagram of the structure of an image contrast enhancement device according to an embodiment of the present invention;
[0062] Figure 6 This is a schematic diagram of a device for enhancing image contrast according to another embodiment of the present invention. Detailed Implementation
[0063] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0064] This invention provides a method for enhancing image contrast, such as... Figure 1 As shown, the method includes:
[0065] S11. Divide the image to be processed into at least two image blocks according to a preset size;
[0066] S12. Calculate the gradient value of each image block, and determine whether there are flat region image blocks or flat texture detail intersection region image blocks in the image to be processed based on the gradient value of each image block.
[0067] S13. When the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, the flat texture detail intersection region image blocks are divided into at least two groups, and the average of the cumulative histogram distribution corresponding to each group is calculated respectively.
[0068] S14. Based on the image blocks adjacent to the flat region image block, replace the cumulative histogram distribution of the flat region image block with the average of the cumulative histograms of one of the groups;
[0069] S15. Perform contrast enhancement on other image blocks using the contrast-limited adaptive histogram equalization algorithm to obtain the output image.
[0070] The method for enhancing image contrast provided in this invention can significantly improve the performance of the CLAHE algorithm while maintaining its characteristic of not amplifying noise in large areas of similar grayscale. On the one hand, it can greatly improve the unnatural halo phenomenon at the junction of large areas of similar grayscale and other texture detail areas in the image processed by the CLAHE algorithm; on the other hand, it can effectively improve the problem of inconsistent contrast enhancement in flat areas in the image processed by the CLAHE algorithm.
[0071] like Figure 2 As shown, optionally, the step of calculating the gradient value of each image patch and determining whether the image to be processed contains flat region image patches and flat texture detail junction region image patches based on the gradient value of each image patch includes:
[0072] S121. Calculate the mean gray value of pixels in the image to be processed, the image noise level, and the mean gray value of pixels in each image block.
[0073] S122. Calculate the gradient value of each image block, count the gradient value of each image block and compare it with the preset parameters to determine whether the image to be processed has flat area image blocks or flat texture detail intersection area image blocks.
[0074] Optionally, the step of calculating the gradient value of each image patch, statistically analyzing the gradient value of each image patch and comparing it with preset parameters, and determining whether the image to be processed contains flat region image patches or flat texture detail junction region image patches based on the judgment result includes:
[0075] S1221. Calculate the gradient value of each image patch;
[0076] S1222. After obtaining the gradient values of each image block, calculate the proportion of pixels with larger gradient values in each image block to the total number of pixels in the image block.
[0077] S1223. When the ratio is within the first preset range, the image block is a flat area image block;
[0078] S1224. If the ratio is within the second preset range, then the image block is a flat texture detail junction area image block; or, calculate the gradient value of each image block, statistically analyze the gradient value of each image block and compare it with preset parameters to determine whether the image to be processed contains a flat area image block, a texture detail junction area image block, or a flat texture detail junction area image block.
[0079] Optionally, the image block gradient value being large is determined by comparing the gradient magnitude of the image block with a first threshold to determine whether the image block gradient value is large.
[0080] Preferably, the first threshold corresponds to the image noise level.
[0081] For example, the method described in this embodiment, when running the CLAHE algorithm, firstly divides the image to be processed into at least two image blocks according to a preset size. Each pixel in the image to be processed belongs to one and only one image block. Then, the average gray value of all pixels in the image to be processed, the noise level of the image, and the average gray value of the pixels contained in each image block are calculated. Then, the gradient value of each image block is calculated. Based on the proportion of pixels with larger gradient magnitudes in each image block to all pixels in the image block, flat region image blocks and flat texture detail junction region image blocks are selected. Then, the cumulative histogram of each flat texture detail junction region image block is calculated according to the "cropping" method of the CLAHE algorithm. Finally, based on the flat texture detail junction region image block... The algorithm considers the relationship between the average grayscale value of pixels in the detail transition region image block and the average grayscale value of all pixels in the image to be processed. It divides the selected flat texture detail transition region image block into at least two categories, calculates the average cumulative histogram for each category, and then finds a non-flat region image block adjacent to the selected flat region image block. Based on the relationship between the average grayscale value of pixels in this image block and the average grayscale value of all pixels in the image, the average cumulative histogram calculated for this image block is selected as the contrast enhancement function for the selected flat region image block. For the remaining image blocks, the corresponding "cropping" histogram and cumulative histogram are calculated according to the CLAHE algorithm. Finally, pixel interpolation is performed according to the traditional CLAHE algorithm to obtain the contrast-enhanced image. This method effectively solves the problems of unnatural transitions between large areas of similar grayscale and other texture detail regions, halo effects, and inconsistent contrast enhancement in flat regions that exist in images processed by the CLAHE algorithm. Furthermore, the algorithm described in this embodiment can be further embedded into a chip to improve operating speed.
[0082] Optionally, such as Figure 3As shown, when the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, the flat texture detail intersection region image blocks are divided into at least two groups, and the average of the corresponding cumulative histograms is calculated for each group.
[0083] S131. When the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, calculate the histogram and cumulative histogram for the flat texture detail intersection region image blocks according to the limited contrast adaptive histogram equalization algorithm.
[0084] S132. Based on the average pixel grayscale value of the image block in the flat texture detail junction region and the average pixel grayscale value of the image to be processed, divide the image block in the flat texture detail junction region into at least two groups, and calculate the average of the cumulative histograms of all image blocks in each group.
[0085] Optionally, the step of dividing the image patch of the flat texture detail junction region into at least two groups based on the average pixel grayscale value of the image patch and the average pixel grayscale value of the image to be processed, and calculating the average of the cumulative histograms of all image patches in each group, includes:
[0086] S1321. The image blocks in the flat texture detail junction region where the average pixel gray value is greater than the average pixel gray value of the image to be processed are taken as the first group, and the average of the cumulative histograms of all image blocks in the first group is calculated.
[0087] S1322. The image blocks in the flat texture detail junction region where the average pixel gray value is not greater than the average pixel gray value of the image to be processed are taken as the second group, and the average of the cumulative histograms of all image blocks in the second group is calculated.
[0088] Optionally, replacing the cumulative histogram distribution of the flat region image patch with the average of the cumulative histograms of one of the adjacent image patches includes:
[0089] S141. Obtain image blocks adjacent to the flat region image block;
[0090] S142. Determine the magnitude of the average pixel grayscale value of the adjacent image blocks and the average pixel grayscale value of the image to be processed.
[0091] S143. When the average pixel gray value of the adjacent image blocks is greater than the average pixel gray value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the first group.
[0092] S144. When the average pixel gray value of the adjacent image blocks is not greater than the average pixel gray value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the second group.
[0093] Optionally, such as Figure 4 As shown, the step of enhancing the contrast of other image patches using the contrast-limited adaptive histogram equalization algorithm to obtain the output image includes:
[0094] S151. After replacing the cumulative histogram distribution of the flat region image block, calculate the cumulative histogram of other image blocks using the contrast-limited adaptive histogram equalization algorithm.
[0095] S152. Weighted averaging is performed using a contrast-limited adaptive histogram equalization algorithm to obtain the contrast-enhanced output image.
[0096] For example, the method described in this embodiment can effectively improve the contrast enhancement effect of the CLAHE algorithm. Specifically, the method first divides the image into several image blocks of equal size, with each pixel in the image belonging to one and only one image block. Traditional CLAHE algorithms process all image blocks identically, without distinguishing whether the content within the processed image block belongs to a flat region, a flat-texture detail transition region, or a texture detail region. Furthermore, it does not consider the relationships between image blocks with different content. This results in large areas of unnatural transitions between flat regions and texture detail regions with similar gray levels, the appearance of halos, and inconsistent contrast enhancement in flat regions. To address these issues, the method described in this embodiment classifies the image blocks. In specific implementation, the average pixel gray level of the entire image to be processed, the image noise level, and the average pixel gray level of each image block are first calculated. Then, the gradient value of each image block is calculated. After obtaining the gradient of each image block, the proportion of pixels with larger gradient magnitudes within each image block is calculated. When determining whether a gradient magnitude is "large," it is necessary to compare the gradient magnitude with a first threshold related to the calculated image noise level. After obtaining the proportion of pixels with large gradient magnitudes within an image patch, the type of the image patch can be determined: if the proportion is within a first preset interval (or the first range is 0-50%, or the proportion is small), it indicates that most pixels in the image patch have very small gradient values, and the image patch can be classified as a flat region image patch; if the proportion is within a second preset interval (or the second range is 51-100%, or the proportion is moderate), it indicates that the number of pixels with large gradient magnitudes and the number of pixels with small gradient magnitudes are not significantly different, and the image patch can be classified as a flat texture detail junction region image patch. After determining the flat texture detail junction region image patches, the (cropped) histogram and corresponding cumulative histogram of each selected flat texture detail junction region image patch are calculated in the form of "cropped" histograms in the traditional CLAHE algorithm. Subsequently, based on the relationship between the average pixel grayscale value of the selected flat texture detail junction region image blocks and the average pixel grayscale value of the entire image, the selected flat texture detail junction region image blocks are divided into two groups: one group of image blocks has an average pixel grayscale value greater than the average pixel grayscale value of the entire image; the other group of image blocks has an average pixel grayscale value no greater than the average pixel grayscale value of the entire image. After dividing the selected flat texture detail junction region image blocks into two categories, the average of the cumulative histograms of all image blocks in each category is calculated. For ease of explanation, these are named avg_acc_H respectively. up and avg_acc_H below ;where avg_acc_H upIt is the average of the cumulative histograms of selected flat texture detail junction areas where the average gray level of pixels within a block is greater than the average gray level of the entire image, avg_acc_H below It is the average of the cumulative histograms of image blocks in selected flat texture detail junction areas where the average gray level of pixels within the block is less than the average gray level of the entire image.
[0097] To improve upon the issues of unnatural transitions, halos at the junctions, and inconsistent contrast enhancement in flat regions after processing with the traditional CLAHE algorithm, particularly in areas with similar gray levels and textured detail regions, it is necessary to consider the relationship between flat regions and the junctions between flat and textured detail regions. Specifically, during contrast enhancement, the pixel gray-level mapping function of the flat region image block must consider the pixel gray-level mapping function of the junction image block. This unifies the contrast enhancement between the flat region and the junction, resulting in a natural transition from the flat region to the junction after contrast enhancement. In the algorithm proposed in this patent, the pixel gray-level mapping function of the flat region image block considers the pixel mapping function of the junction image block, and the pixel gray-level mapping function of the flat region image block is selected as avg_acc_H. up Or avg_acc_H below To achieve this. When selecting avg_acc_H up Or avg_acc_H below When doing this, it is necessary to find a non-flat image patch (referred to as a block) that is adjacent to the selected flat image patch. index Then, based on the image block (i.e., block) index The relationship between the average grayscale value of the selected flat region and the average grayscale value of the entire image is used to assign avg_acc_H to all selected flat region image blocks. up Or avg_acc_H below When an image block index If the average gray value of the pixels contained in the image is greater than the average gray value of all pixels in the entire image, then avg_acc_H is set to... up Assign to all selected flat area image blocks; when image block block index If the average grayscale value of the pixels contained is less than the average grayscale value of the entire image, then avg_acc_H is set to... below Assign to all selected flat area image blocks.
[0098] After specifying the cumulative histogram for the selected flat region image patch, the cumulative histogram for the remaining image patch is calculated according to the traditional CLAHE algorithm (i.e., "cropping" the histogram). (In fact, the cumulative histogram for the selected flat region has already been specified, and the cumulative histogram for the selected flat texture detail junction region image patch has already been calculated, so only the "cropping" histogram and corresponding cumulative histogram for the remaining image patch need to be calculated.) Finally, a weighted average, i.e., interpolation calculation, is performed according to the traditional CLAHE algorithm to obtain the improved CLAHE contrast enhancement algorithm output image.
[0099] In summary, compared with the prior art, the method described in the embodiments of the present invention has the following advantages:
[0100] 1. It can greatly improve the unnatural halo phenomenon that exists at the junction of large areas of similar gray and other texture detail areas in the image processed by the CLAHE algorithm.
[0101] 2. It can effectively improve the problem of inconsistent contrast enhancement in flat areas of images processed by the CLAHE algorithm.
[0102] 3. It is easy to embed onto the chip, thereby effectively improving the operating speed of the device or terminal.
[0103] This invention also provides an apparatus for enhancing image contrast, such as... Figure 5 As shown, the device includes:
[0104] The segmentation unit 11 is used to divide the image to be processed into at least two image blocks according to a preset size;
[0105] The first calculation unit 12 is used to calculate the gradient value of each image block;
[0106] The first judgment unit 13 is used to determine whether the image to be processed has flat region image blocks and flat texture detail intersection region image blocks based on the gradient value of each image block.
[0107] The second calculation unit 14 is used to divide the flat texture detail intersection region image block into at least two groups when the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, and calculate the average of the cumulative histogram distribution corresponding to each group respectively.
[0108] The designated unit 15 is used to replace the cumulative histogram distribution of the flat region image block with the average of the cumulative histograms of one of the adjacent image blocks of the flat region image block;
[0109] The contrast enhancement unit 16 is used to enhance the contrast of other image blocks according to the limited contrast adaptive histogram equalization algorithm to obtain the output image.
[0110] The image contrast enhancement device provided in this invention can significantly improve the performance of the CLAHE algorithm while maintaining its characteristic of not amplifying noise in large areas of similar grayscale. On the one hand, it can greatly improve the unnatural halo phenomenon at the junction of large areas of similar grayscale and other texture detail areas in the image processed by the CLAHE algorithm; on the other hand, it can effectively improve the problem of significant inconsistent contrast enhancement in flat areas of the image processed by the CLAHE algorithm.
[0111] Optionally, such as Figure 6 As shown, the first determination unit 13 includes:
[0112] The first calculation module 131 is used to calculate the average gray level of the pixels in the image to be processed, the image noise level, and the average gray level of the pixels in each image block.
[0113] The second calculation module 132 is used to calculate the gradient value of each image block;
[0114] The statistical judgment module 133 is used to obtain the gradient value of each image block and then calculate the proportion of pixels with larger gradient values in each image block to the pixels in the image block; when the proportion is within a first preset range, the image block is a flat region image block; when the proportion is within a second preset range, the image block is a flat texture detail junction region image block.
[0115] Optionally, the second computing unit 14 includes:
[0116] The third calculation module 141 is used to calculate the histogram and cumulative histogram of the flat texture detail intersection area image block according to the limited contrast adaptive histogram equalization algorithm when the image to be processed contains flat area image blocks and flat texture detail intersection area image blocks.
[0117] Grouping module 142 is used to divide the image block of the flat texture detail junction region into at least two groups according to the average pixel gray value of the image block of the flat texture detail junction region and the average pixel gray value of the image to be processed, and to calculate the average of the cumulative histogram of all image blocks in each group.
[0118] Optionally, the designated unit 15 includes:
[0119] Acquisition module 151 is used to acquire image blocks adjacent to the flat region image block;
[0120] The determination module 152 is used to determine the magnitude of the average pixel grayscale value of the adjacent image blocks and the average pixel grayscale value of the image to be processed; when the average pixel grayscale value of the adjacent image blocks is greater than the average pixel grayscale value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the first group; when the average pixel grayscale value of the adjacent image blocks is not greater than the average pixel grayscale value of the image to be processed, the cumulative histogram distribution of the flat region image blocks is replaced with the average of the cumulative histograms of all image blocks in the second group.
[0121] Optionally, the contrast enhancement unit 16 includes:
[0122] The fourth calculation module 161 is used to calculate the cumulative histogram of other image blocks by limiting contrast adaptive histogram equalization algorithm after replacing the cumulative histogram distribution of the flat region image block.
[0123] Enhancement module 162 is used to perform weighted averaging through a contrast-limited adaptive histogram equalization algorithm to obtain a contrast-enhanced output image.
[0124] The image contrast enhancement device provided in this embodiment of the invention, when running the CLAHE algorithm, first divides the image to be processed into at least two image blocks according to a preset size. Each pixel in the image to be processed belongs to one and only one image block. Then, it calculates the average gray value of all pixels in the image to be processed, the noise level of the image, and the average gray value of the pixels contained in each image block. Then, it calculates the gradient value of each image block. Based on the proportion of pixels with larger gradient magnitudes in each image block to all pixels in the image block, it selects flat region image blocks and flat texture detail junction region image blocks. Then, it calculates the cumulative histogram of each flat texture detail junction region image block according to the "cropping" method of the CLAHE algorithm, and then... The device calculates the average cumulative histogram of each of the selected flat texture detail junction image blocks and the average pixel grayscale of the entire image to be processed, based on the relationship between the average pixel grayscale of the selected flat texture detail junction image block and the average pixel grayscale of the entire image. Then, it identifies a non-flat region image block adjacent to the selected flat region image block and selects the average cumulative histogram of this block as the contrast enhancement function for the selected flat region image block, based on the relationship between the average pixel grayscale of this block and the average pixel grayscale of the entire image. For the remaining image blocks, the corresponding "cropping" histogram and cumulative histogram are calculated according to the CLAHE algorithm. Finally, pixel interpolation is performed according to the traditional CLAHE algorithm to obtain the contrast-enhanced image. This device effectively solves the problems of unnatural transitions between large areas of similar grayscale and other texture detail areas, halo effects, and inconsistent contrast enhancement in flat areas in images processed by the CLAHE algorithm. Furthermore, the device can further embed the algorithm described in this embodiment onto a chip to improve operating speed.
[0125] This invention also provides a terminal, which includes the above-described device for enhancing image contrast.
[0126] The terminal can be a smartphone, a digital camera, a digital camcorder, a tablet computer, an MP4 player, an MRI machine, or a CT scanner, etc.
[0127] Those skilled in the art will understand that all or part of the processes in the above method embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0128] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for enhancing image contrast, characterized in that, The method includes: The image to be processed is divided into at least two image blocks according to a preset size; Calculate the gradient value of each image patch, and determine whether the image to be processed contains flat region image patches or flat texture detail intersection region image patches based on the gradient value of each image patch; When the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, the flat texture detail intersection region image blocks are divided into at least two groups, and the average of the cumulative histogram distribution corresponding to each group is calculated. Based on the image blocks adjacent to the flat region image block, the cumulative histogram distribution of the flat region image block is replaced with the average of the cumulative histograms of one of the groups; The contrast of other image blocks is enhanced using a contrast-limited adaptive histogram equalization algorithm to obtain the output image. When the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, dividing the flat texture detail intersection region image blocks into at least two groups and calculating the average of the corresponding cumulative histograms for each group includes: when the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks, calculating the histogram and cumulative histogram for the flat texture detail intersection region image blocks according to the contrast-limited adaptive histogram equalization algorithm; dividing the flat texture detail intersection region image blocks into at least two groups based on the average pixel grayscale value of the flat texture detail intersection region image blocks and the average pixel grayscale value of the image to be processed, and calculating the average of the cumulative histograms of all image blocks in each group for each group; The step of replacing the cumulative histogram distribution of the flat region image block with the average of the cumulative histograms of one group based on the image blocks adjacent to the flat region image block includes: obtaining the image blocks adjacent to the flat region image block; determining the magnitude of the average pixel grayscale value of the adjacent image blocks and the average pixel grayscale value of the image to be processed; when the average pixel grayscale value of the adjacent image blocks is greater than the average pixel grayscale value of the image to be processed, then replacing the cumulative histogram distribution of the flat region image block with the average of the cumulative histograms of all image blocks in the first group; when the average pixel grayscale value of the adjacent image blocks is not greater than the average pixel grayscale value of the image to be processed, then replacing the cumulative histogram distribution of the flat region image block with the average of the cumulative histograms of all image blocks in the second group.
2. The method according to claim 1, characterized in that, The calculation of the gradient value of each image patch, and the determination of whether the image to be processed contains flat region image patches and flat texture detail junction region image patches based on the gradient value of each image patch, includes: Calculate the mean gray level of pixels in the image to be processed, the image noise level, and the mean gray level of pixels in each image block; The gradient value of each image block is calculated, the gradient value of each image block is statistically analyzed and compared with the preset parameters, and the judgment result is used to determine whether there are flat region image blocks and flat texture detail intersection region image blocks in the image to be processed.
3. The method according to claim 2, characterized in that, The process of calculating the gradient value of each image patch, statistically analyzing the gradient value of each image patch and comparing it with preset parameters, and determining whether the image to be processed contains flat region image patches or flat texture detail junction region image patches based on the judgment result includes: Calculate the gradient value for each image patch; After obtaining the gradient values of each image block, the proportion of pixels with larger gradient values in each image block is calculated. When the ratio is within the first preset range, the image block is a flat area image block; When the ratio is within the second preset range, the image block is a flat texture detail junction area image block.
4. The method according to claim 3, characterized in that, The condition that the gradient value of an image block is large is determined by comparing the gradient magnitude of the image block with a first threshold. The first threshold corresponds to the image noise level.
5. The method according to claim 1, characterized in that, The step of dividing the image blocks in the flat texture detail junction region into at least two groups based on the average pixel grayscale value of the image blocks in the flat texture detail junction region and the average pixel grayscale value of the image to be processed, and calculating the average of the cumulative histograms of all image blocks in each group, includes: The image blocks in the flat texture detail junction region whose average pixel grayscale value is greater than the average pixel grayscale value of the image to be processed are taken as the first group, and the average of the cumulative histograms of all image blocks in the first group is calculated. The image blocks in the flat texture detail junction region whose average pixel grayscale value is not greater than the average pixel grayscale value of the image to be processed are designated as the second group, and the average of the cumulative histograms of all image blocks in the second group is calculated.
6. The method according to any one of claims 1-5, characterized in that, The step of enhancing the contrast of other image patches using the contrast-limited adaptive histogram equalization algorithm to obtain the output image includes: After replacing the cumulative histogram distribution of the flat region image block, the cumulative histograms of other image blocks are calculated using a contrast-limited adaptive histogram equalization algorithm. The contrast-enhanced output image is obtained by weighted averaging using a contrast-limited adaptive histogram equalization algorithm.
7. An apparatus for enhancing image contrast, characterized in that, The device includes: The segmentation unit is used to divide the image to be processed into at least two image blocks according to a preset size; The first calculation unit is used to calculate the gradient value of each image patch; The first judgment unit is used to determine whether the image to be processed has flat region image blocks and flat texture detail intersection region image blocks based on the gradient value of each image block; The second calculation unit is used to divide the flat texture detail intersection area image block into at least two groups when the image to be processed contains flat area image blocks and flat texture detail intersection area image blocks, and calculate the average of the cumulative histogram distribution corresponding to each group respectively. A designated unit is configured to replace the cumulative histogram distribution of the flat region image block with the average of the cumulative histograms of one of the adjacent image blocks of the flat region image block; The contrast enhancement unit is used to enhance the contrast of other image blocks according to the limited contrast adaptive histogram equalization algorithm to obtain the output image. The second calculation unit includes: a third calculation module, used to calculate the histogram and cumulative histogram of the flat texture detail intersection region image block according to the limited contrast adaptive histogram equalization algorithm when the image to be processed contains flat region image blocks and flat texture detail intersection region image blocks; and a grouping module, used to divide the flat texture detail intersection region image block into at least two groups according to the pixel grayscale mean of the flat texture detail intersection region image block and the pixel grayscale mean of the image to be processed, and calculate the average of the cumulative histograms of all image blocks in each group respectively. The designated unit includes: an acquisition module for acquiring image blocks adjacent to the flat region image block; and a determination module for determining the magnitude of the average pixel grayscale value of the adjacent image block and the average pixel grayscale value of the image to be processed; when the average pixel grayscale value of the adjacent image block is greater than the average pixel grayscale value of the image to be processed, the cumulative histogram distribution of the flat region image block is replaced with the average of the cumulative histograms of all image blocks in the first group; when the average pixel grayscale value of the adjacent image block is not greater than the average pixel grayscale value of the image to be processed, the cumulative histogram distribution of the flat region image block is replaced with the average of the cumulative histograms of all image blocks in the second group.
8. The apparatus according to claim 7, characterized in that, The first determination unit includes: The first calculation module is used to calculate the average gray level of the pixels in the image to be processed, the image noise level, and the average gray level of the pixels in each image block. The second calculation module is used to calculate the gradient values of each image patch; The statistical judgment module is used to obtain the gradient value of each image block and then calculate the proportion of pixels with larger gradient values in each image block to the total number of pixels in the image block. If the proportion is within a first preset range, the image block is a flat region image block. If the proportion is within a second preset range, the image block is a flat texture detail junction region image block.
9. The apparatus according to claim 7, characterized in that, The contrast enhancement unit includes: The fourth calculation module is used to calculate the cumulative histogram of other image blocks by using a contrast-limited adaptive histogram equalization algorithm after replacing the cumulative histogram distribution of the flat region image blocks. The enhancement module is used to perform weighted averaging using a contrast-limited adaptive histogram equalization algorithm to obtain a contrast-enhanced output image.
10. A smart terminal, characterized in that, The smart terminal includes a device for enhancing image contrast as described in any one of claims 7 to 9.
Citation Information
Patent Citations
Multiple exposure high dynamic range image capture
US20110211732A1
Image processing method, device and system, and storage medium
WO2022246663A1