Image processing method and device and electronic equipment
By performing resolution division and information processing on the image, brightness and contrast enhancement signals are generated, and the unnatural image problems caused by the single-scale compensation strategy are solved, achieving a more natural and clear image effect.
Patent Information
- Application Number
- CN202310464932.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-26
- Publication Date
- 2024-11-01
AI Technical Summary
The image compensation strategy based on single-scale in the prior art causes the compensated image to be unnatural, resulting in problems such as black edges, insufficient details and excessive sharpening.
By dividing the image to be processed, images with different resolutions are generated, their statistical information, contrast information and brightness information are calculated, initial brightness mask and contrast enhancement signals are generated, and the brightness and contrast of the image are adjusted to achieve a more natural image Processing effect.
It effectively improves the unnatural image problems caused by the single-scale image compensation strategy, significantly reduces black edges and insufficient details, and improves the sharpness and contrast balance of the image.
Smart Images

Figure CN118887150A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method, device and electronic equipment. Background Art
[0002] In image processing, image contrast enhancement is the most basic technology with a relatively simple principle but very important. It can change the grayscale range occupied by image data according to user requirements. The larger the grayscale distribution range, the clearer the image details are presented, and the higher the requirement for image radiation resolution.
[0003] At present, the contrast enhancement control strategy for local brightness of an image mainly adopts single-scale brightness and contrast compensation. However, this compensation method will make the compensated image unnatural. For example, after image sharpening, the image has black edges at high-contrast edges, the problem of insufficient details and local contrast caused by the inability to balance detail enhancement and black edges, the image is blurred, or the problem of over-sharpening of some areas of the image caused by directly raising the edge signal addition level in order to enhance sharpening. Summary of the invention
[0004] In view of this, the present application provides an image processing method, device and electronic device, the main purpose of which is to improve the technical problem that a single-scale image compensation strategy makes the compensated image unnatural.
[0005] In a first aspect, the present application provides an image processing method, comprising:
[0006] Process the image to be processed to obtain images with different resolutions;
[0007] Determine statistical information, contrast information, and brightness information respectively corresponding to the images with different resolutions;
[0008] Based on the statistical information, generating initial brightness masks corresponding to the images with different resolutions respectively;
[0009] Determining a brightness enhancement mask according to the contrast information and the initial brightness mask respectively corresponding to the images with different resolutions;
[0010] Determining, according to the brightness enhancement mask and the brightness information, contrast enhancement signals corresponding to the images with different resolutions respectively;
[0011] The brightness and contrast of the image to be processed are adjusted according to the brightness enhancement mask and the contrast enhancement signal.
[0012] In a second aspect, the present application provides an image processing device, comprising:
[0013] A processing unit is configured to process the image to be processed to obtain images with different resolutions;
[0014] A calculation unit, configured to determine statistical information, contrast information and brightness information respectively corresponding to the images with different resolutions;
[0015] A generating unit, configured to generate initial brightness masks corresponding to the images of different resolutions respectively based on the statistical information;
[0016] a fusion unit configured to determine a brightness enhancement mask according to the contrast information and the initial brightness mask respectively corresponding to the images with different resolutions;
[0017] A difference unit, configured to determine contrast enhancement signals corresponding to the images of different resolutions respectively according to the brightness enhancement mask and the brightness information;
[0018] The adjustment unit is configured to adjust the brightness and contrast of the image to be processed according to the brightness enhancement mask and the contrast enhancement signal.
[0019] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the image processing method described in the first aspect.
[0020] In a fourth aspect, the present application provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the image processing method described in the first aspect when executing the computer program.
[0021] By means of the above technical scheme, the present application provides an image processing method, device and electronic device, which first processes the image to be processed to obtain images of different resolutions, and determines the statistical information, contrast information and brightness information corresponding to the images of different resolutions. According to the statistical information, the initial brightness masks corresponding to the images of different resolutions are generated, and then the brightness enhancement mask is determined according to the contrast information and the initial brightness mask corresponding to the images of different resolutions. Then, according to the brightness enhancement mask and the brightness information, the contrast enhancement signals corresponding to the images of different resolutions are determined, and the brightness and contrast of the image to be processed are adjusted according to the brightness enhancement mask and the contrast enhancement signal. Compared with the related art, the present application divides the original image into different scales according to the resolution, and then determines the brightness enhancement mask and the contrast enhancement signal based on the relevant information of the images of different resolutions to adjust the image to be processed, which can effectively improve the problem that the single-scale image compensation strategy will cause the image to be unnatural.
[0022] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0024] 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 or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0025] Figure 1 A schematic diagram of a process flow of an image processing method provided in an embodiment of the present application is shown;
[0026] Figure 2 A schematic diagram showing a flow chart of another image processing method provided in an embodiment of the present application is shown;
[0027] Figure 3 A schematic diagram showing a flow chart of another image processing method provided in an embodiment of the present application is shown;
[0028] Figure 4 A schematic diagram showing a flow chart of another image processing method provided in an embodiment of the present application is shown;
[0029] Figure 5 A schematic diagram showing a flow chart of another image processing method provided in an embodiment of the present application is shown;
[0030] Figure 6 A schematic structural diagram of an image processing device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0031] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0032] The main scenario of the solution proposed in this embodiment is as a key module of the image signal processing (ISP) in the image processor, in the image sharpening and local brightness contrast processing process of the image pipeline. In this process, high-quality local contrast enhancement and detail enhancement control are required, and the image processing method proposed in this embodiment can be used, and the method is open to all scenarios, including image processing in single-frame shooting mode, image processing in multi-frame shooting mode, image processing in preview mode, image processing in video recording mode, night scene shooting, image processing in video mode, and other shooting and video usage scenarios. All of these methods can adopt this method.
[0033] In order to improve the technical problem in the related art that a single-scale image compensation strategy may make the compensated image unnatural, this embodiment provides an image processing method, such as Figure 1 As shown, the method includes:
[0034] S101, processing the image to be processed to obtain images with different resolutions.
[0035] In this step, the purpose is to process the image to be processed based on the resolution to obtain images with different resolutions, which can be specifically achieved through a resolution generation module. In actual design and implementation, other methods can also be adopted, such as downsampling the original resolution image, i.e., the image to be processed, multiple times to obtain images with different resolutions.
[0036] S102: Determine statistical information, contrast information, and brightness information corresponding to images of different resolutions.
[0037] After obtaining images of different resolutions, it is necessary to calculate the statistical information, contrast information and brightness information corresponding to the images of different resolutions. The statistical information is also called brightness statistical information, which may include the number of pixels pcnt, the sum of pixel values vsum, etc.
[0038] S103 . Generate initial brightness masks corresponding to images of different resolutions based on the statistical information.
[0039] The statistical information here is that each image of different resolutions has corresponding statistical information. Similarly, images of different resolutions also generate corresponding initial brightness masks.
[0040] S104: Determine a brightness enhancement mask according to the contrast information and the initial brightness mask corresponding to the images with different resolutions.
[0041] The purpose of obtaining the brightness enhancement mask is to use more brightness enhancement information of low-resolution layers in low-contrast positions to avoid overshoot in these positions and to smoothly avoid the generation of black and white edges; use the brightness enhancement information of the current resolution layer in high-contrast positions to avoid loss of details and insufficient compensation. Therefore, it is necessary to use the contrast information of images with different resolutions to determine the brightness enhancement mask.
[0042] S105 . Determine contrast enhancement signals corresponding to images of different resolutions according to the brightness enhancement mask and the brightness information.
[0043] In the previous step, we obtained the brightness enhancement mask. Based on the brightness enhancement mask and the brightness information corresponding to the original images of different resolutions, in this step, we need to focus on local contrast enhancement. In addition to enhancing the local brightness, we also need to enhance the local contrast dimension to better highlight the local details and contrast perception. Therefore, we also need to determine the contrast enhancement signal corresponding to images of different resolutions.
[0044] S106 , adjusting the brightness and contrast of the image to be processed according to the brightness enhancement mask and the contrast enhancement signal.
[0045] In this embodiment, the image to be processed is processed to obtain images of different resolutions, and the statistical information, contrast information and brightness information corresponding to the images of different resolutions are determined. The initial brightness masks corresponding to the images of different resolutions are generated according to the statistical information, and then the brightness enhancement mask is determined according to the contrast information and the initial brightness mask corresponding to the images of different resolutions. Then, the contrast enhancement signals corresponding to the images of different resolutions are determined according to the brightness enhancement mask and the brightness information, and the brightness and contrast of the image to be processed are adjusted according to the brightness enhancement mask and the contrast enhancement signal. Compared with the related art, this embodiment divides the original image into different scales according to the resolution, and then determines the brightness enhancement mask and the contrast enhancement signal based on the relevant information of the images of different resolutions to adjust the image to be processed, which can effectively improve the problem that the single-scale image compensation strategy will cause the image to be unnatural.
[0046] It should be noted that the relevant image processing generally includes image sharpening, image smoothing and image contrast enhancement. Image sharpening is to compensate for the contour of the image, enhance the edge and grayscale jump of the image, and make the image clear. It can be specifically divided into two categories: spatial domain processing and frequency domain processing. It can also highlight the edges and contours of the objects on the image, or the characteristics of some linear target elements. This filtering method improves the contrast between the edge of the object and the surrounding pixels, so it is also called edge enhancement. When the image is smoothed, the boundaries and contours in the image often become blurred. In order to reduce the impact of such adverse effects, it is necessary to use image sharpening technology to make the edges of the image clear. In some cases, such as underwater image enhancement processing, in addition to denoising and contrast expansion, it is sometimes necessary to strengthen the edges and contours of the scene in the image. The edges and contours are often located in the place where the grayscale changes suddenly in the image, so it can be intuitively thought of using grayscale differences to extract the edges and contours. Image contrast enhancement is also called image contrast stretching or directly called point operation. Image contrast enhancement changes an image in a predetermined way. Since the contrast of black and white images mainly depends on the grayscale difference of the image, in order to improve the recognition effect of black and white images with too small contrast, it is necessary to expand the grayscale difference of the image. Currently, there are many methods to expand the grayscale difference of images, mainly including linear enhancement method, nonlinear enhancement method and histogram enhancement method, adaptive enhancement method (ACE algorithm) and its various variants.
[0047] One of the purposes of adjusting the image brightness and contrast is to provide the maximum detail information at an appropriate brightness. The deeper the grooves of the detail texture, the clearer the image. In image processing, image contrast enhancement is the most basic, relatively simple in principle but very important type of technology. They can change the grayscale range occupied by image data according to user requirements. The larger the grayscale distribution range, the clearer the image details are presented, and the higher the requirements for image radiation resolution. Therefore, in addition to layering the original image with resolution, this embodiment also pays attention to the adjustment of the brightness and contrast of the image to obtain better image processing effects. It solves the problems in the existing solutions that after image sharpening, the image has black edges at high-contrast edges, the problem of being unable to balance detail enhancement and black edges, resulting in insufficient details and local contrast, and the image is blurred or the edge signal is directly raised to enhance sharpening. The level of over-sharpening of some areas of the image is caused.
[0048] Optionally, the image to be processed is processed to obtain images with different resolutions, including: performing layered processing on the image to be processed according to resolutions by downsampling step by step to obtain images with different resolutions.
[0049] In this embodiment, the actual application scenario and implementation method can obtain images of different resolutions by downsampling step by step. For example, the original resolution image first passes through the first-level downsampling module to obtain ds4 image information, and then obtains ds16 image information through the second-level downsampling module via the ds4 image information, and then uses the ds16 image information to obtain ds64 image information through the third-level downsampling module (for example, three-level processing); wherein the first-level, second-level, and third-level downsampling information can be the same hardware design, or can be a different downsampling design. By dividing the original image into different scales according to resolution, and then processing based on images of different resolutions, the processing result is more natural compared to the related art based only on a single-scale image processing solution.
[0050] Optionally, determining statistical information corresponding to images of different resolutions includes: dividing the image of the first resolution into regions according to a preset ratio to obtain a plurality of intermediate images after division, the image of the first resolution being any image among the images of different resolutions; performing statistical histogram processing on each intermediate image to obtain statistical information corresponding to the image of the first resolution.
[0051] In this embodiment, the image of the first resolution may be one of the above-mentioned ds4, ds16 or ds64. The image is first divided into A*B regions according to a preset ratio, where A and B may be selected according to actual conditions. Then, statistical information corresponding to the image of the first resolution is obtained by statistical histogram processing. By obtaining the statistical information, initial brightness masks corresponding to images of different resolutions may be calculated respectively, thereby obtaining a better image processing effect.
[0052] Optionally, determining contrast information corresponding to images of different resolutions includes: cropping the image of the second resolution according to a preset size, the image of the second resolution being any image of the images of different resolutions; determining a maximum contrast value and a minimum contrast value in the cropped area; and determining contrast differential data of the image of the second resolution according to the maximum contrast value and the minimum contrast value as contrast information corresponding to the image of the second resolution.
[0053] In this embodiment, the process of determining contrast information is described. First, a cropped area, i.e., a window, is obtained by cropping the image, and then a difference calculation is performed through the maximum contrast value and the minimum contrast value in the window to obtain contrast information corresponding to the image of the second resolution. This paves the way for obtaining brightness enhancement masks corresponding to images of different resolutions, and can make the image processing results better.
[0054] Optionally, based on the brightness enhancement mask and the brightness information, the contrast enhancement signals corresponding to the images with different resolutions are determined, including: performing differential processing on the brightness enhancement mask and the brightness information corresponding to the third resolution image to obtain the contrast enhancement signal corresponding to the third resolution image, and the third resolution image is any image among the images with different resolutions.
[0055] In this embodiment, the contrast enhancement signal is obtained by performing differential processing on the brightness enhancement mask and the brightness information. Considering that local contrast enhancement requires not only enhancement in local brightness, but also enhancement in local contrast dimension, it is necessary to better highlight the perception of local details and contrast.
[0056] Optionally, the brightness and contrast of the image to be processed are adjusted according to the brightness enhancement mask and the contrast enhancement signal, including: enhancing the brightness enhancement mask and the contrast enhancement signal through a global detail gain to obtain a brightness addition signal and a contrast addition signal; adjusting the brightness of the image to be processed according to the brightness addition signal, and adjusting the contrast of the image to be processed according to the contrast addition signal.
[0057] In this embodiment, during the process of adjusting the image, the brightness enhancement mask and the contrast enhancement signal can be enhanced by means of the global detail gain to obtain a brightness add-back signal and a contrast add-back signal, and then the contrast of the image to be processed can be adjusted, thereby obtaining a better image processing effect.
[0058] Optionally, a brightness enhancement mask is determined based on contrast information and initial brightness masks corresponding to images of different resolutions, and the method further includes: determining a difference between the initial brightness mask and the brightness information of images of different resolutions; correcting the initial brightness masks corresponding to images of different resolutions according to a correction value corresponding to the difference in a preset association relationship; and determining a brightness enhancement mask based on contrast information corresponding to images of different resolutions and the corrected initial brightness mask.
[0059] In this embodiment, after the initial brightness mask is calculated, the value of the initial brightness mask can also be corrected. Specifically, it may include: controlling the difference between the value of the initial brightness mask and the original brightness to avoid a large gap. This part is mainly completed by calculating the difference between the initial brightness mask and the original brightness signal, and using the difference signal to look up a table to obtain an adjusted difference signal. Then, the smoothness of the initial brightness mask value is controlled by Gaussian filtering. Finally, the brightness enhancement mask is obtained. In the above manner, the value of the initial brightness mask can be made more accurate and smooth.
[0060] Furthermore, in order to better reflect the specific steps of the technical solution proposed in this embodiment, a specific implementation method is given. This embodiment is consistent with the idea of the previous embodiment, but the detailed steps are described in more detail. It includes five parts respectively as follows: Figures 2 to 5 shown.
[0061] In the first part, as Figure 2 As shown, including:
[0062] S201, obtaining brightness information of an original image.
[0063] S202 . Based on the brightness information of the original image, obtain the brightness information of the ds4 image by downsampling.
[0064] S203 . Based on the brightness information of the ds4 image, obtain the brightness information of the ds16 image by downsampling.
[0065] S204 , based on the brightness information of the ds16 image, obtain the brightness information of the ds64 image by downsampling.
[0066] In actual design and implementation, we adopt a step-by-step downsampling method, that is, the ds4 image information is first obtained from the original image through the first-level downsampling module, and then the ds16 image information is obtained through the second-level downsampling module via the ds4 image information, and then the ds16 image information is used to obtain the ds64 image information through the third-level downsampling module; the first-level, second-level and third-level downsampling information can be the same hardware design, or they can be different downsampling designs. In this case, we adopt the same downsampling method; the downsampling ratio can be 2x downsampling, or it can be a non-integer ratio downsampling, such as 1.5x, etc. In this embodiment, 2x downsampling is adopted, that is, ds4 is 1 / 4 of the original resolution, ds16 is 1 / 16 of the original resolution, and ds64 is 1 / 64 of the original resolution.
[0067] In this part, the core processing of this embodiment needs to be processed in the brightness domain, so a conversion needs to be performed, that is, the conversion of the input color signal to the brightness signal needs to be completed. Here we use a general calculation formula to complete it.
[0068] Luma=(R*rgb2luma_lut[0]+G*rgb2luma_lut[1]+B*rgb2luma_lut[2]+512)>>10Formula 1
[0069] It should be noted that rgb2luma_lut = [306 601 116], or rgb2luma_lut = [256512256]; other slightly more complex conversion formulas can also be selectively used here, such as the formula containing max(R,G,B) information. The advantage of such a formula is that it can better identify the maximum value of a single channel in the three channels and provide a better reference for brightness conversion. The disadvantage is that it may introduce some additional calculations and judgments, which will be adopted as appropriate in actual engineering.
[0070] Then enter the downsampling calculation stage. First, confirm the central pixel position of the downsampling point at the original resolution according to the downsampling ratio, and then build a 5*5 window at the central pixel position for filtering and smoothing. The 5*5window Gaussian filter calculation is:
[0071] Get the image 5*5 window area Window_5x5 at each pixel position to be downsampled 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55
[0077] And load the pre-built Gaussian filter kernel Gaussian_kernel5x5:
[0078] {1,4,6,4,1},
[0079] {4,16,24,16,4},
[0080] {6,24,36,24,6},
[0081] {4,16,24,16,4},
[0082] {1,4,6,4,1}
[0083] The convolution operation is used to perform point-by-point multiplication and accumulation, and the filtering result is obtained after normalization based on the kernel accumulation and 256.
[0084] After obtaining the filtering result, perform 2x downsampling. Select the pixel at the jump point position of the original resolution in the following calculation method and perform Gaussian filtering in step 1 to obtain the downsampled data of the target position. In the first part, the original image can be processed to obtain four images of different resolutions: ds4, ds16, and ds64. In addition, in this step, it is also easy to obtain the brightness information of ds4, ds16, and ds64 through successive 2x downsampling. Therefore, Figure 2 In the steps shown, brightness information corresponding to the images with different resolutions is obtained while images with different resolutions are obtained.
[0085] The purpose of the second part is to calculate statistical information and generate initial brightness masks corresponding to images of different resolutions based on the statistical information, such as Figure 3 As shown, including:
[0086] S301. Obtain statistical information of images with different resolutions.
[0087] To calculate the statistical information of images with different resolutions, you need to divide the image into A*B regions first, where A=12 and B=9 are optional, and other values can be selected according to the actual situation. The statistics mainly include the number of pixels pcnt corresponding to the 8 histogram bins of each sub-image in the bilateral grid, the sum of the pixel values in each histogram bin vsum, the number of pixels with pixel values less than the threshold, and the number of pixels with pixel values greater than the threshold. The threshold can be set according to different situations. Among them, each histogram can usually be represented by a column vector, and each value in the column vector is a bin. For example, if the column vector has 50 elements, it means there are 50 bins.
[0088] Then, vsum and pcnt are preprocessed. Here, 101 mirror expansion can be used to expand vsum and pcnt respectively, and then 5*5*11 three-dimensional convolution is used to perform three-dimensional filtering on the expanded statistical information. When implementing, first perform 5*5 two-dimensional convolution in the horizontal and vertical directions; then perform 1*11 convolution on the result of the two-dimensional convolution in the depth dimension. In practice, different filter kernels can be flexibly used for configuration and calculation.
[0089] Next, we will perform 2D filtering and 1D filtering. We will use pseudocode to represent this. Overall, this position filtering is a conventional filtering process. Points in the window and the filter kernel are multiplied point by point and the window is accumulated and normalized. The actual filter kernel is a 5*5 filter kernel, which can be constructed using a Gaussian smoothing method. In the 2D filtering process, the data needs to be expanded, such as expanding the 12*9*8 three-dimensional statistical information to a (12+4)*(9+4)*(8+10) three-dimensional matrix to obtain vsum and pcnt.
[0090] S302: Calculate and obtain an initial brightness mask according to the statistical information.
[0091] The three-dimensional grid information Vgrid is calculated as the quotient of vsum and pcnt. The calculation of the initial brightness mask requires determining the index of the pixel value in Vgrid through Vgrid, the input brightness information, and the specific coordinate position of the pixel in the image. Then, trilinear interpolation is performed on the eight vertices using its period. The interpolation result is the initial brightness mask.
[0092] S303: Correct the initial brightness mask.
[0093] In this step, the initial brightness mask calculated in the previous step is corrected, mainly to control the difference between the value of the initial brightness mask and the initial brightness value, which is specifically completed by looking up the table of the differential signal or by performing Gaussian filtering on the initial brightness mask to ensure its smoothness.
[0094] The purpose of the third part is to obtain the brightness enhancement mask, such as Figure 4 As shown, including:
[0095] S401: Calculate contrast information of images with different resolutions.
[0096] Considering how to effectively fuse the information of each layer, it is necessary to fuse based on the representative information of each layer, and the preferred reference benchmark is the contrast information of each layer.
[0097] First, we get a 5*5 window from the image as the area for contrast calculation.
[0098] Get the image 5*5window area Window_5x5 at each pixel position 11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 41 42 43 44 45 51 52 53 54 55
[0104] It should be noted that when calculating the local contrast signal based on the maximum value in the region, different sizes such as 3*3, 5*5, 7*7, 9*9 can be selected for the local contrast signal based on the maximum value. Different window sizes correspond to different frequency ranges of the original image. For example, a 3*3 window corresponds to higher-frequency signals and finer edges, while a 9*9 window corresponds to lower-frequency signals and coarser edges and textures. In practice, a 9*9 window can be opened by the hardware, and the internal window can be backward compatible with small windows such as 7*7 for more precise control. If the hardware cost is limited, the maximum window size can be reduced to strike a balance between hardware overhead and algorithm effect.
[0105] Here we take 5*5 as an example to illustrate, and then calculate the local maximum value.
[0106] local_max=max(Window_5x5);
[0107] local_min=min(Window_5x5);
[0108] Finally, the difference signal between local_max and local_min in each window is calculated and used as the representation of local contrast. The larger the difference signal, the greater the contrast between pixels in the window area. The formula is:
[0109] Contrast_info=(local_max–local_min);
[0110] Through the above contrast information calculation method and the brightness information of each layer of image, we can obtain the contrast information of each layer.
[0111] S402: Generate inter-layer mask fusion information based on contrast information of images with different resolutions.
[0112] In this step, the contrast information of each layer and the preset parameters are used to generate the fusion weights between the current layer Mask_current_layer and the low-resolution layer Mask_lower_layer. Here, we mainly consider weighted averages of different intensities on LTM masks of different scales. The principle is as follows: if the contrast value is large, less information of the Lower_layer layer is used, and more Mask_current_layer is used, and w in the corresponding formula is reduced; if the contrast is small, more Mask_lower_layer is used, and less Mask_current_layer is used, and w in the corresponding formula is increased;
[0113] In actual engineering, we can set several nodes on the parameter lookup table, such as bw0, bw1, and bw2. The horizontal coordinate of each node corresponds to the contrast information, and the vertical coordinate corresponds to the output weight w information. Linear interpolation is used between the nodes to obtain the corresponding weights. This makes it easier for us to debug. We only need to adjust the position of bw0 / bw1 / bw2 to adjust the low contrast, medium contrast, and high contrast position ranges and the weight size.
[0114] In practice, we adjust the contrast by adjusting bw0, bw1, and bw2, so that positions with large contrast can achieve better resolution levels, while positions with small contrast can have a smoother effect.
[0115] S403: Generate brightness enhancement masks corresponding to images with different resolutions.
[0116] The calculation formula is:
[0117] Current_layer_fusion=Mask_lower_layer_us*Fusion_weight+Mask_current_layer*(1-Fusion_weight) Formula 2
[0118] Wherein Mask_current_layer is the brightness enhancement mask of the current layer, and Mask_lower_layer_us is the brightness enhancement mask of the corresponding next layer (low resolution) after upsampling, such as 2 times upsampling calculation in this embodiment. There are many options for upsampling calculation. In this implementation, bilinear interpolation is used to complete it. If you want to obtain a better upsampling reconstruction effect, you can also use bicubic interpolation or other high-precision upsampling algorithms.
[0119] The purpose of the fourth part is to generate contrast enhancement signals of images of different resolutions based on the difference signal between the brightness information and the brightness enhancement mask. In this part, the detail signal Detail of each layer is obtained according to the difference calculation form. The difference calculation formula is:
[0120] Detail = Luma-Mask, where Luma is the brightness information of each layer, and Mask is the initial brightness mask of each layer. Specifically, each layer needs to be discussed separately. For example, after downsampling, the layer needs to be upsampled step by step and then differentiated at the original resolution to obtain a contrast enhancement signal. For the original resolution layer, the contrast enhancement signal can be obtained by direct differentiation:
[0121] Detail_full=Luma_full-Mask_full_fusion
[0122] For the ds4 layer, you need to first upsample the 1 / 4 resolution brightness signal and the 1 / 4 resolution mask signal, obtain the Luma_ds4_us and Mask_ds4_fusion_us signals, and perform the difference to obtain the contrast enhancement signal at the original resolution:
[0123] Detail_ds4=Luma_ds4_us-Mask_ds4_fusion_us
[0124] For the ds16 layer, as with the ds4 layer, you need to first upsample Luma_ds16 by 2x twice (or upsample by 4x once) to obtain Luma_ds16_us of the original resolution, and then upsample Mask_ds16_fusion by 2x twice (or upsample by 4x once) to obtain Mask_ds16_us of the original resolution to obtain the contrast enhancement signal at the original resolution:
[0125] Detail_ds16=Luma_ds16_us-Mask_ds16_fusion_us
[0126] For the ds64 layer, as with the ds16 layer, you need to first upsample Luma_ds16 by 2x three times (or upsample by 8x once) to obtain Luma_ds64_us of the original resolution, and then upsample Mask_ds64_fusion by 2x three times (or upsample by 8x once) to obtain Mask_ds64_us of the original resolution to obtain the contrast enhancement signal at the original resolution:
[0127] Detail_ds64=Luma_ds64_us-Mask_ds64_fusion_us.
[0128] It should be noted that this part is actually the difference between the luminance signal output by ltm and the luminance signal input, which contains low-frequency signals. Based on this, Detail_full is used to subtract the differential signals of each layer to obtain the high-frequency differential signals of each layer. Before this step, the signals of each layer need to be upsampled. Therefore, we have the following corrections for ds4 / ds16 / ds64:
[0129] Detail_ds4=Detail_ds4-Detail_full;
[0130] Detail_ds16=Detail_ds16-Detail_full;
[0131] Detail_ds64=Detail_ds64-Detail_full.
[0132] Furthermore, it is necessary to adjust the intensity of the added-back signal of each scale segment and perform overall detail enhancement through the global detail gain, so as to obtain the brightness added-back signal and the contrast added-back signal enhanced by the detail gain.
[0133] In the last fifth part, based on the fused brightness enhancement signal Mask_full_fusion and detail enhancement signal Detail_full / Detail_ds4 / Detail_16 / Detail_ds64, we can perform the final brightness enhancement and detail enhancement back-adding operations. Figure 5 As shown, including:
[0134] S501: Obtain a brightness add-back signal and a contrast add-back signal.
[0135] S502: Adjust the brightness of the original image according to the brightness feedback signal.
[0136] In the brightness enhancement part, we need to calculate the brightness enhancement ratio of each pixel, and then apply the brightness enhancement ratio to the input RGB data; the brightness enhancement ratio is used to describe the ratio relationship between the brightness signal Mask_full_fusion after a series of brightness adjustments and multi-scale fusion and the original RGB-to-brightness signal Luma_full, which can describe the degree to which each pixel is enhanced or compressed in brightness. The calculation of Ratio is:
[0137] Ratio=Mask_full_fusion / Luma_full
[0138] The application of brightness enhancement is on RGB. We obtain the signal after local brightness adjustment by applying Ratio to the three channels of R / G / B:
[0139] R_boost=R*Ratio
[0140] G_boost=G*Ratio
[0141] B_boost=B*Ratio
[0142] To avoid excessive gain, you can increase the signal strength control Str_ctl
[0143] R_out=R+(R_boost-R)*Str_ctl
[0144] G_out=G+(G_boost-G)*Str_ctl
[0145] B_out=B+(B_boost-B)*Str_ctl
[0146] S503: Adjust the contrast of the original image according to the contrast-added-back signal.
[0147] In the contrast enhancement part, we need to perform controlled back-addition based on the local contrast information calculated in the previous step 4, and adjust the strength of each multi-scale back-addition signal. Here we use the global detail gain details_boost_ratio, details_boost_ratio_ds4, details_boost_ratio_ds16, details_boost_ratio_ds64 to perform overall detail enhancement. The brightness-based lookup table is used to make differential adjustments based on different positive and negative edges and brightness. For example, for the positive edges in Details of each scale, use the A parameter for adjustment, and for the negative edges in each scale, use the B parameter for adjustment.
[0148] Through the scheme in the above embodiment, the image is divided into different scales according to the resolution, and then the corresponding brightness enhancement mask and contrast enhancement signal are determined to adjust the image to be processed, effectively improving the problem that the single-scale image compensation strategy will cause the image to be unnatural. According to the actual use results, this embodiment has a significant effect on the black edge suppression effect, and significantly improves the problem of black edge-type image quality errors; for the texture area, it is also well protected and effectively enhanced. It solves the problem that in the existing solution, after the image is sharpened, the image has black edges at the high-contrast edges, the problem of being unable to balance detail enhancement and black edges, resulting in insufficient details and local contrast, and the image is blurred or the edge signal is directly raised to enhance sharpening. The level of over-sharpening in some areas of the image is caused.
[0149] Further, as Figures 1 to 5 The specific implementation of the method shown in the embodiment provides an image processing device, such as Figure 6 As shown, the device includes: a processing unit 61, a calculation unit 62, a generation unit 63, a fusion unit 64, a difference unit 65, and an adjustment unit 66.
[0150] A processing unit 61 is configured to process the image to be processed to obtain images with different resolutions;
[0151] A calculation unit 62, configured to determine statistical information, contrast information and brightness information respectively corresponding to the images with different resolutions;
[0152] A generating unit 63 is configured to generate initial brightness masks corresponding to the images with different resolutions respectively based on the statistical information;
[0153] A fusion unit 64 is configured to determine a brightness enhancement mask according to the contrast information and the initial brightness mask respectively corresponding to the images with different resolutions;
[0154] The difference unit 65 is configured to determine the contrast enhancement signals corresponding to the images of different resolutions respectively according to the brightness enhancement mask and the brightness information;
[0155] The adjustment unit 66 is configured to adjust the brightness and contrast of the image to be processed according to the brightness enhancement mask and the contrast enhancement signal.
[0156] In a specific application scenario, the processing unit 61 is specifically configured to perform layered processing on the image to be processed according to resolution by downsampling step by step to obtain images with different resolutions.
[0157] In a specific application scenario, the computing unit 62 is further configured to divide the image of the first resolution into regions according to a preset ratio to obtain a number of intermediate images after division, where the image of the first resolution is any image among the images of different resolutions; and perform statistical histogram processing on each of the intermediate images to obtain statistical information corresponding to the image of the first resolution.
[0158] In a specific application scenario, the computing unit 62 is further configured to crop the image of the second resolution according to a preset size, where the image of the second resolution is any image of the images of different resolutions; determine the maximum contrast value and the minimum contrast value in the cropped area; and determine the contrast differential data of the image of the second resolution according to the maximum contrast value and the minimum contrast value as the contrast information corresponding to the image of the second resolution.
[0159] In a specific application scenario, the differential unit 65 is specifically configured to perform differential processing on the brightness enhancement mask and the brightness information corresponding to the third resolution image to obtain a contrast enhancement signal corresponding to the third resolution image, and the third resolution image is any one of the images with different resolutions.
[0160] In a specific application scenario, the adjustment unit 66 is further configured to enhance the brightness enhancement mask and the contrast enhancement signal through a global detail gain to obtain a brightness add-back signal and a contrast add-back signal; adjust the brightness of the image to be processed according to the brightness add-back signal, and adjust the contrast of the image to be processed according to the contrast add-back signal.
[0161] In a specific application scenario, the fusion unit 64 is further configured to determine the difference between the initial brightness mask and the brightness information of the images with different resolutions; correct the initial brightness masks corresponding to the images with different resolutions according to the correction value corresponding to the difference in the preset association relationship; determine the brightness enhancement mask according to the contrast information corresponding to the images with different resolutions and the corrected initial brightness mask.
[0162] It should be noted that for other corresponding descriptions of the functional units involved in the image processing device provided in this embodiment, reference can be made to Figures 1 to 5 The corresponding description in will not be repeated here.
[0163] Based on the above Figures 1 to 5 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figures 1 to 5 The method shown.
[0164] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0165] Based on the above Figures 1 to 5 The method shown, and Figure 6 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, which can be configured on a computer terminal, etc. The device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figures 1 to 5 The method shown.
[0166] Based on the above Figures 1 to 5 The method shown, and Figure 6 In order to achieve the above-mentioned purpose, the embodiment of the virtual device shown in the embodiment of the present application further provides a chip, including one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from the memory of the electronic device and send the signal to the processor, the signal including the computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the above-mentioned Figures 1 to 5 The method shown.
[0167] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0168] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0169] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0170] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the solution of this embodiment, compared with the related art, the present application divides the original image into different scales according to resolution, and then determines the brightness enhancement mask and contrast enhancement signal based on the relevant information of the images of different resolutions to adjust the image to be processed, which can effectively improve the problem that the single-scale image compensation strategy will cause the image to be unnatural.
[0171] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0172] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. An image processing method, characterized in that: include: Process the image to be processed to obtain images with different resolutions; Determine statistical information, contrast information, and brightness information respectively corresponding to the images with different resolutions; Based on the statistical information, generating initial brightness masks corresponding to the images with different resolutions respectively; Determining a brightness enhancement mask according to the contrast information and the initial brightness mask respectively corresponding to the images with different resolutions; Determining, according to the brightness enhancement mask and the brightness information, contrast enhancement signals corresponding to the images with different resolutions respectively; The brightness and contrast of the image to be processed are adjusted according to the brightness enhancement mask and the contrast enhancement signal.
2. The method according to claim 1, characterized in that The image to be processed is processed to obtain images of different resolutions, including: The image to be processed is processed in layers according to resolution through a step-by-step downsampling method to obtain images with different resolutions.
3. The method according to claim 1, characterized in that Determining statistical information corresponding to the images of different resolutions, respectively, includes: Divide the image of the first resolution into regions according to a preset ratio to obtain a plurality of intermediate images after division, wherein the image of the first resolution is any image among the images of different resolutions; Perform statistical histogram processing on each of the intermediate images to obtain statistical information corresponding to the image of the first resolution.
4. The method according to claim 1, characterized in that: Determining the contrast information corresponding to the images with different resolutions respectively includes: Cropping the image with a second resolution according to a preset size, where the image with the second resolution is any one of the images with different resolutions; Determine the maximum contrast value and the minimum contrast value in the cropped area; Contrast difference data of the image with the second resolution is determined according to the maximum contrast value and the minimum contrast value as contrast information corresponding to the image with the second resolution.
5. The method according to claim 1, characterized in that The step of determining, according to the brightness enhancement mask and the brightness information, the contrast enhancement signals corresponding to the images with different resolutions respectively comprises: The brightness enhancement mask and the brightness information corresponding to the third resolution image are differentially processed to obtain a contrast enhancement signal corresponding to the third resolution image, where the third resolution image is any one of the images with different resolutions.
6. The method according to claim 1, characterized in that According to the brightness enhancement mask and the contrast enhancement signal, the brightness and contrast of the image to be processed are adjusted, including: The brightness enhancement mask and the contrast enhancement signal are enhanced by global detail gain to obtain a brightness add-back signal and a contrast add-back signal; The brightness of the image to be processed is adjusted according to the brightness return signal, and the contrast of the image to be processed is adjusted according to the contrast return signal.
7. The method according to any one of claims 1 to 6, characterized in that Determining a brightness enhancement mask according to the contrast information and the initial brightness mask respectively corresponding to the images with different resolutions, the method further comprising: Determine a difference between the initial brightness mask and the brightness information of the images with different resolutions; Correcting the initial brightness masks respectively corresponding to the images with different resolutions according to the correction values corresponding to the difference values in the preset association relationship; The brightness enhancement mask is determined according to the contrast information respectively corresponding to the images with different resolutions and the corrected initial brightness mask.
8. An image processing device, characterized in that: include: A processing unit is configured to process the image to be processed to obtain images with different resolutions; A calculation unit, configured to determine statistical information, contrast information and brightness information respectively corresponding to the images with different resolutions; A generating unit, configured to generate initial brightness masks corresponding to the images of different resolutions respectively based on the statistical information; a fusion unit configured to determine a brightness enhancement mask according to the contrast information and the initial brightness mask respectively corresponding to the images with different resolutions; A difference unit, configured to determine contrast enhancement signals corresponding to the images of different resolutions respectively according to the brightness enhancement mask and the brightness information; The adjustment unit is configured to adjust the brightness and contrast of the image to be processed according to the brightness enhancement mask and the contrast enhancement signal.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
11. A chip, characterized in that: The invention comprises one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from a memory of an electronic device and send the signal to the processor, wherein the signal includes a computer instruction stored in the memory; when the processor executes the computer instruction, the electronic device executes the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
System and method for automatically enhancing underwater images in NSCT (non-subsampled contourlet transform) regions on basis of human visual characteristics
CN104504664A
Image enhancement method and device, mobile equipment and computer readable storage medium
CN110766639A
Image enhancement algorithm for carrying out adaptive gain modulation based on local brightness
CN112396563A
Frame structure for switchboard
KR1020230009586A
Method for generating a super-resolution image and related device
WO2020191475A1
