Image contrast enhancement method, electronic device and computer readable storage medium
By performing global and local contrast enhancement processing on the image, combined with the initial substrate image and detail image, the problem of poor image contrast enhancement effect in the prior art is solved and the image quality is improved.
Patent Information
- Application Number
- CN202510056008.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2045-01-14
AI Technical Summary
When the prior art enhances the global contrast of images, it is easy to cause some areas to be over-enhanced or the degree of enhancement is not ideal, resulting in poor image contrast enhancement effect and poor image quality after enhancement.
By performing global contrast enhancement processing on the initial brightness image of the acquired initial image on the brightness channel, a target brightness image is obtained. The target brightness image includes an initial substrate image and an initial detail image; a local contrast enhancement processing is performed on the initial substrate image to obtain a target substrate image; a target image is determined based on the target substrate image, an initial detail image and an initial substrate image.
The effect of contrast enhancement on the initial detail image is avoided, and the contrast enhancement effect when the brightness is concentrated in the initial image is improved, thereby improving the quality of the target image.
Smart Images

Figure CN119477707B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image contrast enhancement method, an electronic device and a computer-readable storage medium. Background Art
[0002] During the image formation process, it is very easy to cause poor image quality due to the influence of the surrounding environment. For example, in low-light or foggy environments, or in scenes with uneven lighting such as medical endoscopes, the image details and textures will become unclear. In order to improve the visibility of the image, the image contrast needs to be adjusted. Therefore, image contrast enhancement technology has always been a long-standing topic in the field of image processing.
[0003] At present, the method of processing images by global contrast enhancement causes some areas in the image to be over-enhanced or the enhancement degree is not ideal, resulting in poor image contrast enhancement effect and low quality of the enhanced image. Summary of the invention
[0004] The main technical problem solved by the present application is to provide an image contrast enhancement method, an electronic device and a computer-readable storage medium, which can improve image quality.
[0005] To solve the above technical problems, the present application provides an image contrast enhancement method, which includes: performing global contrast enhancement processing on an initial brightness image of an acquired initial image on a brightness channel to obtain a target brightness image, wherein the target brightness image includes an initial base image and an initial detail image; performing local contrast enhancement processing on the initial base image to obtain a target base image; and determining a target image based on the target base image, the initial detail image and the initial base image.
[0006] In one embodiment, the step of performing local contrast enhancement processing on the initial base image to obtain a target base image includes: performing block processing on the initial base image to obtain at least two image block information, wherein the image block information includes an image block and an initial histogram of the image block; determining a histogram cropping coefficient of the corresponding image block according to attribute information of each image block; adjusting the initial histogram of the image block according to the histogram cropping coefficient of the image block to obtain a target histogram of each image block; and performing image block splicing processing according to each target histogram to obtain the target base image.
[0007] In one embodiment, the step of adjusting the initial histogram of the image block according to the histogram cropping coefficient of the image block to obtain the target histogram of each image block includes: cropping the initial histogram of the corresponding image block according to the histogram cropping coefficient to obtain an initial pixel point set and a cropped initial histogram, wherein the initial pixel point set includes pixel points cropped from the initial histogram; and allocating the pixel points in the initial pixel point set to the cropped initial histogram to obtain the target histogram.
[0008] In one embodiment, the step of assigning the pixel points in the initial pixel point set to the cropped initial histogram to obtain the target histogram includes: determining the number of assignable pixel points and the allocation threshold according to the number of pixel points in the initial pixel point set, the grayscale information of the image block, and the histogram cropping coefficient of the image block; traversing each gray level in the initial histogram, and assigning pixel points to each gray level according to the relationship between the number of pixel points in each gray level, the histogram cropping coefficient, and the allocation threshold to obtain the target histogram, wherein the allocation threshold is less than the histogram cropping coefficient.
[0009] In one embodiment, the step of traversing each gray level in the initial histogram and allocating pixels to each gray level according to the relationship between the number of pixels in each gray level, the histogram clipping coefficient, and the allocation threshold to obtain the target histogram includes: in response to the number of pixels in the gray level being greater than or equal to the allocation threshold and less than or equal to the histogram clipping coefficient, obtaining the difference between the histogram clipping coefficient and the number of pixels in the gray level; allocating the pixels of the difference in the initial pixel point set to the gray level; in response to the number of pixels in the gray level being less than the allocation threshold, allocating the pixels of the allocable number of pixels in the initial pixel point set to the gray level; until the preset requirements are met, evenly allocating the remaining pixels in the initial pixel point set to each gray level of the initial histogram to obtain the target histogram.
[0010] In one embodiment, the step of determining the target image based on the target base image, the initial detail image and the initial base image includes: fusing the target base image and the initial base image to obtain a fused base image; performing image fusion processing based on the fused base image and the initial detail image to obtain the target image.
[0011] In one embodiment, the step of fusing the target base image and the initial base image to obtain a fused base image includes: determining a brightness enhanced area and a brightness weakened area in the target base image based on a brightness comparison result between each pixel in the target base image and a corresponding pixel in the initial base image; fusing the target base image and the initial base image based on a first fusion weight corresponding to the brightness enhanced area and a second fusion weight corresponding to the brightness weakened area to obtain the fused base image.
[0012] In one embodiment, the step of performing image fusion processing based on the fused base image and the initial detail image to obtain the target image includes: performing detail enhancement processing on the initial detail image to obtain the enhanced initial detail image; and fusing the fused base image and the enhanced initial detail image to obtain the target image.
[0013] In order to solve the above technical problem, the present application provides an electronic device, including a memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the above image contrast enhancement method.
[0014] In order to solve the above technical problem, the present application provides a computer-readable storage medium including program data stored therein, and the program data is used to implement the above image contrast enhancement method when executed by a processor.
[0015] The above scheme performs global contrast enhancement processing on the initial brightness image of the acquired initial image on the brightness channel to obtain a target brightness image, which includes an initial base image and an initial detail image; performs local contrast enhancement processing on the initial base image to obtain a target base image; and determines the target image based on the target base image, the initial detail image, and the initial base image. By performing global contrast enhancement processing on the initial brightness image of the initial image on the brightness channel, and by performing local contrast enhancement processing on the base image in the target brightness image, the influence of contrast enhancement on the initial detail image can be avoided, and the contrast enhancement effect when the brightness in the initial image is concentratedly distributed is improved, thereby improving the quality of the target image determined based on the target base image, the initial detail image, and the initial base image. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0017] Figure 1 is a flowchart of an exemplary embodiment of an image contrast enhancement method shown in the present application;
[0018] Figure 2 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S120 in the method for enhancing image contrast;
[0019] Figure 3 yes Figure 2 FIG. 1 is a flow chart of an exemplary embodiment of step S230 in the method for enhancing image contrast;
[0020] Figure 4 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S130 in the method for enhancing image contrast;
[0021] Figure 5 is a block diagram of an image contrast enhancement device shown in an exemplary embodiment of the present application;
[0022] Figure 6 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application;
[0023] Figure 7 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0024] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It will be appreciated that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for ease of description, only some but not all structures related to the present application are shown in the drawings. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the art without making creative work are within the scope of protection of the present application.
[0025] For details, please refer to Figure 1 , Figure 1 It is a flowchart of an exemplary embodiment of the image contrast enhancement method shown in the present application.
[0026] The execution subject of the image contrast enhancement method may be a terminal device or a server or other processing device, wherein the terminal device may be a user equipment (UE), a computer, a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The execution subject of the image contrast enhancement method may also be an image contrast enhancement device. In some possible implementations, the image contrast enhancement method may be implemented by a processor calling a computer-readable instruction stored in a memory.
[0027] In the embodiment of the present application, the image contrast enhancement device is used as the execution subject for description. Specifically, the image contrast enhancement method of this embodiment includes the following steps:
[0028] Step S110 , performing global contrast enhancement processing on the initial brightness image of the acquired initial image in the brightness channel to obtain a target brightness image, where the target brightness image includes an initial base image and an initial detail image.
[0029] As an example, the initial image can be a YUV image. Among them, Y in the YUV image is the brightness channel, which represents the brightness of the initial image, that is, the grayscale value. U and V in the YUV image are color channels, which represent the color and saturation in the initial image. As another example, if the initial image is an RGB image, it is necessary to convert the RGB image into a YUV image before determining its initial brightness image on the brightness channel.
[0030] The initial base image is a main image used for contrast adjustment. The image contrast enhancement device can protect image details from being affected by contrast enhancement by performing contrast enhancement processing on the initial base image.
[0031] The initial detail image is used to represent image details. The image contrast enhancement device can directly obtain the initial detail image by extracting details from the target brightness image, or the image contrast enhancement device inputs the target brightness image into a trained detail extraction network to obtain the initial detail image output by the detail extraction network.
[0032] The image contrast enhancement device performs global contrast enhancement processing on the initial brightness image of the acquired initial image on the brightness channel to obtain a target brightness image, which includes an initial base image and an initial detail image. Specifically, the image contrast enhancement device can perform global contrast enhancement processing on the initial brightness image to obtain a target brightness image after global contrast enhancement processing; then, perform image separation processing on the target brightness image after global contrast enhancement processing to obtain an initial base image and an initial detail image.
[0033] As for the method of global contrast enhancement processing, as an example, the global contrast enhancement processing may be histogram equalization. Specifically, the image contrast enhancement device obtains the target brightness image by redistributing each pixel in the initial brightness image. Among them, the pixel points in the histogram of the target brightness image are evenly distributed. As another example, the global contrast enhancement processing may be histogram stretching. Specifically, the image contrast enhancement device performs histogram stretching processing according to the brightness distribution of the pixel points in the initial brightness image to obtain the target brightness image. For example, for the image area with concentrated brightness distribution, stretching processing is performed according to the preset stretching rules. Among them, the brightness distribution in the target brightness image is even. It should be noted that the concentrated brightness distribution represents that the histogram corresponding to the initial brightness image is concentrated near the same brightness.
[0034] As for the image separation method, as an example, the image contrast enhancement device can use a filter to perform high-low frequency separation processing on the target brightness image to obtain an initial base image and an initial detail image. As another example, the image contrast enhancement device can also perform high-frequency information smoothing processing on the target brightness image to obtain an initial base image; then determine the initial detail image through the pixel difference between the target brightness image and the initial base image.
[0035] Step S120, performing local contrast enhancement processing on the initial base image to obtain a target base image.
[0036] As an example, the image contrast enhancement device may use a local adaptive histogram equalization (AHE) to perform local contrast enhancement processing on the initial base image to obtain a target base image. As another example, the image contrast enhancement device may also use a CLAHE (Contrast Limited Adaptive Histogram Equalization) algorithm to perform local contrast enhancement processing on the initial base image to obtain a target base image.
[0037] Step S130, determining a target image based on the target base image, the initial detail image and the initial base image.
[0038] The image contrast enhancement device can fuse the target base image, the initial detail image and the initial base image to obtain the target image.
[0039] It can be seen that the image contrast enhancement method of the embodiment of the present application performs global contrast enhancement processing on the initial brightness image of the acquired initial image on the brightness channel to obtain a target brightness image, which includes an initial base image and an initial detail image; performs local contrast enhancement processing on the initial base image to obtain a target base image; and determines the target image based on the target base image, the initial detail image, and the initial base image. By performing global contrast enhancement processing on the initial brightness image of the initial image on the brightness channel, and by performing local contrast enhancement processing on the base image in the target brightness image, the influence of contrast enhancement on the initial detail image can be avoided, and the contrast enhancement effect when the brightness in the initial image is concentratedly distributed is improved, thereby improving the quality of the target image determined based on the target base image, the initial detail image, and the initial base image.
[0040] Based on the above examples, please continue to refer to Figure 2 , Figure 2 yes Figure 1 FIG. 1 is a flow chart of an exemplary embodiment of step S120 in the method for enhancing image contrast. Specifically, step S120 performs local contrast enhancement processing on the initial base image to obtain the target base image, and the process further includes the following steps:
[0041] Step S210, performing block processing on the initial base image to obtain at least two pieces of image block information, wherein the image block information includes an image block and an initial histogram of the image block.
[0042] The image contrast enhancement device performs block processing on the initial base image to obtain at least two image block information. Specifically, the image contrast enhancement device can perform block processing on the initial base image according to a preset image block division method to obtain at least two image blocks; then determine the initial histogram of the corresponding image block according to the brightness of each pixel in each image block. Among them, the preset image block division method can be to divide the initial base image into image blocks of the same size, or to divide the initial base image into image blocks of different sizes. It should be noted that there is no overlapping area between adjacent image blocks.
[0043] Step S220: determining a histogram cropping coefficient of a corresponding image block according to the attribute information of each image block.
[0044] The attribute information of the image block may include brightness information, number of pixels, grayscale information, etc. of the image block.
[0045] The image contrast enhancement device can use the traditional CLAHE (Contrast Limited Adaptive Histogram Equalization) algorithm to determine the histogram cropping coefficient. Specifically, the image contrast enhancement device determines the image variation coefficient by the ratio between the brightness standard deviation in the image block and the brightness mean of the corresponding image block, and then determines the histogram cropping coefficient according to the image variation coefficient. Specifically, the histogram cropping coefficient can be determined from a conversion curve between a preset cropping coefficient and a preset variation coefficient according to the image variation coefficient. Among them, there is a positive correlation between the image variation coefficient and the histogram cropping coefficient.
[0046] Specifically, the calculation method of the image variation coefficient satisfies the following formula:
[0047]
[0048] in, is the image variation coefficient, is the brightness standard deviation of the image block, is the mean brightness of the image block.
[0049] Based on the above example, if the image block is a low-brightness area, the brightness mean of the image block will be small, which makes the image variation coefficient too large and the histogram clipping coefficient too large, which easily leads to the problem of unclear contrast improvement. In this regard, the image contrast enhancement device can improve the way the traditional CLAHE algorithm determines the histogram clipping coefficient. Specifically, the image contrast enhancement device determines the histogram clipping coefficient of the corresponding image block according to the brightness standard deviation, brightness mean, number of pixels in the image block and grayscale information of the image block in the attribute information of the image block.
[0050] According to the attribute information of the image block, the histogram cropping coefficient of the corresponding image block is determined to satisfy the following formula:
[0051]
[0052] in, is the number of pixels in the image block, is the grayscale information of the image block, that is, the grayscale value, and Preset parameters for controlling the degree of regulation; To prevent the denominator from being a preset minimum value of 0; is the minimum function; is the preset adjustment factor, and cliplimit is the histogram clipping factor.
[0053] Step S230 , adjusting the initial histogram of the image block according to the histogram cropping coefficient of the image block to obtain a target histogram of each image block.
[0054] The image contrast enhancement device can perform cropping processing on the initial histogram corresponding to the image block according to the histogram cropping coefficient of the image block to obtain an initial pixel point set and a cropped initial histogram, and then distribute the pixels in the initial pixel point set to the cropped initial histogram to obtain a target histogram. The initial pixel point set includes the pixels cropped from the initial histogram. For the method of cropping the initial histogram corresponding to the image block according to the histogram cropping coefficient, the image contrast enhancement device crops the part of the vertical axis representing the number of pixels in the initial histogram that is greater than the histogram cropping coefficient to obtain the initial pixel point set; the part of the vertical axis that is less than or equal to the histogram cropping coefficient is retained as the cropped initial histogram. For the method of distributing the pixels in the initial pixel point set to the cropped initial histogram to obtain the target histogram, the image contrast enhancement device can evenly distribute the pixels in the initial pixel point set to the cropped initial histogram to obtain the target histogram.
[0055] Step S240, performing image block stitching processing according to each target histogram to obtain a target base image.
[0056] The image contrast enhancement device determines the contrast-enhanced image blocks according to each target histogram, and performs splicing processing on the contrast-enhanced image blocks to obtain the target base image.
[0057] It can be seen that the image contrast enhancement method of the embodiment of the present application performs block processing on the initial base image to obtain at least two image block information, the image block information includes the image block and the initial histogram of the image block; the histogram cropping coefficient of the corresponding image block is determined according to the attribute information of each image block; the initial histogram of the image block is adjusted according to the histogram cropping coefficient of the image block to obtain the target histogram of each image block; the image blocks are spliced according to each target histogram to obtain the target base image. The histogram cropping coefficient used for cropping the initial histogram is determined according to the brightness standard deviation, brightness mean, number of pixels in the image block and grayscale information of the image block in the attribute information of the image block, which can avoid the problem of unclear contrast improvement caused by excessive cropping coefficient when the image block is in a low-brightness state.
[0058] Based on the above examples, please continue to refer to Figure 3 , Figure 3 yes Figure 2 The flowchart of an exemplary embodiment of step S230 in the method for enhancing image contrast is shown. Specifically, step S230 adjusts the initial histogram of the image block according to the histogram cropping coefficient of the image block, and the process of obtaining the target histogram of each image block also includes the following steps:
[0059] Step S310 , performing cropping processing on the initial histogram of the corresponding image block according to the histogram cropping coefficient to obtain an initial pixel point set and a cropped initial histogram, wherein the initial pixel point set includes pixel points cropped from the initial histogram.
[0060] The image contrast enhancement device crops the part of the vertical axis representing the number of pixel points in the initial histogram of the image block that is greater than the histogram cropping coefficient to obtain an initial pixel point set; and retains the part of the vertical axis representing the number of pixel points in the initial histogram that is less than or equal to the histogram cropping coefficient as the cropped initial histogram.
[0061] Step S320, allocating the pixels in the initial pixel set to the cropped initial histogram to obtain a target histogram.
[0062] On the basis of the above-mentioned embodiments, it is considered that the point set allocation strategy using the traditional CLAHE algorithm has the problem of low allocation efficiency, which is not conducive to the allocation implementation of the image contrast enhancement device. In this regard, the image contrast enhancement device of the embodiment of the present application controls the allocation by determining the number of allocable pixel points and the allocation threshold to improve the allocation efficiency. Specifically, the image contrast enhancement device determines the number of allocable pixel points and the allocation threshold according to the number of pixel points in the initial pixel point set, the grayscale information of the image block, and the histogram cropping coefficient of the image block; traverses each gray level in the initial histogram, and allocates pixels to each gray level according to the allocable pixel points according to the size relationship between the number of pixel points in each gray level and the histogram cropping coefficient and the allocation threshold, so as to obtain a target histogram.
[0063] Regarding the method of determining the allocable number of pixels and the allocation threshold according to the number of pixels in the initial pixel point set, the grayscale information of the image block and the histogram cropping coefficient of the image block, the image contrast enhancement device determines the ratio between the number of pixels in the initial pixel point set and the grayscale value represented by the grayscale information of the image block as the allocable number of pixels; and determines the difference between the histogram cropping coefficient of the image block and the allocable number of pixels as the allocation threshold.
[0064] Specifically, the number of pixels that can be allocated and the allocation threshold calculation satisfy the following formula:
[0065]
[0066]
[0067] Among them, totalNum represents the number of pixels in the initial pixel set. Indicates the grayscale information of the image block; avgNum indicates the number of allocable pixels, and clipval indicates the allocation threshold. It should be noted that the grayscale information of the image block also indicates the grayscale range of the image block, which can specifically be the maximum grayscale value of the image block.
[0068] For each gray level in the traversal initial histogram, pixel points are allocated to each gray level according to the size relationship between the number of pixels in each gray level, the histogram clipping coefficient, and the allocation threshold, and the target histogram is obtained. The image contrast enhancement device traverses each gray level, determines the size relationship between the number of pixels in each gray level, the histogram clipping coefficient, and the allocation threshold, and in response to the number of pixels in the gray level being greater than or equal to the histogram clipping coefficient, the pixel point allocation processing is not performed on the corresponding gray level; in response to the number of pixels in the gray level being less than the allocation threshold, the initial image is allocated. The pixel points of the pixel point set that can be allocated are allocated to the grayscale, and the pixel points allocated to the grayscale are deleted in the initial pixel point set; in response to the number of pixel points in the grayscale being greater than or equal to the allocation threshold and less than or equal to the histogram clipping coefficient, the difference between the histogram clipping coefficient and the number of pixel points in the grayscale is obtained, the pixel points of the difference in the initial pixel point set are allocated to the grayscale, and the pixel points allocated to the grayscale are deleted in the initial pixel point set until the requirements are met, and the remaining pixel points are evenly allocated to each grayscale level of the initial histogram to obtain the target histogram. It should be noted that the requirements can be met in that the remaining number of remaining pixel points in the initial pixel point set is less than or equal to the grayscale level represented by the grayscale information of the image block; the requirements can also be met in that the number of traversals of the initial histogram is greater than the preset number of allocations; or the requirements can be met in that the remaining number of remaining pixel points in the initial pixel point set is less than or equal to the grayscale level represented by the grayscale information of the image block, and the number of traversals of the initial histogram is greater than the preset number of allocations.
[0069] It can be seen that the image contrast enhancement method of the embodiment of the present application determines the number of allocable pixels and the allocation threshold according to the number of pixels in the initial pixel set, the grayscale information of the image block, and the histogram clipping coefficient of the image block; traverses each gray level in the initial histogram, and allocates pixels to each gray level according to the relationship between the number of pixels in each gray level and the histogram clipping coefficient and the allocation threshold, and obtains a target histogram. In this way, the allocation can be controlled by the determined number of allocable pixels and the allocation threshold, thereby improving the allocation efficiency.
[0070] Based on the above examples, please continue to refer to Figure 4 , Figure 4 yes Figure 1FIG. 1 is a flow chart of an exemplary embodiment of step S130 in the method for enhancing image contrast. Specifically, the process of determining the target image based on the target base image, the initial detail image and the initial base image in step S130 further includes the following steps:
[0071] Step S410, fusing the target base image and the initial base image to obtain a fused base image.
[0072] The image contrast enhancement device can determine the brightness enhancement area and the brightness reduction area in the target base image according to the brightness comparison result between each pixel point in the target base image and the corresponding pixel point in the initial base image; and fuse the target base image and the initial base image according to the first fusion weight corresponding to the brightness enhancement area and the second fusion weight corresponding to the brightness reduction area to obtain a fused base image.
[0073] For the method of determining the brightness enhancement area and the brightness reduction area in the target base image according to the brightness comparison result between each pixel in the target base image and the corresponding pixel in the initial base image, as an example, the image contrast enhancement device determines whether the brightness value of each pixel in the target base image is greater than the brightness value of the corresponding pixel in the initial base image. If so, the corresponding pixel in the target base image is characterized as a pixel in the brightness enhancement area; if not, the corresponding pixel in the target base image is characterized as a pixel in the brightness reduction area. As another example, the image contrast enhancement device determines the brightness enhancement area and the brightness reduction area in the target base image by determining whether the brightness difference between the brightness value of each pixel in the target base image and the brightness value of the corresponding pixel in the initial base image is greater than the difference threshold. Specifically, the image contrast enhancement device determines the pixel whose brightness difference between the brightness value of each pixel in the target base image and the brightness value of the corresponding pixel in the initial base image is greater than the difference threshold as the pixel in the brightness enhancement area, and determines the pixel whose brightness difference between the brightness value of each pixel in the target base image and the brightness value of the corresponding pixel in the initial base image is less than or equal to the difference threshold as the pixel in the brightness reduction area.
[0074] Regarding the method of fusing the target base image and the initial base image according to the first fusion weight corresponding to the brightness enhanced area and the second fusion weight corresponding to the brightness reduced area to obtain the fused base image, as an example, the first fusion weight and the second fusion weight can be preset, that is, the brightness enhanced area is preset with the same fusion weight, and the brightness reduced area is preset with the same fusion weight. After determining the brightness enhanced area and the brightness reduced area, the image contrast enhancement device can determine the fusion weight of the pixel points in each area. Then, the image contrast enhancement device performs weighted fusion processing on the target base image and the initial base image according to the first fusion weight corresponding to the brightness enhanced area and the second fusion weight corresponding to the brightness reduced area to obtain the fused base image. As another example, the first fusion weight and the second fusion weight can be determined from the corresponding preset weight curve according to the pixel value of the pixel point in the initial base image. Specifically, for the pixel points in the brightness enhancement area, the corresponding first fusion weight can be obtained from the first preset weight curve according to the pixel value of the pixel point in the initial base image; for the pixel points in the brightness reduction area, the second fusion weight of the corresponding pixel point can be obtained from the second preset weight curve according to the pixel value of the pixel point in the initial base image, and then the image fusion processing is performed according to the first fusion weight corresponding to each pixel point in the brightness enhancement area and the second fusion weight corresponding to each pixel point in the brightness reduction area to obtain the fused base image. It should be noted that the first preset weight curve and the second preset weight curve include the correspondence between the pixel value of the pixel point and the fusion weight. As another example, the first fusion weight and the second fusion weight can also be determined from a third preset weight curve according to the brightness contrast result. Specifically, the third preset weight curve includes the correspondence between the brightness difference and the fusion weight. The image contrast enhancement device determines the fusion weight of the corresponding pixel from the third preset weight curve according to the brightness difference between the brightness value of each pixel in the target base image represented by the brightness contrast result and the brightness value of the corresponding pixel in the initial base image. Then, the target base image and the initial base image are weightedly fused according to the first fusion weight corresponding to each pixel in the brightness enhanced area and the second fusion weight corresponding to each pixel in the brightness weakened area to obtain a fused base image.
[0075] Step S420: performing image fusion processing based on the fused base image and the initial detail image to obtain a target image.
[0076] In an embodiment of the present application, the image contrast enhancement device can directly perform image fusion processing on the fused base image and the initial detail image to obtain a target image. In other embodiments, the image contrast enhancement device can also perform image fusion processing on the initial detail image according to a preset ratio to obtain an enlarged initial detail image; then, perform image fusion processing on the enlarged initial detail image and the fused base image to obtain a target image. In other embodiments, the image contrast enhancement device can also perform detail enhancement processing on the initial detail image to obtain an enhanced initial detail image; and perform fusion processing on the fused base image and the enhanced initial detail image to obtain a target image.
[0077] For the detail enhancement processing method, the image contrast enhancement device determines the detail adjustment weight of the corresponding pixel in the initial detail image according to the gray value of each pixel in the initial base image and the gray value of each pixel in the target base image, and then uses the detail adjustment weight of each pixel to perform detail adjustment processing on the initial detail image to obtain the enhanced initial detail image. Specifically, for the method of determining the detail adjustment weight of the corresponding pixel in the initial detail image according to the gray value of each pixel in the initial base image and the gray value of each pixel in the target base image, the image contrast enhancement device obtains a preset perception curve, which includes the corresponding relationship between the perception value and the gray value, and the image contrast enhancement device determines the first perception value of the corresponding pixel from the preset perception curve according to the gray value of each pixel in the base image, and determines the second perception value of the corresponding pixel from the target base image according to the gray value of each pixel in the target base image; the ratio between the first perception value and the second perception value is used as the detail adjustment weight of the corresponding pixel in the initial detail image. It should be noted that, for the method of obtaining the preset perception curve, the image contrast enhancement device can determine the preset perception curve according to the size relationship between the grayscale value of each pixel in the initial image and the preset grayscale threshold. Specifically, the portion where the pixel with a grayscale value greater than the preset grayscale threshold is located is determined as a bright area, and the portion where the pixel with a grayscale value less than or equal to the preset grayscale threshold is located is determined as a dark area, and the preset perception curve is configured according to the bright area and the dark area in the initial image. Among them, the preset perception curve shows a downward trend in the dark area to suppress the obvious noise problem caused by contrast enhancement, and the preset perception curve shows an upward trend in the bright area, which can improve the detail texture of the contrast enhanced image.
[0078] It can be seen that the image contrast enhancement method of the embodiment of the present application fuses the target base image and the initial base image to obtain a fused base image; and performs image fusion processing based on the fused base image and the initial detail image to obtain the target image. On the one hand, when the initial base image and the target base image are image-fused, the target base image and the initial base image are fused according to the first fusion weight corresponding to the brightness enhancement area and the second fusion weight corresponding to the brightness reduction area to obtain the fused base image, thereby being able to determine the corresponding fusion weights according to the pixel brightening area and the pixel darkening area to perform image fusion, so that the image contrast enhancement effect is more refined and the noise in the pixel darkening area is avoided; on the other hand, the corresponding first perception value and the second perception value are determined from the preset perception curve according to the gray value of each pixel in the initial base image and the gray value of each pixel in the target base image, and then the detail adjustment weight is determined according to the first perception value and the second perception value, and then the initial detail image is enhanced based on the detail adjustment weight, and the fused base image and the enhanced initial detail image are fused to obtain the target image. The preset perception curve presents a downward trend in the dark area to suppress the obvious noise problem caused by contrast enhancement, and the preset perception curve presents an upward trend in the bright area to improve the detail texture of the contrast enhanced image.
[0079] Figure 5 FIG. 1 is a block diagram of an image contrast enhancement device shown in an exemplary embodiment of the present application. Figure 5 As shown, the exemplary image contrast enhancement device 500 includes: a global enhancement module 510, a local enhancement module 520 and a determination module 530. Specifically:
[0080] The global enhancement module 510 is used to perform global contrast enhancement processing on the initial brightness image of the acquired initial image in the brightness channel to obtain a target brightness image, where the target brightness image includes an initial base image and an initial detail image.
[0081] The local enhancement module 520 is used to perform local contrast enhancement processing on the initial base image to obtain a target base image.
[0082] The determination module 530 is configured to determine a target image based on the target base image, the initial detail image and the initial base image.
[0083] In the exemplary image contrast enhancement device, global contrast enhancement processing is performed on the initial brightness image of the acquired initial image on the brightness channel to obtain a target brightness image, which includes an initial base image and an initial detail image; local contrast enhancement processing is performed on the initial base image to obtain a target base image; and the target image is determined based on the target base image, the initial detail image and the initial base image. By performing global contrast enhancement processing on the initial brightness image of the initial image on the brightness channel and performing local contrast enhancement processing on the base image in the target brightness image, the influence of contrast enhancement on the initial detail image can be avoided, and the contrast enhancement effect when the brightness in the initial image is concentratedly distributed is improved, thereby improving the quality of the target image determined based on the target base image, the initial detail image and the initial base image.
[0084] The functions of each module can be found in the embodiment of the image contrast enhancement method, which will not be described in detail here.
[0085] In order to implement the image contrast enhancement method of the above embodiment, the present application proposes another electronic device, for details, please refer to Figure 6 , Figure 6 It is a structural schematic diagram of an embodiment of an electronic device provided by the present application.
[0086] The electronic device 600 includes a memory 601 and a processor 602 , wherein the memory 601 and the processor 602 are coupled.
[0087] The memory 601 is used to store program data, and the processor 602 is used to execute the program data to implement the image contrast enhancement method of the above embodiment.
[0088] In this embodiment, the processor 602 may also be referred to as a CPU (Central Processing Unit). The processor 602 may be an integrated circuit chip having signal processing capabilities. The processor 602 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. A general-purpose processor may be a microprocessor or the processor 602 may also be any conventional processor, etc.
[0089] The present application also provides a computer-readable storage medium, such as Figure 7 As shown, the computer-readable storage medium 700 is used to store program data 701. When the program data 701 is executed by the processor, it is used to implement the image contrast enhancement method in the method embodiment of the present application.
[0090] The method involved in the embodiment of the image contrast enhancement method of the present application, when implemented in the form of a software functional unit and sold or used as an independent product, can be stored in a device, such as a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.
[0091] The above description is only an implementation method of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for enhancing image contrast, characterized in that: The method comprises: Performing global contrast enhancement processing on an initial brightness image of the acquired initial image on a brightness channel to obtain a target brightness image, wherein the target brightness image includes an initial base image and an initial detail image; Performing local contrast enhancement processing on the initial base image to obtain a target base image; A target image is determined based on the target base image, the initial detail image, and the initial base image.
2. The image contrast enhancement method according to claim 1, characterized in that: The step of performing local contrast enhancement processing on the initial base image to obtain a target base image comprises: Performing block processing on the initial base image to obtain at least two pieces of image block information, wherein the image block information includes an image block and an initial histogram of the image block; Determine a histogram cropping coefficient of a corresponding image block according to the attribute information of each image block; Adjusting the initial histogram of the image block according to the histogram cropping coefficient of the image block to obtain a target histogram of each image block; Image block splicing processing is performed according to each target histogram to obtain the target base image.
3. The image contrast enhancement method according to claim 2, characterized in that: The step of adjusting the initial histogram of the image block according to the histogram cropping coefficient of the image block to obtain the target histogram of each image block includes: Performing cropping processing on the initial histogram of the corresponding image block according to the histogram cropping coefficient to obtain an initial pixel point set and a cropped initial histogram, wherein the initial pixel point set includes pixel points cropped from the initial histogram; The pixel points in the initial pixel point set are allocated to the cropped initial histogram to obtain the target histogram.
4. The image contrast enhancement method according to claim 3, characterized in that: The step of allocating the pixel points in the initial pixel point set to the clipped initial histogram to obtain the target histogram comprises: Determining the number of allocable pixels and an allocation threshold according to the number of pixels in the initial pixel point set, the grayscale information of the image block, and the histogram cropping coefficient of the image block; Traversing each gray level in the initial histogram, allocating pixels to each gray level according to the relationship between the number of pixels in each gray level, the histogram clipping coefficient, and the allocation threshold, to obtain the target histogram, wherein the allocation threshold is less than the histogram clipping coefficient.
5. The image contrast enhancement method according to claim 4, characterized in that: The step of traversing each gray level in the initial histogram and allocating pixels to each gray level according to the relationship between the number of pixels in each gray level, the histogram clipping coefficient, and the allocation threshold to obtain the target histogram includes: In response to the number of pixels in the grayscale being greater than or equal to the allocation threshold and less than or equal to the histogram clipping coefficient, obtaining a difference between the histogram clipping coefficient and the number of pixels in the grayscale; Allocate the pixel points of the difference value in the initial pixel point set to the grayscale; In response to the number of pixels in the grayscale being less than the allocation threshold, allocating the pixel points of the allocable pixel points in the initial pixel point set to the grayscale; Until the preset requirements are met, the remaining pixels in the initial pixel set are evenly distributed to each grayscale level of the initial histogram to obtain the target histogram.
6. The image contrast enhancement method according to claim 1, characterized in that: The step of determining the target image based on the target base image, the initial detail image and the initial base image comprises: Fusing the target base image and the initial base image to obtain a fused base image; Image fusion processing is performed based on the fused base image and the initial detail image to obtain the target image.
7. The image contrast enhancement method according to claim 6, characterized in that: The step of fusing the target base image and the initial base image to obtain a fused base image comprises: Determine a brightness enhancement area and a brightness reduction area in the target base image according to a brightness comparison result between each pixel in the target base image and a corresponding pixel in the initial base image; The target base image and the initial base image are fused according to a first fusion weight corresponding to the brightness enhanced region and a second fusion weight corresponding to the brightness weakened region to obtain the fused base image.
8. The image contrast enhancement method according to claim 6, characterized in that: The step of performing image fusion processing based on the fused base image and the initial detail image to obtain the target image comprises: Performing detail enhancement processing on the initial detail image to obtain an enhanced initial detail image; The fused base image and the enhanced initial detail image are fused to obtain the target image.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: include: Program data is stored, and when the program data is executed by a processor, it is used to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
High-performance infrared image processing system
CN112150381A
Image processing method and device, electronic equipment and storage medium
CN112950499A