An image enhancement method, device, storage medium and program product
By converting RGB images to YUV images and performing differential brightness and color compensation processing, the problems of insufficient brightening of dark areas, overexposure of bright areas, and color distortion in image enhancement under complex scenes are solved, achieving high-precision image enhancement effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-26
- Publication Date
- 2026-06-26
AI Technical Summary
Existing image enhancement technologies struggle to achieve insufficient brightening of dark areas or overexposure and distortion of bright areas in complex scenes. Furthermore, they neglect color balance after brightness enhancement, resulting in color cast and abnormal saturation, failing to meet the requirements for high-precision image enhancement.
The RGB image is converted to a YUV image, the luminance component Y is extracted, the noise intensity is determined based on the luminance value of the Y component image, differential filtering and luminance enhancement are performed, adaptive luminance enhancement is performed by combining the luminance value of the texture image, and finally the RGB image is color corrected by color compensation gain.
It achieves adaptive brightness enhancement by significantly brightening dark areas and avoiding overexposure in bright areas, ensuring a precise balance in color reproduction and improving the visual quality of images and the accuracy of computer vision tasks.
Smart Images

Figure CN122289055A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image enhancement method, apparatus, storage medium, and program product. Background Technology
[0002] As the core carrier of information transmission, the visual quality of images directly affects the efficiency of information extraction. In actual data acquisition, factors such as lighting conditions (e.g., nighttime surveillance, cloudy days, low-light indoor environments), equipment performance (e.g., low-resolution cameras, low-cost sensors, sensor noise), and environmental interference (e.g., fog, dust storms, backlighting) result in a large number of images exhibiting low contrast—manifesting as blurred light and dark areas, obscured details (e.g., lack of texture in dark areas, overexposure in bright areas), and insufficient color saturation or color cast. These low-quality images not only degrade the human visual experience but also severely restrict the accuracy of subsequent computer vision tasks (e.g., object detection, image segmentation, medical image diagnosis, intelligent surveillance recognition). For example, the outlines of targets in dark areas of nighttime surveillance images cannot be identified, and lesion details are obscured in low-light medical images.
[0003] Therefore, developing image enhancement technologies that can adapt to complex scenarios and solve the problems of detail restoration, noise suppression, and color fidelity in low-quality images has become one of the key research directions in the field of image processing, especially in scenarios such as intelligent monitoring, autonomous driving, medical imaging, and mobile device photography, where there is an urgent need for application. Summary of the Invention
[0004] To overcome the problems existing in related technologies, this application provides an image enhancement method, device, storage medium, and program product.
[0005] According to a first aspect of the embodiments of this application, an image enhancement method is provided, the method comprising: Convert the RGB image to be processed into a YUV image; Extract the luminance component Y from the YUV image to obtain the Y component image; Based on the brightness value of each pixel in the Y component image, the noise intensity of each pixel is determined; Based on the noise intensity of each pixel, the Y component image is filtered to obtain the texture image corresponding to the Y component image. The intensity of the filtering process on each pixel is proportional to the noise intensity of that pixel. Based on the brightness values of each pixel in the texture image, the brightness of each pixel in the Y component image is enhanced to obtain the enhanced Y component image. The magnitude of the brightness enhancement for each pixel is inversely proportional to the brightness value of the pixel in the texture image. Based on the brightness enhancement magnitude of each pixel in the enhanced Y component image, the color compensation gain of each pixel is determined; and The R, G, and B components of the corresponding pixels in the RGB image are compensated using the color compensation gain of each pixel to obtain the enhanced RGB image.
[0006] According to a second aspect of the embodiments of this application, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect.
[0007] According to a third aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method described in the first aspect.
[0008] According to a fourth aspect of the embodiments of this application, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described in the first aspect.
[0009] The technical solutions provided in this application embodiment may include the following beneficial effects: In this embodiment, the RGB image to be processed is first converted into a YUV image, and the luminance component Y is extracted to achieve separation of luminance and chrominance. Then, the noise intensity is determined based on the luminance value of each pixel in the Y component image, and differential filtering is performed on pixels with different noise intensities to achieve accurate extraction of image texture while suppressing noise interference. Next, based on the luminance value of each pixel in the texture image, the Y component image is enhanced with a differential amplitude to achieve adaptive brightness enhancement that significantly brightens dark areas and avoids overexposure in bright areas. Finally, color compensation is performed on the R, G, and B components of the RGB image based on the brightness enhancement amplitude to achieve a precise balance between brightness enhancement and color restoration.
[0010] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0011] The accompanying drawings, which are incorporated in and form part of this application, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0012] Figure 1 This is a schematic flowchart illustrating an image enhancement method according to an exemplary embodiment of this application.
[0013] Figure 2This is a flowchart illustrating another image enhancement method according to an exemplary embodiment of this application.
[0014] Figure 3 This is a schematic diagram illustrating the before-and-after effects of enhancing the dark areas of an RGB image according to an exemplary embodiment of this application.
[0015] Figure 4 This is a schematic diagram illustrating the before-and-after effect of enhancing the bright areas of an RGB image according to an exemplary embodiment of this application.
[0016] Figure 5 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of this application. Detailed Implementation
[0017] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0018] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0019] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0020] As the core carrier of information transmission, the visual quality of images directly affects the efficiency of information extraction. In actual data acquisition, factors such as lighting conditions (e.g., nighttime surveillance, cloudy days, low-light indoor environments), equipment performance (e.g., low-resolution cameras, low-cost sensors, sensor noise), and environmental interference (e.g., fog, dust storms, backlighting) result in a large number of images exhibiting low contrast—manifesting as blurred light and dark areas, obscured details (e.g., lack of texture in dark areas, overexposure in bright areas), and insufficient color saturation or color cast. These low-quality images not only degrade the human visual experience but also severely restrict the accuracy of subsequent computer vision tasks (e.g., object detection, image segmentation, medical image diagnosis, intelligent surveillance recognition). For example, the outlines of targets in dark areas of nighttime surveillance images cannot be identified, and lesion details are obscured in low-light medical images.
[0021] Therefore, developing image enhancement technologies that can adapt to complex scenarios and solve the problems of detail restoration, noise suppression, and color fidelity in low-quality images has become one of the key research directions in the field of image processing, especially in scenarios such as intelligent monitoring, autonomous driving, medical imaging, and mobile device photography, where there is an urgent need for application.
[0022] However, current image enhancement technologies typically employ a globally uniform enhancement strategy, which can lead to problems such as insufficient brightening of dark areas or overexposure and distortion of bright areas. Alternatively, they may focus on noise suppression and excessively smooth the image, resulting in the loss of texture details. Furthermore, they may neglect color balance correction after brightness enhancement, causing problems such as color cast and abnormal saturation. These technologies are insufficient to meet the high-precision image enhancement requirements in complex scenes.
[0023] Based on this, and to address the problems existing in related technologies, this application provides an image enhancement method. The method first converts the RGB image to be processed into a YUV image, extracting the luminance component Y to achieve separation of luminance and chrominance. Then, based on the luminance values of each pixel in the Y component image, it determines the noise intensity and performs differentiated filtering on pixels with different noise intensities to achieve accurate texture extraction while suppressing noise interference. Next, based on the luminance values of each pixel in the texture image, it performs differentiated brightness enhancement on the Y component image, achieving adaptive brightness enhancement that significantly brightens dark areas and avoids overexposure in bright areas. Finally, it performs color compensation on the R, G, and B components of the RGB image based on the brightness enhancement magnitude, achieving a precise balance between brightness enhancement and color restoration.
[0024] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0025] The image enhancement method provided in this application embodiment can be executed by an electronic device, including but not limited to physical servers, server clusters, cloud servers, smartphones, tablets, personal digital assistants (PDAs), laptops, and desktop computers, etc., which are terminals or devices with image processing capabilities. It is particularly suitable for image processing scenarios related to consumer electronics cameras, such as mobile phone photography and optimization processing after image acquisition by intelligent monitoring equipment.
[0026] Figure 1 This is a schematic flowchart illustrating an image enhancement method according to an exemplary embodiment of this application. Figure 1 As shown, the method includes steps S101 to S107.
[0027] Step S101: Convert the RGB image to be processed into a YUV image.
[0028] Step S102: Extract the luminance component Y from the YUV image to obtain the Y component image.
[0029] The RGB images to be processed typically refer to low-quality images with visual quality defects. Specifically, these defects can manifest as blurred tonal gradations, obscured details (e.g., lack of discernible texture in dark areas, overexposure distortion in bright areas), insufficient color saturation, or significant color casts. These images are often caused by complex acquisition environments, such as nighttime surveillance scenes, outdoor shooting on cloudy days, or image acquisition in low-light indoor environments, or are generated by low-resolution cameras or low-cost image sensors. The acquisition of these RGB images can be achieved in various ways: electronic devices can directly acquire images in real-time using built-in or external cameras, such as a mobile phone capturing nighttime scenes with its rear camera; or they can receive stored images transmitted from other devices, such as nighttime surveillance video frames received from intelligent monitoring equipment or historical images read from storage media. To ensure targeted enhancement processing, electronic devices can also be equipped with a dedicated image quality detection module. By analyzing indicators such as image contrast parameters, texture clarity, and color deviation values, it can automatically identify low-quality images and mark them as RGB images to be processed. Alternatively, users can manually specify the images to be processed through human-computer interaction, such as selecting the target image in a mobile image processing APP or computer software and triggering an enhancement command. After determining the RGB image to be processed based on the above methods, the electronic device will proceed to the subsequent enhancement processing flow.
[0030] Meanwhile, since luminance and chromaticity information are mixed in the RGB color space, directly enhancing an RGB image as a whole can easily lead to color distortion. For example, brightening dark areas may be accompanied by hue shifts, and enhancing contrast may result in abnormal saturation, making it impossible to achieve a precise balance between brightness adjustment and color preservation. Therefore, this embodiment employs a color gamut conversion and separation strategy to convert the RGB image to be processed to the YUV color space, thereby achieving effective separation of luminance and chromaticity. This allows for the separate optimization of luminance information that affects image visual clarity, while avoiding interference with chromaticity information.
[0031] The specific conversion process can use a standardized linear conversion formula: Here, 'a' is a fixed transformation factor (e.g., a preset constant matrix conforming to BT.601 or BT.709 standards to ensure the universality and accuracy of the transformation). The Y component is specifically used to characterize the image's brightness information, and subsequent enhancement processing can be performed solely on this component to precisely control the brightness adjustment effect. The U and V components correspond to the image's chromaticity information, respectively, and their original values remain unchanged during subsequent brightness optimization, thus completely preserving the image's original color features and providing a reliable foundation for subsequent color restoration. Through the above transformation and extraction operations, the final result is an image containing only the Y component, which contains only brightness information, laying the foundation for subsequent differentiated enhancement processing.
[0032] Step S103: Determine the noise intensity of each pixel based on the brightness value of each pixel in the Y component image.
[0033] Step S104: Based on the noise intensity of each pixel, filter each pixel of the Y component image to obtain the texture image corresponding to the Y component image. The intensity of the filtering process for each pixel is proportional to the noise intensity of that pixel.
[0034] Before enhancing the brightness of the Y component image, in order to achieve adaptive enhancement adjustment of pixels in different brightness ranges, ensure effective brightening of dark areas, no overexposure of highlight areas, and smooth transition of intermediate brightness without layering, this embodiment can pre-extract the texture image corresponding to the Y component image. Because the texture image can accurately reflect the detailed features of the image (such as object outlines, surface textures, etc.), the brightness enhancement amplitude can be adjusted based on the differences in texture distribution in the image, which can achieve targeted adaptive brightness enhancement optimization, brightening dark areas while preserving texture details (such as target outlines in night monitoring, texture structures in low-light images), and avoiding loss of details during the enhancement process.
[0035] During texture extraction, low-quality images are often accompanied by significant noise. Directly extracting the texture can lead to noise being misidentified as detail, which is then amplified in subsequent enhancement, severely impacting image quality. Therefore, to suppress noise interference, this embodiment can perform filtering simultaneously during texture image extraction to obtain a denoised, clean texture image, achieving the dual goals of extracting texture details and suppressing noise.
[0036] Meanwhile, since the noise intensity of pixels in different regions may vary, for example, the brightness value of pixels in dark areas fluctuates greatly and the noise is concentrated, while the brightness of pixels in bright areas is relatively stable and the noise is less. If a uniform intensity of filtering is used, either insufficient filtering will result in residual noise in dark areas, or excessive filtering will cause blurring of textures in bright areas. Therefore, this embodiment can further perform different intensity filtering on pixels in different regions of the Y component image according to the noise intensity of the pixels, so as to achieve differentiated filtering processing of "stronger filtering for stronger noise and weaker filtering for weaker noise", which can both ensure the noise suppression effect and avoid the loss of texture details.
[0037] Specifically, the noise intensity in this embodiment can be determined in various ways. For example, the variance of the brightness values in the 3×3 or 5×5 neighborhood of each pixel can be calculated. The larger the variance, the more severe the brightness fluctuation in that area, and the higher the noise intensity. Alternatively, the noise intensity can be characterized by grayscale gradient detection, the degree of deviation between the pixel value and the neighborhood mean, etc. The specific method can be selected based on the user's actual filtering needs, and this embodiment does not limit this. The filtering process can also be performed using various methods such as bilateral filtering, median filtering, and guided filtering. Among them, guided filtering can preserve the image edge texture details to the greatest extent while smoothing noise. Compared with other filtering methods, it is more suitable for the texture extraction and noise suppression requirements of this application. Therefore, in some embodiments, the filtering process in step S104 can preferably be guided filtering.
[0038] In an embodiment employing guided filtering, the specific filtering process is as follows: First, based on the noise intensity of each pixel, the filter window size and regularization parameter for guided filtering of each pixel in the Y component image are determined. For each pixel, the filter window size and regularization parameter are proportional to the noise intensity of that pixel. For example, when a pixel in a dark area has a large neighborhood variance and high noise intensity, a larger filter window size (e.g., a 15×15 window) and a larger regularization parameter (e.g., 0.1) can be configured to suppress noise through stronger smoothing, thus enhancing the filtering's ability to suppress strong noise. Conversely, when a pixel in a bright area has a small neighborhood variance and low noise intensity, a smaller filter window size (e.g., a 5×5 window) and a smaller regularization parameter (e.g., 0.01) can be configured to preserve texture details to the maximum extent while slightly reducing noise, avoiding over-filtering that leads to blurred details. Subsequently, using the Y component image itself as the guide image, guided filtering of different intensities is performed on each pixel of the Y component image based on the dynamically determined filter window size and regularization parameters, so that the filtering result can effectively suppress noise and retain the original texture details of the image to the greatest extent, thus achieving a balance between noise suppression and detail preservation.
[0039] On the other hand, considering the large number of image pixels and the large amount of data in practical applications, directly filtering the original resolution Y component image would result in high computational complexity and slow processing speed, making it difficult to meet the real-time requirements of electronic devices for image processing. To solve this problem, in some embodiments, the image pyramid scaling method can be used to optimize the filtering process in step S104: First, the Y component image is downsampled (e.g., by using mean sampling, interlaced sampling, etc., to compress the image resolution to 1 / 4 or 1 / 8 of the original), resulting in a downsampled image of the Y component image with a smaller scale. At this time, the image data volume is greatly reduced, and the filtering computation is significantly reduced; then, based on the noise intensity of each pixel in the downsampled image, different intensity filtering is applied to the pixels in different regions to obtain the texture image corresponding to the downsampled image; finally, through upsampling (e.g., bilinear interpolation, bicubic interpolation, etc., using neighborhood pixel information to restore image details), the scale of the texture image corresponding to the downsampled image is restored to the same scale as the original Y component image, and finally the texture image corresponding to the Y component image is obtained. Due to the scale invariance of the image, the relative distribution characteristics of noise and texture remain stable during downsampling. Subsequent upsampling recovery will hardly lose the texture extraction accuracy, while the computational complexity can be greatly reduced, significantly improving the filtering speed and meeting real-time requirements.
[0040] Of course, in other embodiments, the guided filtering and filtering process optimization described above can be combined to achieve dual optimization of the speed and effect of texture image extraction. The specific process is as follows: First, the Y component image is downsampled to obtain a downsampled image; then, based on the noise intensity of each pixel in the downsampled image, the filter window size and regularization parameters for guiding filtering of pixels in different regions are dynamically determined. For each pixel, the filter window size and regularization parameters for guiding filtering of that pixel are proportional to the noise intensity of that pixel; subsequently, according to the determined filter window size and regularization parameters, the downsampled image is used as the guide image, and guided filtering of each pixel in the downsampled image with different intensities is performed to obtain the texture image corresponding to the downsampled image; finally, it is upsampled to restore it to the same image scale as the Y component image to obtain the texture image corresponding to the Y component image. This combined approach achieves a balance between texture extraction and noise suppression through guided filtering, and reduces computational complexity through image scale conversion. It effectively resolves the contradiction of traditional algorithms where "fast speed results in poor performance, and good performance results in slow speed." While ensuring the accuracy of texture extraction, it significantly reduces computational complexity and effectively meets the real-time image processing requirements of electronic devices.
[0041] Step S105: Based on the brightness value of each pixel in the texture image, enhance the brightness of each pixel in the Y component image to obtain the enhanced Y component image. For each pixel, the magnitude of the brightness enhancement is inversely proportional to the brightness value of the pixel in the texture image.
[0042] After obtaining the texture image, this embodiment can enhance the Y component image by different amplitudes based on the brightness values of pixels in different regions of the texture image. This achieves a differentiated brightness enhancement effect, effectively brightening dark areas, preventing overexposure in highlight areas, and ensuring smooth transitions in mid-tone brightness without layering. The brightness value of a pixel in the texture image directly reflects the richness of detail and sufficiency of brightness in the corresponding area. Higher brightness values indicate denser details and sufficient brightness in the area, requiring less enhancement and thus allowing for a smaller enhancement amplitude to avoid overexposure distortion in bright areas. Conversely, lower brightness values often correspond to dark areas or areas lacking detail, necessitating a larger enhancement amplitude to precisely brighten dark areas and highlight hidden details. This differentiated brightness enhancement scheme fundamentally solves the problems of insufficient brightening of dark areas or overexposure distortion in bright areas caused by uniform brightness enhancement in traditional global enhancement schemes.
[0043] Specifically, there are various ways to achieve differentiated brightness enhancement in this embodiment, such as adaptive histogram equalization, logarithmic transformation, and gamma transformation. Among them, gamma transformation has advantages such as simple mathematical model, low computational complexity, strong controllability of enhancement intensity, and wide adaptability. Therefore, in some embodiments, the brightness enhancement method in step S105 can preferably be gamma transformation.
[0044] When using gamma transform for brightness enhancement, the Y component image needs to be normalized first. That is, after obtaining the Y component image in step S102, the brightness values of each pixel in the Y component image are normalized from the original range [0,255] to the interval [0,1] to obtain the normalized Y component image. This is because the core formula of gamma transform is: (O is the output value, Y is the input value,) (For gamma parameters), if the input luminance value Y is within the unprocessed standard range of [0, 255], when When the values are non-integer, problems such as numerical overflow and precision distortion can easily occur during the calculation process, and the consistency of the transformation effect across different brightness ranges is poor. However, normalizing the brightness values to the [0,1] range can effectively avoid these problems, ensuring the stability and calculation accuracy of the gamma transform. At the same time, the normalization operation can also expand the dynamic grayscale range of the image, solving the problems of low contrast and loss of detail caused by concentrated grayscale values. This provides a unified numerical benchmark for subsequent filtering, color compensation, and detail preservation, avoiding uneven enhancement effects caused by large ranges in brightness values.
[0045] Accordingly, the noise intensity calculation in step S103 and the filtering process in step S104 are also performed based on the normalized Y component image. That is, the noise intensity of each pixel in the normalized Y component image is determined according to the brightness value of each pixel in the normalized Y component image. Then, according to the noise intensity of each pixel in the normalized Y component image, filtering processes of different intensities are performed on each pixel in the normalized Y component image to finally obtain the texture image corresponding to the normalized Y component image. In this case, the intensity of the filtering process on each pixel in the normalized Y component image is proportional to the noise intensity of that pixel.
[0046] Then, proceed to step S105, where gamma transform is used for brightness enhancement: First, based on the brightness values of each pixel in the texture image corresponding to the normalized Y component image, determine the gamma parameters for gamma transform of each pixel in the normalized Y component image; wherein, for each pixel in the normalized Y component image, the gamma parameters for gamma transform of that pixel are proportional to the brightness value of that pixel in the texture image corresponding to the normalized Y component image; then, based on the determined gamma parameters of each pixel, perform gamma transforms of different amplitudes on each pixel of the normalized Y component image to obtain the enhanced normalized Y component image. Specifically, assume that the normalized Y component image in this process is Y(x,y), its corresponding texture image is Q(x,y), and the gamma parameters of each pixel are... It can be calculated using the following function: Enhanced normalized Y component image Then it is: The functional relationship f between the gamma parameter and the texture image can be set according to the user's actual brightness enhancement needs; for example, it can be set to... For linear functions (k and b are preset constants) or nonlinear functions, it is only necessary to satisfy the following: The higher the value, A larger proportional relationship is acceptable, but this embodiment does not impose any limitation on this. When A higher value corresponds to an area with rich detail and sufficient brightness. The value is relatively large; according to the characteristics of the gamma transform, at this time... The power operation result (within the [0,1] interval) increases gradually, meaning the enhancement amplitude is small, which can avoid overexposure in bright areas; when When the value is low (corresponding to dark areas and areas lacking detail). Smaller The result of the exponentiation operation is significantly increased, meaning the enhancement is substantial and can effectively brighten dark areas.
[0047] Subsequently, since the brightness values of pixels in the enhanced normalized Y component image obtained after gamma transformation are still within the normalized range of [0,1], while the brightness display standard of existing display devices (such as mobile phone screens and monitors) is in the range of [0,255], direct output would result in the image not displaying correctly (manifesting as overall darkness and invisibility of details). Therefore, after brightness enhancement by gamma transformation, it is necessary to perform grayscale stretching on the pixels in the enhanced image to map their brightness values to the preset standard brightness range of [0,255] to obtain the enhanced Y component image. Specifically, this embodiment can use linear mapping or other methods to achieve grayscale stretching. The domain of the mapping is [0,1], and the value range is [0,255]. The mapped brightness component is obtained through linear interpolation, thereby ensuring that the stretched brightness value accurately matches the conventional standard of image display, laying the foundation for subsequent color compensation and image restoration.
[0048] Step S106: Determine the color compensation gain of each pixel based on the brightness enhancement magnitude of each pixel in the enhanced Y component image.
[0049] Step S107: Using the color compensation gain of each pixel, perform color compensation on the R component, G component and B component of the corresponding pixel in the RGB image respectively to obtain the enhanced RGB image.
[0050] After enhancing the brightness of an image, it is also necessary to simultaneously perform corresponding color compensation. This is because brightness and chromaticity are strongly correlated in visual perception of images. Simply enhancing brightness will disrupt the color balance of the original image. For example, brightening a low-light image can easily lead to reduced saturation (a grayish appearance) or color cast (such as a yellowish tint in dark areas or distorted colors in greenery), resulting in a significant deviation between the enhanced image and the actual scene's colors, severely impacting the visual experience. Furthermore, the degree of brightness enhancement varies among different pixels in the image. To specifically correct the color imbalance caused by brightness changes, adaptive color compensation can be applied based on the degree of brightness enhancement for different pixels. For instance, areas with a large increase in brightness (such as the original dark areas) can receive a larger color compensation gain to restore saturation, while areas with a small increase in brightness (such as the original bright areas) can receive a smaller color compensation gain to keep the colors close to their original state. Ultimately, this achieves a precise balance between brightness optimization and color restoration, ensuring that the enhanced image's colors are consistent with the original scene, without color cast or abnormal saturation, and exhibiting excellent color reproduction, especially in low-light and dark environments.
[0051] Specifically, in some embodiments, the process of determining the color compensation gain of each pixel based on the brightness enhancement magnitude of each pixel in the enhanced Y component image is as follows: First, based on the R, G, and B components of each pixel in the original RGB image, the initial saturation of each pixel is calculated. The saturation calculation method can refer to existing calculation formulas, such as saturation S = (max(R, G, B) - min(R, G, B)) / max(R, G, B), or the RGB image can be converted to the HSV color space and the value of the S channel can be directly extracted. This embodiment does not limit this method.
[0052] Secondly, based on the brightness enhancement magnitude of each pixel in the enhanced Y component image, the color compensation gain of each pixel is initially determined. The brightness enhancement magnitude of a pixel can be represented by the ratio of the brightness values before and after enhancement, or by a relative rate of change. The choice can be made according to the actual calculation needs of users in different scenarios; this embodiment does not limit this. Taking the ratio of the brightness values before and after enhancement to represent the brightness enhancement magnitude of a pixel as an example, assuming the brightness value of pixel (x,y) in the original Y component image is Y(x,y), and the brightness value of the pixel after enhancement is Y'(x,y), then the brightness enhancement magnitude of the pixel can be expressed as... (If Y(x,y) is 0, A(x,y) can be preset to a fixed maximum value to avoid division by zero). The color compensation gain has a preset functional relationship with the brightness enhancement magnitude; for example, the color compensation gain can be set... , These are preset parameters; they can be initially determined during the calculation process. The value of is taken, and then combined with the specific brightness enhancement range of each pixel, to calculate the corresponding color compensation gain. The functional relationship between the color compensation gain and the brightness enhancement range is not fixed and can be flexibly adjusted according to the user's actual color reproduction needs; this embodiment does not impose any limitations on this.
[0053] Subsequently, using the initially determined color compensation gain for each pixel, color compensation is performed on the R, G, and B components of the corresponding pixels in the RGB image, yielding the compensated R, G, and B components for each pixel. Assuming that the R, G, and B components of each pixel in the original RGB image are R(x,y), G(x,y), and B(x,y) respectively, the initially compensated R component can be... The compensated G component can be The compensated B component can be .
[0054] Next, following the same calculation method as the initial saturation calculation, the compensated saturation of each pixel is calculated based on the compensated R, G, and B components of each pixel.
[0055] Finally, with the goal of minimizing the difference between the compensated saturation and the initial saturation of each pixel, the initially determined color compensation gain for each pixel is iteratively adjusted. During the iteration process, optimization methods such as gradient descent and greedy algorithms can be used to adjust the gain value. For example, if the compensated saturation is higher than the initial saturation, the compensation gain can be appropriately reduced; if the compensated saturation is lower than the initial saturation, the compensation gain can be appropriately increased, until the difference between the two is less than a preset threshold or the preset number of iterations is reached, at which point the iteration stops, and the currently adjusted color compensation gain is taken as the final color compensation gain for each pixel.
[0056] Of course, in addition to the iterative optimization methods mentioned above, when determining the color compensation gain, one can also accumulate prior knowledge through numerous experiments and directly determine the parameters in the functional relationship between the color compensation gain and the brightness enhancement amplitude. This allows for the rapid establishment of a correlation between color compensation gain and brightness enhancement, simplifying the calculation process and improving image processing efficiency.
[0057] In the above embodiments, the same color compensation gain is used to compensate for the R, G, and B components, which is mainly suitable for scenarios where the color deviation is relatively uniform. However, in practical applications, there may be situations where the color deviation of each component is inconsistent. For example, in low-light environments, the R component is prone to being dark, and the B component is prone to color distortion. In this case, in order to achieve more accurate color reproduction, independent color compensation gains can be set for the R, G, and B components respectively, i.e., R component compensation gain, G component compensation gain, and B component compensation gain. Of course, in other cases, the color compensation gains of two components can also be set to be the same. The specific choice can be made according to the user's actual color compensation gain, and this embodiment does not limit this.
[0058] When setting independent color compensation gains for the R, G, and B components, the above iterative process can be performed on the R, G, and B components respectively to determine the color compensation gain corresponding to each component: First, based on the R, G, and B components of each pixel in the RGB image, calculate the initial saturation of each pixel; then, based on the brightness enhancement magnitude of each pixel in the enhanced Y component image, preliminarily determine the R component compensation gain, G component compensation gain, and B component compensation gain of each pixel; finally, using the preliminarily determined R component compensation gain, G component compensation gain, and B component compensation gain of each pixel, respectively, adjust the R, G, and B components of the corresponding pixels in the RGB image. Color compensation is performed on the B component to obtain the compensated R, G, and B components for each pixel. Based on the compensated R, G, and B components, the compensated saturation of each pixel is calculated. Finally, with the goal of minimizing the difference between the compensated saturation and the initial saturation of each pixel, the initially determined R component compensation gain, G component compensation gain, and B component compensation gain for each pixel are iteratively adjusted until the difference is less than a preset threshold or the number of iterations is reached. The iteration stops, and the currently adjusted R component compensation gain, G component compensation gain, and B component compensation gain are determined as the final R component compensation gain, G component compensation gain, and B component compensation gain for each pixel.
[0059] After obtaining the color compensation gain of each pixel, the color compensation gain can be used to perform color compensation on the R, G, and B components of the corresponding pixels in the original RGB image, so as to obtain the compensated R, G, and B components of each pixel, and then combine them to form an enhanced RGB image, thereby effectively restoring the color imbalance caused by brightness enhancement.
[0060] Furthermore, to enhance the flexibility and user adaptability of image enhancement during implementation, electronic devices can also support human-computer interaction functions. They can receive parameter adjustment commands input by the user through the operating interface and dynamically adjust the intensity of filtering for each pixel, the magnitude of brightness enhancement for each pixel, and / or the color compensation gain for each pixel based on these commands. For example, users can manually increase the filtering intensity in dark areas to further suppress noise, or fine-tune the brightness enhancement to avoid overexposure in bright areas, or adjust the color compensation gain to optimize image saturation, thereby achieving personalized image optimization tailored to individual user habits.
[0061] Meanwhile, electronic devices can also preset various customized optimization styles, such as portrait mode and landscape mode, to adapt to different shooting scenarios and visual needs, improving ease of operation and flexibility. The portrait mode is specifically designed for portrait shooting scenarios, using AI face detection algorithms to accurately locate the face area in the image. Combined with the light and shadow characteristics of backlit scenes, it prioritizes brightening details in the face area and surrounding dark areas, while moderately increasing the overall image contrast. This ensures natural skin tone and clear contours while avoiding issues like darkened faces and overexposed backgrounds caused by backlighting. The landscape mode focuses on color and brightness optimization for natural landscape shooting scenarios. In the color compensation and RGB space restoration stages, it increases color compensation gain to enhance the overall saturation and color gradation of the image, resulting in moderate brightness and vibrant, rich colors, effectively restoring the realistic texture of natural landscapes.
[0062] In summary, to provide a clearer understanding of this application, the following example illustrates the overall process of the image enhancement method provided in this application.
[0063] like Figure 2 As shown, in this embodiment, the overall process of the image enhancement method includes the following steps: Step S201: Convert the RGB image to be processed into a YUV image; Step S202: Extract the luminance component Y from the YUV image to obtain the Y component image; Step S203: Normalize the brightness values of each pixel in the Y component image to obtain a normalized Y component image. Step S204: Perform downsampling processing on the normalized Y component image to obtain a downsampled image of the normalized Y component image; Step S205: Determine the noise intensity of each pixel in the downsampled image of the normalized Y component image based on the brightness value of each pixel in the downsampled image of the normalized Y component image. Step S206: Based on the noise intensity of each pixel in the downsampled image of the normalized Y component image, filter the pixels of the downsampled image of the normalized Y component image to obtain the texture image corresponding to the downsampled image of the normalized Y component image; wherein, for each pixel in the downsampled image of the normalized Y component image, the intensity of the filtering process on the pixel is proportional to the noise intensity of the pixel in the downsampled image of the normalized Y component image; Step S207: Upsample the texture image corresponding to the downsampled image of the normalized Y component image to restore the scale of the texture image corresponding to the downsampled image of the normalized Y component image to the same scale as the normalized Y component image, and obtain the texture image corresponding to the normalized Y component image. Step S208: Based on the brightness values of each pixel in the texture image corresponding to the normalized Y component image, determine the gamma parameters for gamma transformation of each pixel in the normalized Y component image; wherein, for each pixel in the normalized Y component image, the gamma parameters for gamma transformation of the pixel are proportional to the brightness value of the pixel in the texture image corresponding to the normalized Y component image. Step S209: Based on the determined gamma parameters of each pixel, perform gamma transformation on each pixel of the normalized Y component image to obtain the enhanced normalized Y component image. Step S210: Map the brightness values of each pixel in the enhanced normalized Y component image to a preset standard brightness range to obtain the enhanced Y component image. Step S211: Determine the color compensation gain of each pixel based on the brightness enhancement magnitude of each pixel in the enhanced Y component image. Step S212: Using the color compensation gain of each pixel, perform color compensation on the R component, G component and B component of the corresponding pixel in the RGB image respectively to obtain the enhanced RGB image.
[0064] In addition, this application also... Figure 3 , Figure 4 This demonstrates the image enhancement effect of the method described in this application.
[0065] Figure 3 , Figure 4 The images on the left are all unprocessed, low-quality RGB images, typical of low-light scenes, with poor image quality: dark areas (such as...) Figure 3 The mountain area A on the left is completely black, with no texture details visible, significant overall noise, and a narrow dynamic range; the bright areas (such as...) are completely black. Figure 4 Although the sky area B on the left is visible, its color saturation is insufficient, and the overall image is too dark.
[0066] Figure 3 , Figure 4 The right side shows a schematic diagram of the enhanced effect after the method described in this application: in, Figure 3 The diagram shows a comparison of the enhancement effects before and after enhancement of dark area A. It can be seen that the dark area is significantly brightened, the previously hidden mountain textures and rock outlines are clearly presented, and the noise in the dark area is not amplified, resulting in a significant improvement in the overall signal-to-noise ratio.
[0067] Figure 4 This is a comparison diagram of the enhancement effect before and after for bright area B. It can be seen that there is no overexposure in the bright area, the blue of the sky is purer and fuller, the white clouds are clearly layered, and the brightness transition is smooth and natural.
[0068] Overall, the enhanced image exhibits a significantly wider dynamic range, accurate color reproduction, and consistency with the colors of the real scene, without any color cast or abnormal saturation. Therefore, the image enhancement method provided in this application effectively achieves a balance between brightening dark areas and preserving details, avoids overexposure in bright areas, and maintains accurate color reproduction, thus efficiently enhancing the visual effect of low-quality images.
[0069] Corresponding to the embodiments of the foregoing methods, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor; wherein, when the processor executes the computer program, it implements the steps of the image enhancement method described in any of the above embodiments.
[0070] For example, processors include, but are not limited to, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), application-specific integrated circuits (ASICs), or field-programmable gate arrays (FPGAs).
[0071] For example, the memory may include at least one type of storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc.
[0072] Figure 5 This is a structural block diagram of a computer device according to an exemplary embodiment of this application. Figure 5 As shown, at the hardware level, the computer device includes a processor 501, an internal bus 502, a network interface 503, memory 504, and non-volatile memory 505, and may also include other hardware required for business operations. One or more embodiments of this application can be implemented in software, for example, the processor 501 reads the corresponding computer program from the non-volatile memory 505 into memory 504 and then runs it. Of course, in addition to software implementation, one or more embodiments of this application do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the above processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0073] Corresponding to the embodiments of the foregoing methods, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the image enhancement method described in any of the above embodiments.
[0074] Corresponding to the embodiments of the foregoing methods, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the image enhancement method described in any of the above embodiments.
[0075] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0076] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention filed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the foregoing claims.
[0077] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
[0078] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. An image enhancement method, characterized in that, include: Convert the RGB image to be processed into a YUV image; Extract the luminance component Y from the YUV image to obtain the Y component image; Based on the brightness value of each pixel in the Y component image, the noise intensity of each pixel is determined; Based on the noise intensity of each pixel, the Y component image is filtered to obtain the texture image corresponding to the Y component image. The intensity of the filtering process on each pixel is proportional to the noise intensity of that pixel. Based on the brightness values of each pixel in the texture image, the brightness of each pixel in the Y component image is enhanced to obtain the enhanced Y component image. The magnitude of the brightness enhancement for each pixel is inversely proportional to the brightness value of the pixel in the texture image. Based on the brightness enhancement magnitude of each pixel in the enhanced Y component image, the color compensation gain of each pixel is determined; and By utilizing the color compensation gain of each pixel, color compensation is performed on the R, G, and B components of the corresponding pixels in the RGB image to obtain an enhanced RGB image.
2. The method according to claim 1, characterized in that, The filtering process is a guided filter; Based on the noise intensity of each pixel, filtering processing is performed on each pixel of the Y component image, including: Based on the noise intensity of each pixel, the filter window size and regularization parameters for guiding filtering of each pixel in the Y component image are determined; wherein, for each pixel, the filter window size and regularization parameters for guiding filtering of that pixel are both proportional to the noise intensity of that pixel; Based on the determined filter window size and regularization parameters for each pixel, the Y component image is used as a guide image to perform guided filtering on each pixel of the Y component image.
3. The method according to claim 1, characterized in that, Based on the noise intensity of each pixel, filtering processing is performed on each pixel of the Y component image, including: The Y component image is downsampled to obtain a downsampled image of the Y component image; Based on the noise intensity of each pixel in the downsampled image, each pixel in the downsampled image is filtered to obtain the texture image corresponding to the downsampled image; wherein, for each pixel in the downsampled image, the intensity of the filtering process on that pixel is proportional to the noise intensity of that pixel in the downsampled image; The texture image corresponding to the downsampled image is upsampled to restore the scale of the texture image corresponding to the downsampled image to the same scale as the Y component image.
4. The method according to claim 1, characterized in that, The brightness enhancement is a gamma transform; After obtaining the Y component image, the following is also included: The brightness values of each pixel in the Y component image are normalized to obtain a normalized Y component image. Based on the brightness value of each pixel in the Y component image, the noise intensity of each pixel is determined, including: Based on the brightness value of each pixel in the normalized Y component image, the noise intensity of each pixel in the normalized Y component image is determined. Based on the noise intensity of each pixel, the Y component image is filtered to obtain the texture image corresponding to the Y component image, including: Based on the noise intensity of each pixel in the normalized Y component image, each pixel in the normalized Y component image is filtered to obtain the texture image corresponding to the normalized Y component image; wherein, for each pixel in the normalized Y component image, the intensity of the filtering process on the pixel is proportional to the noise intensity of the pixel. Based on the brightness values of each pixel in the texture image, the brightness of each pixel in the Y component image is enhanced to obtain an enhanced Y component image, including: Based on the brightness value of each pixel in the texture image corresponding to the normalized Y component image, the gamma parameters for gamma transformation of each pixel in the normalized Y component image are determined; wherein, for each pixel in the normalized Y component image, the gamma parameters for gamma transformation of the pixel are proportional to the brightness value of the pixel in the texture image corresponding to the normalized Y component image. Based on the determined gamma parameters of each pixel, a gamma transform is performed on each pixel of the normalized Y component image to obtain an enhanced normalized Y component image. The brightness values of each pixel in the enhanced normalized Y component image are mapped to a preset standard brightness range to obtain the enhanced Y component image.
5. The method according to claim 1, characterized in that, Based on the brightness enhancement magnitude of each pixel in the enhanced Y component image, the color compensation gain of each pixel is determined, including: Calculate the initial saturation of each pixel based on the R, G, and B components of the RGB image. Based on the brightness enhancement magnitude of each pixel in the enhanced Y component image, the color compensation gain of each pixel is initially determined. Using the preliminarily determined color compensation gain of each pixel, color compensation is performed on the R component, G component, and B component of the corresponding pixel in the RGB image to obtain the compensated R component, G component, and B component of each pixel. Calculate the saturation of each pixel after compensation based on the R, G and B components after compensation. With the goal of minimizing the difference between the compensated saturation and the initial saturation of each pixel, the color compensation gain of each pixel is iteratively adjusted until the difference is less than a preset threshold or the number of iterations is reached. Then the iteration stops, and the currently adjusted color compensation gain is used as the color compensation gain of each pixel.
6. The method according to claim 5, characterized in that, The color compensation gain for each pixel includes the R component compensation gain, G component compensation gain, and B component compensation gain for each pixel.
7. The method according to claim 1, characterized in that, Also includes: Receive parameter adjustment commands input by the user; Based on the parameter adjustment instructions, adjust the intensity of filtering for each pixel, the magnitude of brightness enhancement for each pixel, and / or the color compensation gain for each pixel.
8. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, It stores a computer program thereon, which, when executed by a processor, implements the method described in any one of claims 1 to 7.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1 to 7.