Image processing method and device, electronic equipment, storage medium and product
By acquiring grayscale images and calculating linear mapping relationships, a tone mapping method is used to solve the problems of low image quality and RGB component color cast in traditional tone mapping techniques, thus achieving high-quality image compression.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XIAN OPPO COMM TECH CORP LTD
- Filing Date
- 2022-07-27
- Publication Date
- 2026-07-14
Smart Images

Figure CN115205168B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image processing method, apparatus, electronic device, storage medium, and product. Background Technology
[0002] With the rapid development of computer technology, camera imaging technology has also advanced rapidly. Image sensors in cameras can now capture images of nature more realistically, generating High Dynamic Range (HDR) images. While HDR images can more realistically reflect real-world scenes, for the same image size, HDR images have a larger data volume compared to ordinary LDR images. Because of this larger data volume, HDR images often encounter situations where real-world usage scenarios cannot support them during storage, transmission, and display. In such cases, tone mapping technology can be used to compress the HDR image from its high dynamic range to a dynamic range suitable for the actual usage scenario.
[0003] However, using traditional tone mapping techniques to compress HDR images into LDR images results in LDR images with lower image quality. Summary of the Invention
[0004] This application provides an image processing method, apparatus, electronic device, and computer-readable storage medium that can improve the image quality of images generated after tone mapping.
[0005] On the one hand, an image processing method is provided, the method comprising:
[0006] Obtain the grayscale image of the original image;
[0007] Perform tone mapping on the grayscale image to generate the tone mapping result of the grayscale image;
[0008] Calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and perform tone mapping on the original image according to the linear mapping relationship to generate the tone mapping result of the original image.
[0009] On the other hand, an image processing apparatus is provided, the apparatus comprising:
[0010] The acquisition module is used to acquire the grayscale image of the original image;
[0011] The first tone mapping module is used to perform tone mapping on the grayscale image to generate the tone mapping result of the grayscale image;
[0012] The second tone mapping module is used to calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and to perform tone mapping on the original image according to the linear mapping relationship to generate the tone mapping result of the original image.
[0013] On the other hand, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the image processing method described above.
[0014] On the other hand, a computer-readable storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the steps of the image processing method described above.
[0015] On the other hand, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the image processing method as described above.
[0016] The aforementioned image processing method, apparatus, electronic device, storage medium, and product acquire a grayscale image of the original image, perform tone mapping on the grayscale image, and generate a tone mapping result for the grayscale image. A linear mapping relationship between the tone mapping result and the grayscale image is calculated, and the original image is tone-mapped based on this linear mapping relationship to generate a tone mapping result for the original image. Since a grayscale image is a single-channel image, the tone mapping process only requires tone mapping of the single-channel pixel values. Therefore, a linear mapping relationship exists between the tone mapping result and the grayscale image. This linear mapping relationship is then calculated. Finally, the original image is tone-mapped based on this linear mapping relationship, thus achieving a linear transformation during the tone mapping process on the original image.
[0017] Traditional methods directly perform tone mapping on the original image, that is, tone mapping on each of the RGB components of the original image separately. This obviously alters the relationship between the RGB components, causing color cast and degrading image quality. However, in this embodiment, a linear transformation is implemented during tone mapping of the original image. Since a linear transformation preserves the relationship between the RGB components of the original image during tone mapping, it better retains the color information in the original image. Therefore, the color cast problem during tone mapping of the original image is avoided, thereby improving the image quality of the tone-mapped result of the generated original image. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is an application environment diagram of an image processing method in one embodiment;
[0020] Figure 2 This is a flowchart of an image processing method in one embodiment;
[0021] Figure 3 for Figure 2 The flowchart shows a method for performing tone mapping on a grayscale image to generate the tone mapping result of the grayscale image.
[0022] Figure 4 This is a flowchart of a method for converting a high-bit RGB image to a low-bit RGB image in one embodiment;
[0023] Figure 5 A flowchart of an image processing method in another embodiment;
[0024] Figure 6 Here is a flowchart of an image processing method in another embodiment;
[0025] Figure 7 This is a flowchart of a method for global tone mapping of a human portrait region in one embodiment;
[0026] Figure 8 This is a schematic diagram illustrating the global tone mapping of the human image region in a 3D LUT image in one embodiment, generating the final tone mapping result of the original image;
[0027] Figure 9 This is a schematic diagram of a human face region mask in one embodiment;
[0028] Figure 10 This is a schematic diagram of an image processing method in a specific embodiment;
[0029] Figure 11 This is a structural block diagram of an image processing device in one embodiment;
[0030] Figure 12 for Figure 11 Structural block diagram of the first tone mapping module;
[0031] Figure 13 This is a structural block diagram of an image processing apparatus in another embodiment;
[0032] Figure 14 This is a schematic diagram of the internal structure of an electronic device in one embodiment. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0034] It is understood that the terms "first," "second," etc., used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of this application, a first tone mapping module may be referred to as a second tone mapping module, and similarly, a second tone mapping module may be referred to as a first tone mapping module. Both the first tone mapping module and the second tone mapping module are tone mapping modules, but they are not the same tone mapping module.
[0035] Figure 1 This is a schematic diagram illustrating the application environment of an image processing method in one embodiment. For example... Figure 1 As shown, the application environment includes an electronic device 120. The electronic device 120 can acquire a grayscale image of the original image; perform tone mapping on the grayscale image to generate a tone mapping result; calculate the linear mapping relationship between the tone mapping result and the grayscale image; and perform tone mapping on the original image based on the linear mapping relationship to generate a tone mapping result for the original image. The electronic device 120 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc.
[0036] Figure 2 This is a flowchart of an image processing method in one embodiment. The image processing method in this embodiment is designed to run on... Figure 1 The description will be based on an example of an electronic device. Figure 2 As shown, the image processing method includes steps 220 to 260, wherein,
[0037] Step 220: Obtain the grayscale image of the original image.
[0038] Here, the electronic device can capture the original image using a camera and then convert the original image into a grayscale image. Alternatively, the electronic device can directly acquire a grayscale image of the original image; this application does not limit this. The electronic device can acquire a single frame of the original image in grayscale, or it can acquire multiple frames of the original image in grayscale, and then process each frame separately. Furthermore, the original image can be a high dynamic range image (HDR image) or other high-quality image; that is, generally, the original image contains a large amount of data.
[0039] The original image here can be an RGB three-channel image (hereinafter referred to as an RGB image) or an RGBW four-channel image (hereinafter referred to as an RGBW image), and this application does not limit it. The RGB three-channel image includes the R channel (red channel), G channel (green channel), and B channel (blue channel), meaning the original image includes red pixels (R pixels), green pixels (G pixels), and blue pixels (B pixels). The RGBW four-channel image includes the R channel (red channel), G channel (green channel), B channel (blue channel), and W channel (white channel), meaning the original image includes red pixels (R pixels), green pixels (G pixels), blue pixels (B pixels), and all-color pixels (or W pixels).
[0040] Assuming the original image is an RGB image, methods such as averaging or weighted averaging can be used to convert the original image to a grayscale image; this application does not limit the specific methods used. The bit width of the resulting grayscale image is the same as that of the original image.
[0041] The averaging method refers to averaging the RGB values of the same pixel to obtain its grayscale value. For example, the formula for the averaging method is shown below:
[0042] Gray[i]=(R[i]+B[i]+G[i]) / 3 Formula (1-1)
[0043] Here, R[i], G[i], and B[i] are the values of the R, G, and B channels of pixel i located at (x, y) in the original image, respectively, and Gray[i] represents the converted grayscale value corresponding to pixel i. Then, Gray[i] is right-shifted to obtain a smaller grayscale value, Gray_Y. For example, if the original image is a 10-bit image, assuming Gray_Y = Gray[i] >> 2, this means that right-shifting Gray[i] by 2 bits yields a grayscale value Gray_Y with a bit width of 8. In other words, the 10-bit original image is converted into an 8-bit grayscale image.
[0044] The weighted average method refers to the method of obtaining the grayscale value of a pixel by weighting the values of its RGB channels. For example, the formula for the weighted average method is shown below:
[0045] Gray[i]=0.3×R[i]+0.59×G[i]+0.11×B[i] Formula (1-2)
[0046] Step 240: Perform tone mapping on the grayscale image to generate the tone mapping result of the grayscale image.
[0047] After acquiring a grayscale image of the original image, an electronic device can perform tone mapping on that grayscale image to generate a tone-mapped result. Tone mapping refers to the technique of compressing an HDR image from its high dynamic range to a dynamic range suitable for the actual usage scenario. Specifically, it involves mapping the chroma, luminance, and dynamic range of the HDR image to the range of the LDR image.
[0048] In the process of tone mapping a grayscale image to generate the tone-mapped result, global tone mapping, local tone mapping, or a combination of both can be used. The order in which these techniques are applied is not specified in this application. Since a grayscale image contains the grayscale values of each pixel, and these values are calculated based on the RGB components of each pixel in the original image, tone mapping a grayscale image involves tone mapping the grayscale values of each pixel. Because tone mapping of a grayscale image involves mapping the grayscale values of each pixel individually, rather than separately mapping the RGB components, the tone mapping process is a linear transformation.
[0049] Step 260: Calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and perform tone mapping on the original image according to the linear mapping relationship to generate the tone mapping result of the original image.
[0050] After obtaining the tone mapping result of a grayscale image, the electronic device can perform tone mapping on the original image based on the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and generate the tone mapping result of the original image.
[0051] Specifically, based on the tone mapping result of a grayscale image and the grayscale image itself, a linear mapping relationship can be calculated between the two. Since a grayscale image is a single-channel image, the tone mapping process only requires toning the single-channel pixel values. Therefore, a linear mapping relationship exists between the tone mapping result and the grayscale image. This linear mapping relationship is then calculated and applied to the original image to generate the tone mapping result of the original image. In this way, a linear transformation can be achieved during the tone mapping process on the original image. Performing a linear transformation ensures that the relationship between the RGB components in the original image is not changed during tone mapping, better preserving the color information in the original image. This avoids the color cast problem that may occur during tone mapping of the original image.
[0052] In this embodiment, a grayscale image of the original image is obtained, and tone mapping is performed on the grayscale image to generate a tone-mapped result of the grayscale image. A linear mapping relationship between the tone-mapped result of the grayscale image and the grayscale image is calculated. Based on this linear mapping relationship, tone mapping is performed on the original image to generate a tone-mapped result of the original image. Since a grayscale image is a single-channel image, the tone mapping process only requires tone mapping of the single-channel pixel values. Therefore, a linear mapping relationship exists between the tone-mapped result of the grayscale image and the grayscale image. This linear mapping relationship is then calculated. By performing tone mapping on the original image based on this linear mapping relationship, a linear transformation is achieved during the tone mapping process on the original image.
[0053] Traditional methods directly perform tone mapping on the original image, that is, tone mapping on each of the RGB components of the original image separately. This obviously alters the relationship between the RGB components, causing color cast and degrading image quality. However, in this embodiment, a linear transformation is implemented during tone mapping of the original image. Since a linear transformation preserves the relationship between the RGB components of the original image during tone mapping, it better retains the color information in the original image. Therefore, the color cast problem during tone mapping of the original image is avoided, thereby improving the image quality of the tone-mapped result of the generated original image.
[0054] In the previous embodiment, an image processing method was described, which involves acquiring a grayscale image of the original image, performing tone mapping on the grayscale image to generate a tone mapping result for the grayscale image, calculating the linear mapping relationship between the tone mapping result and the grayscale image, and then performing tone mapping on the original image based on the linear mapping relationship to generate a tone mapping result for the original image. In this embodiment, as... Figure 3 As shown, step 240 is described in detail, which involves tone mapping of the grayscale image to generate the tone mapping result of the grayscale image, including:
[0055] Step 242: Perform global tone mapping on the grayscale image to generate the global tone mapping result of the grayscale image.
[0056] After acquiring the grayscale image of the original image, global tone mapping is performed on the grayscale image to generate the global tone mapping result. Global tone mapping refers to processing all pixels in the high dynamic range image using the same mapping function, thus mapping the high dynamic range image to a low dynamic range image. Because global tone mapping processes all pixels in the high dynamic range image using the same mapping function, the computational cost is relatively small.
[0057] Specifically, the following formula is used for global tone mapping:
[0058]
[0059] Where In[i] represents the grayscale value of each pixel in the grayscale image, and Out[i] represents the grayscale value of each pixel in the grayscale image after global tone mapping; max In is the largest gray value in a grayscale image. min τ is the minimum gray value in the grayscale image, and τ is an adjustment parameter that can be obtained experimentally.
[0060] The global tone mapping result of the grayscale image is generated based on the grayscale values output by each pixel in the grayscale image after global tone mapping.
[0061] Step 244: Perform local tone mapping on the global tone mapping result of the grayscale image to generate the local tone mapping result of the grayscale image, and use the local tone mapping result of the grayscale image as the tone mapping result of the grayscale image.
[0062] Local tonemapping is performed on the global tone mapping result of a grayscale image to generate a locally tone-mapped result. Local tonemapping refers to the process of mapping a high dynamic range (HDR) image to a low dynamic range (LVR) image by referencing the pixel values of surrounding pixels when performing tone mapping on each pixel in the HDR image. Therefore, performing local tonemapping on a HDR image not only improves image contrast but also better processes image details, thereby increasing image detail information.
[0063] Finally, the local tone mapping result of the grayscale image is used as the tone mapping result of the grayscale image.
[0064] In this embodiment, when performing tone mapping on a grayscale image to generate the tone mapping result, global tone mapping is first performed on the grayscale image, followed by local tone mapping on the global tone mapping result; finally, the local tone mapping result is used as the tone mapping result of the grayscale image. In this way, the resulting tone mapping result of the grayscale image can combine the advantages of lower computational cost of global tone mapping with the detailed processing effect of local tone mapping.
[0065] In the previous embodiment, the process of performing global tone mapping on a grayscale image and then performing local tone mapping on the global tone mapping result was described. In this embodiment, step 244, performing local tone mapping on the global tone mapping result of the grayscale image to generate a local tone mapping result, is described in detail, including:
[0066] The global tone mapping result of the grayscale image is divided into blocks to generate multiple grayscale image blocks;
[0067] Histogram equalization is used to perform local tone mapping on each grayscale image block, generating the local tone mapping result of the grayscale image.
[0068] Specifically, in the process of performing local tone mapping on the global tone mapping result of a grayscale image, the spatial characteristics of the image need to be considered. That is, for two pixels with the same gray value but located in different spatial positions, since the gray values of the surrounding pixels may be different, these two pixels will be mapped to different pixel values during local tone mapping.
[0069] During local tone mapping, due to the introduction of the spatial characteristics of the image, the global tone mapping result of the grayscale image can be divided into blocks to generate multiple grayscale image blocks. Specifically, the global tone mapping result of the grayscale image can be divided into multiple overlapping or non-overlapping grayscale image blocks, and then histogram equalization can be used to perform local tone mapping on each grayscale image block, that is, histogram equalization is performed independently on each grayscale image block.
[0070] When performing local tone mapping on each grayscale image block using histogram equalization, for each grayscale image block, firstly, the grayscale values of the block are statistically analyzed to generate a corresponding grayscale histogram. Secondly, the grayscale image block is optimized based on the grayscale value distribution characteristics of the histogram to make its grayscale histogram tend to be uniformly distributed. Finally, the uniformly distributed grayscale histogram is converted into grayscale image blocks, and the local tone mapping result of the grayscale image is obtained based on all grayscale image blocks.
[0071] Combination Figure 4 As shown, assuming the input original image is a high-bit RGB image, it is first converted to a grayscale image. Specifically, this is achieved by calculating the grayscale value of each pixel in the high-bit RGB image. Next, based on formula (1-3), i.e., the Global Tonemapping formula, global tone mapping is performed on the grayscale image to generate the global tone mapping result (referred to as the Global Tonemapping grayscale image). Then, the global tone mapping result (Global Tonemapping grayscale image) is divided into blocks, generating multiple grayscale image blocks. Histogram equalization is then used to perform local tone mapping on each grayscale image block, generating the local tone mapping result (referred to as the Local Tonemapping grayscale image).
[0072] Finally, the pixel value of each pixel in the tone mapping result of the grayscale image is divided by the pixel value of the corresponding position in the grayscale image to obtain the tone mapping mask. Based on the tone mapping mask, the RGB components (each RGB channel value) in the original image are tone mapped to generate a low-bit RGB image of the tone mapping result of the original image.
[0073] In this embodiment, the global tone mapping result of the grayscale image is first divided into blocks to generate multiple grayscale image blocks. Then, histogram equalization is used to independently perform local tone mapping on each grayscale image block, generating multiple grayscale image blocks after local tone mapping processing. Finally, the local tone mapping result of the grayscale image is obtained based on all the grayscale image blocks after local tone mapping processing. Performing histogram equalization processing independently on each grayscale image block can enhance the contrast of the image and make the local tone mapping result of the grayscale image clearer.
[0074] In the previous embodiment, how to perform local tone mapping on the global tone mapping result of a grayscale image was described. In this embodiment, step 260 is detailed, which involves calculating the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image itself, and performing tone mapping on the original image based on the linear mapping relationship to generate the tone mapping result of the original image, including:
[0075] Calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and generate a tone mapping mask;
[0076] The original image is tone-mapped based on the tone-mapping mask to generate the tone-mapping result of the original image.
[0077] Specifically, based on the tone mapping result of a grayscale image and the grayscale image itself, a linear mapping relationship between the two can be derived. This tone mapping relationship can be represented in the form of a tone mapping mask. The tone mapping mask includes floating-point data, such as high-precision floating-point data. The tone mapping mask can be used to tone map the original image, generating the tone mapping result of the original image. Since the grayscale image has a smaller data volume compared to the original image, the amount of data processed in the process of tone mapping the grayscale image to generate the tone mapping result is also smaller, resulting in higher processing efficiency. Furthermore, calculating the linear mapping relationship between the tone mapping result and the grayscale image, and generating the tone mapping mask, requires less data and can generate the tone mapping mask more quickly. This facilitates subsequent tone mapping of the original image based on the tone mapping mask, generating the tone mapping result of the original image.
[0078] The tone mapping mask includes floating-point data. When performing tone mapping on the original image based on the tone mapping mask, the floating-point data corresponding to a certain position in the tone mapping mask is multiplied by the pixel value of the pixel at the same position in the original image, generating a new pixel value. Based on these new pixel values, the tone mapping result of the original image is generated. Clearly, during the tone mapping process, the RGB components of pixels at the same position in the original image are multiplied by the same floating-point data. This is equivalent to performing a linear transformation on the original image, thus preserving the relationship between the RGB components and better retaining the color information in the original image (RGB image).
[0079] In this embodiment, since tone mapping of a grayscale image is a linear transformation, the linear mapping relationship between the tone mapping result and the grayscale image is calculated, and the generated tone mapping mask also reflects this linear mapping relationship. Then, the tone mapping mask is applied to the original image (RGB image) to perform tone mapping, generating the tone mapping result of the original image (RGB image). In this way, a linear transformation can be achieved during tone mapping of the original image (RGB image). Performing a linear transformation ensures that the relationship between the RGB components in the original image is not altered during tone mapping, better preserving the color information in the original image (RGB image). This avoids the color cast problem that occurs during tone mapping of the original image (RGB image).
[0080] In the previous embodiment, the process of toning the original image based on the tone mapping mask to generate the tone mapping result of the original image was described. In this embodiment, step 264, which calculates the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image to generate the tone mapping mask, includes:
[0081] Divide the pixel value of each pixel in the tone mapping result of the grayscale image by the pixel value of the corresponding pixel in the grayscale image to generate the gain value corresponding to each pixel in the grayscale image.
[0082] A tone mapping mask is generated based on the gain value corresponding to each pixel in the grayscale image.
[0083] Specifically, when calculating the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image to generate the tone mapping mask, firstly, the pixel value of each pixel in the tone mapping result of the grayscale image is divided by the pixel value of the corresponding pixel in the grayscale image to obtain the floating-point data corresponding to that pixel. This floating-point data is the gain value corresponding to each pixel in the grayscale image. Using the gain value corresponding to each pixel in the grayscale image, the pixel value of each pixel in the original image can be adjusted, thus achieving tone mapping of the original image. This floating-point data can be high-precision floating-point data, such as 1, 0.99999, 1.34556, etc., which is not limited in this application. Then, based on the gain value corresponding to each pixel in the grayscale image, the tone mapping mask can be generated. Here, the tone mapping mask can be a two-dimensional matrix composed of floating-point data.
[0084] In this embodiment, since tone mapping of a grayscale image is a linear transformation, the pixel value of each pixel in the tone mapping result of the grayscale image is divided by the pixel value of the corresponding pixel in the grayscale image to generate the gain value corresponding to each pixel in the grayscale image. Therefore, the generated tone mapping mask also reflects the linear mapping relationship. Finally, the tone mapping mask is applied to the original image (RGB image) to perform tone mapping, generating the tone mapping result of the original image (RGB image). In this way, a linear transformation can be achieved during tone mapping of the original image (RGB image). Performing a linear transformation ensures that the relationship between the RGB components in the original image is not changed during tone mapping, better preserving the color information in the original image (RGB image). This avoids the color cast problem that occurs during tone mapping of the original image (RGB image).
[0085] In the previous embodiment, the process of calculating the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and generating a tone mapping mask, was described. In this embodiment, step 264 is described in detail, which involves tone mapping the original image based on the tone mapping mask to generate the tone mapping result of the original image, including:
[0086] Based on the gain value corresponding to each pixel in the tone mapping mask, the gain of the original image is adjusted to generate the gain adjustment result of the original image;
[0087] The gain adjustment result of the original image is shifted to generate the tone mapping result of the original image; wherein the bit width of the original image is greater than the preset bit width threshold, and the bit width of the tone mapping result of the original image is less than or equal to the preset bit width threshold.
[0088] Specifically, the tone mapping mask includes the gain value corresponding to each pixel in the grayscale image. After obtaining the tone mapping mask, the gain of the original image can be adjusted based on the gain values of each pixel in the mask, generating the gain-adjusted result of the original image. At this point, the bit width of the gain-adjusted result of the original image is the same as that of the original image. Therefore, the gain-adjusted result of the original image can be further shifted to generate the tone mapping result of the original image. Here, the bit width of the original image is greater than a preset bit width threshold, and the bit width of the tone mapping result of the original image is less than or equal to the preset bit width threshold. For example, to reduce computation, the gain-adjusted result of the original image can be right-shifted to obtain an image with a smaller bit width. For example, the gain-adjusted result of the original image (16-bit) can be converted into a 10-bit image, thus achieving the shifting process of the gain-adjusted result of the original image to generate the tone mapping result of the original image.
[0089] Specifically, gain adjustment and shifting can be performed using formula (1-4):
[0090] Rout[i] = Rin[i] * Mask[i] >> N
[0091] Gout[i]=Gin[i]*Mask[i]>>N formula (1-4)
[0092] Bout[i] = Bin[i] * Mask[i] >> N
[0093] Where Rin[i] is the R component of pixel i in the original image, Gin[i] is the G component of pixel i in the original image, and Bin[i] is the B component of pixel i in the original image; Rout[i] is the R component of pixel i in the original image, output after gain adjustment and shifting; Gout[i] is the G component of pixel i in the original image, output after gain adjustment and shifting; Bout[i] is the B component of pixel i in the original image, output after gain adjustment and shifting; Mask[i] is the pixel value corresponding to pixel i in the tone mapping mask; and N is the number of shifts performed.
[0094] In this embodiment, the gain of the original image is adjusted based on the gain value corresponding to each pixel in the tone mapping mask, generating a gain adjustment result for the original image. Then, the gain adjustment result of the original image is shifted to generate a tone mapping result for the original image. On one hand, the gain adjustment of the original image is based on the gain value corresponding to each pixel in the tone mapping mask; since the tone mapping mask can reflect a linear mapping relationship, linear adjustment of the original image is achieved during the gain adjustment process. This avoids the color cast problem that occurs during tone mapping of the original image (RGB image).
[0095] On the other hand, shifting the gain adjustment result of the original image converts it from a high-bit image to a low-bit image. Compression of the original image is achieved through gain adjustment and shifting, thus converting the original image from a high-dynamic-range image to a low-dynamic-range image.
[0096] The above embodiments describe an image processing method, including: acquiring a grayscale image of an original image; performing tone mapping on the grayscale image to generate a tone mapping result of the grayscale image; calculating a linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image; and performing tone mapping on the original image based on the linear mapping relationship to generate a tone mapping result of the original image. In this embodiment, as shown... Figure 5 As shown, an image processing method is provided, which further includes:
[0097] Step 280: Perform color enhancement processing on the tone mapping result of the original image according to the preset pixel mapping table to generate the target tone mapping result of the original image.
[0098] Specifically, after obtaining the tone mapping result of the original image, if the color effect of the tone mapping result does not meet the preset color effect, further color enhancement processing can be performed on the tone mapping result of the original image. For example, color enhancement processing can be performed on the tone mapping result of the original image according to a preset pixel mapping table to generate the target tone mapping result of the original image.
[0099] The preset pixel mapping table can also be called a 3D look-up table (3D-LUT). Here, the preset pixel mapping table stores the correspondence between input pixel values and color-enhanced output pixel values. Furthermore, the correspondence between input pixel values and color-enhanced output pixel values recorded in the preset pixel mapping table can be obtained from a large number of input images and their corresponding output images after a professional has performed color enhancement processing on a large number of input images to generate output images that meet the preset color effect. Of course, this application does not limit this. Therefore, by using the pixel values of each pixel in the tone mapping result of the original image as input pixel values to look up the preset pixel mapping table, the color-enhanced output pixel values can be obtained. Based on all the color-enhanced output pixel values, the target tone mapping result of the original image (the image after 3D LUT) can be generated.
[0100] Specifically, the following formulas (1-5) can be used to look up the pixel values of each pixel in the tone mapping result of the original image as input pixel values in the preset pixel mapping table to obtain the output pixel values after color enhancement.
[0101] Rout[i] = Rtable[Rin[i]]
[0102] Gout[i]=Gtable[Gin[i]] Formula (1-5)
[0103] Bout[i] = Btable[Bin[i]]
[0104] Wherein, Rin[i] is the R component of pixel i in the tone mapping result of the original image, Gin[i] is the G component of pixel i in the tone mapping result of the original image, and Bin[i] is the B component of pixel i in the tone mapping result of the original image; Rout[i] is the color-enhanced output pixel value obtained by looking up the preset pixel mapping table based on the R component of pixel i in the tone mapping result of the original image; Gout[i] is the color-enhanced output pixel value obtained by looking up the preset pixel mapping table based on the G component of pixel i in the tone mapping result of the original image; Bout[i] is the color-enhanced output pixel value obtained by looking up the preset pixel mapping table based on the B component of pixel i in the tone mapping result of the original image; Rtable is the preset pixel mapping table corresponding to the R component, Gtable is the preset pixel mapping table corresponding to the G component, and Btable is the preset pixel mapping table corresponding to the B component.
[0105] In this embodiment, after obtaining the tone mapping result of the original image, if the color effect of the tone mapping result of the original image cannot achieve the preset color effect, further color enhancement processing can be performed on the tone mapping result of the original image to generate the target tone mapping result of the original image. Therefore, it is realized that after converting a high dynamic range image (original image) into a low dynamic range image (tone mapping result of the original image), the color effect of the low dynamic range image can be improved by color enhancement.
[0106] In the previous embodiment, an image processing method was described that, after converting a high dynamic range image (the original image) into a low dynamic range image (the tone mapping result of the original image), the color effect of the low dynamic range image can be improved by color enhancement. In this embodiment, as... Figure 6 As shown, an image processing method is provided, which further includes:
[0107] Step 290: Process the target region in the tone mapping result of the original image or the target region in the target tone mapping result of the original image to generate the final tone mapping result of the original image.
[0108] After obtaining the tone mapping result of the original image or the target tone mapping result of the original image (the image after 3D LUT), targeted adjustments can be made to the target regions in the image. The target regions can be regions of interest, such as subject regions, background regions, etc., which are not limited in this application. The subject region can be a region obtained from the image through subject recognition; for example, the subject region can be any one or more of the following: a human figure region, an animal region, a building region, etc. For human figure regions, targeted adjustments can include brightening, beautifying, or altering the appearance of the human figure. For building regions, targeted adjustments can include distortion correction of the buildings.
[0109] The background area includes any one or more of the following: sky, ocean, beach, mountains, and forest. This application does not limit this. For example, color correction and / or contrast enhancement processing can be applied to the sky, ocean, and beach areas.
[0110] In this embodiment, the target region in the tone mapping result of the original image or the target region in the target tone mapping result of the original image is processed to generate the final tone mapping result of the original image. Targeted adjustments can be made to the target region in the image to improve its display effect. This, in turn, improves the overall display effect of the image.
[0111] In the previous embodiment, step 290 was described, which involves processing the target region in the tone mapping result of the original image or the target region in the target tone mapping result of the original image to generate the final tone mapping result of the original image. In this embodiment, if the target region includes a human figure region, then processing the target region in the tone mapping result of the original image or the target region in the target tone mapping result of the original image to generate the final tone mapping result of the original image includes:
[0112] The portrait area in the tone mapping result of the original image or the portrait area in the target tone mapping result of the original image is brightened to generate the final tone mapping result of the original image.
[0113] If the target region includes a sky region, then processing the target region in the tone mapping result of the original image or the target region in the target tone mapping result of the original image to generate the final tone mapping result of the original image includes:
[0114] Color correction and / or contrast enhancement processing are performed on the sky area in the tone mapping result of the original image or the sky area in the target tone mapping result of the original image to generate the final tone mapping result of the original image.
[0115] On one hand, if the target area includes a human figure area, the human figure area in the tone mapping result of the original image or the target tone mapping result of the original image is brightened to generate the final tone mapping result of the original image. For example, if the image contains a human figure area, the characteristics of the human figure area can be considered to brighten the human figure area in the tone mapping result of the original image or the target tone mapping result of the original image to generate the final tone mapping result of the original image. For example, the brightness of the human figure area can be increased by brightening it, etc., although this application does not limit this. Specifically, the human figure area in the tone mapping result of the original image or the target tone mapping result of the original image can be brightened by adjusting the image's shooting parameters to generate the final tone mapping result of the original image. For example, the shooting parameters here include exposure parameters, white balance parameters, etc. Alternatively, a global tone mapping method can be used to brighten the human figure area.
[0116] Specifically, the portrait area in the tone mapping result of the original image can be brightened to generate the final tone mapping result of the original image. That is, after converting the high dynamic range image (original image) into a low dynamic range image (tone mapping result of the original image), the portrait area in the tone mapping result of the original image is directly brightened. Then, the global tone mapping result of the portrait area is merged with the background area in the tone mapping result of the original image to generate the final tone mapping result of the original image.
[0117] Furthermore, the portrait area in the target tone mapping result of the original image can be brightened to generate the final tone mapping result of the original image. That is, after converting the high dynamic range image (original image) to a low dynamic range image (the tone mapping result of the original image), further color enhancement processing is performed on the tone mapping result of the original image to generate the target tone mapping result of the original image. Then, the portrait area in the target tone mapping result of the original image is brightened. Finally, the global tone mapping result of the portrait area is merged with the background area in the target tone mapping result of the original image to generate the final tone mapping result of the original image.
[0118] On the other hand, if the target area includes a sky area, then the sky area in the tone mapping result of the original image or the sky area in the target tone mapping result of the original image is subjected to color adjustment and / or contrast enhancement processing to generate the final tone mapping result of the original image.
[0119] Specifically, if an image contains a sky region, the sky region can be specifically processed based on its characteristics to improve its image quality. For example, the sky region in the tone mapping result or the target tone mapping result of the original image can be color-corrected and / or contrast-enhanced to generate the final tone mapping result of the original image.
[0120] Color correction of the sky region refers to adding blue component values to the sky region. For example, the sky region can be color-corrected based on a preset pixel mapping table to increase the blue component value. Here, the correspondence between the input pixel values of the sky region recorded in the preset pixel mapping table and the output pixel values after color correction can be obtained from a large number of input images and their corresponding output images after professionals have color-corrected a large number of input images (including the sky region) to generate output images that meet the preset color effect.
[0121] In this embodiment, the portrait area in the tone mapping result of the original image or the portrait area in the target tone mapping result of the original image is brightened to generate the final tone mapping result of the original image. Targeted adjustments can be made to the portrait area in the image to improve its display effect. Color correction and / or contrast enhancement processing are performed on the sky area in the tone mapping result of the original image or the sky area in the target tone mapping result of the original image to generate the final tone mapping result of the original image. Therefore, the sky area can be targeted to improve its image quality.
[0122] In the previous embodiment, the process of performing global tone mapping on the portrait region to generate the final tone mapping result of the original image was described. In this embodiment, as... Figure 7 As shown, this document details the brightening process performed on the portrait region in the tone mapping result of the original image or the portrait region in the target tone mapping result of the original image to generate the final tone mapping result of the original image, including:
[0123] Step 720: Perform portrait region segmentation processing on the grayscale image to obtain a portrait region mask.
[0124] Specifically, in combination Figure 8 The diagram illustrates how, in one embodiment, global tone mapping is performed on the portrait region in the target tone mapping result (image after 3D LUT) of the original image to generate the final tone mapping result of the original image. After obtaining the grayscale image of the original image, portrait region segmentation processing can be performed on the grayscale image to obtain a portrait region mask. Portrait region segmentation processing can be performed on the grayscale image using a portrait segmentation model to obtain the portrait region mask. Here, the portrait segmentation model can be based on a trained artificial intelligence model (AI), or it can be based on a trained neural network model, etc., which is not limited in this application.
[0125] The portrait region mask is used to extract the region of interest (portrait region) from the tone mapping result of the original image or the target tone mapping result of the original image (the image after 3D LUT). In the portrait region mask, the pixel value of the pixels in the portrait region is assigned a value of 1, while the pixel value of the pixels in the background region excluding the portrait region is assigned a value of 0. For example... Figure 9 As shown, this is a schematic diagram of a human portrait area mask in one embodiment. The black area is the background area, and the pixel value of the pixels in the black area is 0; the white area is the human portrait area, and the pixel value of the pixels in the white area is 1.
[0126] Step 740: Obtain the portrait region based on the portrait region mask and the tone mapping result of the original image; or obtain the portrait region based on the portrait region mask and the target tone mapping result of the original image. The portrait region corresponds to either the tone mapping result or the target tone mapping result.
[0127] The portrait region can be obtained by multiplying the portrait region mask by the tone mapping result of the original image. It is known that in the portrait region mask, the pixel values of the portrait region are assigned a value of 1, while the background region (excluding the portrait region) is assigned a value of 0. Therefore, multiplying the portrait region mask by the tone mapping result of the original image is equivalent to keeping the pixel values of the portrait region unchanged in the tone mapping result of the original image, while the pixel values of the background region in the tone mapping result of the original image all become 0. This achieves the extraction of the portrait region from the tone mapping result of the original image.
[0128] The portrait region mask can also be multiplied by the target tone mapping result of the original image to obtain the portrait region. It is known that in the portrait region mask, the pixel values of the portrait region are assigned a value of 1, while the background region (excluding the portrait region) is assigned a value of 0. Therefore, multiplying the portrait region mask by the target tone mapping result of the original image is equivalent to keeping the pixel values of the portrait region unchanged in the original image's target tone mapping result, while the pixel values of the background region in the original image's target tone mapping result all become 0. This achieves the extraction of the portrait region from the target tone mapping result of the original image.
[0129] Step 760: Perform global tone mapping on the portrait area to generate the global tone mapping result for the portrait area.
[0130] After obtaining the portrait area, global tone mapping can be performed on it to generate a global tone mapping result. Here, global tone mapping is mainly used to brighten the portrait area. This allows for targeted adjustments to the portrait area in the image to improve its display quality.
[0131] Specifically, global tone mapping can be performed using formula (1-6):
[0132]
[0133] Where In[i] is the grayscale value of each pixel in the portrait region, and Out[i] is the grayscale value output by each pixel in the portrait region after global tone mapping; max The largest grayscale value in the portrait area, In minLet τ be the minimum grayscale value in the portrait area, and let τ be an adjustment parameter. The specific value of τ can be obtained through experimentation. Here, the value of τ can be the same as or different from that in formula (1-3), and this application does not impose any restrictions on this.
[0134] Step 780: The global tone mapping result of the portrait area is fused with the background area to generate the final tone mapping result of the original image; the background area includes the background area in the tone mapping result of the original image or the background area in the target tone mapping result of the original image.
[0135] After obtaining the global tone mapping result for the portrait region, this result can be merged with the background region to generate the final tone mapping result of the original image. Specifically, the brightened portrait region is merged with the background region to generate the final tone mapping result of the original image as the output image. If the portrait region is obtained by multiplying the portrait region mask by the tone mapping result of the original image, then the global tone mapping result of the portrait region is merged with the background region in the tone mapping result of the original image to generate the final tone mapping result of the original image. If the portrait region is obtained by multiplying the portrait region mask by the target tone mapping result of the original image, then the global tone mapping result of the portrait region is merged with the background region in the target tone mapping result of the original image to generate the final tone mapping result of the original image.
[0136] In this embodiment, a grayscale image is segmented to obtain a portrait region mask. The portrait region is obtained based on the portrait region mask and the tone mapping result of the original image, or based on the portrait region mask and the target tone mapping result of the original image. Global tone mapping is performed on the portrait region to generate a global tone mapping result. This global tone mapping result is then fused with the background region to generate the final tone mapping result of the original image. Based on the portrait region mask, the portrait region can be accurately extracted from the tone mapping result of the original image or the target tone mapping result of the original image. Therefore, targeted global tone mapping can be performed on the portrait region to improve its image quality (e.g., brightness). Finally, the global tone mapping result of the portrait region is fused with the background region to generate the final tone mapping result of the original image. This improves the image quality or effect of the final tone mapping result of the original image.
[0137] In a specific embodiment, such as Figure 10 As shown, an image processing method is provided, including:
[0138] Step 1002: Obtain the original image (high-bit image), for example, a 16-bit RGB image;
[0139] Step 1004: Convert the original image to a grayscale image;
[0140] Step 1006: Perform global tone mapping on the grayscale image to generate the global tone mapping result of the grayscale image;
[0141] Step 1008: Perform local tone mapping on the global tone mapping result of the grayscale image to generate the local tone mapping result of the grayscale image, and use the local tone mapping result of the grayscale image as the tone mapping result of the grayscale image.
[0142] Step 1010: Divide the pixel value of each pixel in the tone mapping result of the grayscale image with the pixel value of the corresponding position in the grayscale image to generate a tone mapping mask.
[0143] Step 1012: Perform tone mapping on the original image based on the tone mapping mask to generate the tone mapping result (low-bit image) of the original image;
[0144] Step 1014: Perform color enhancement processing on the tone mapping result (low-bit image) of the original image according to the preset pixel mapping table to generate the target tone mapping result of the original image;
[0145] Step 1016: Perform global tone mapping on the portrait area in the tone mapping result of the original image or the target tone mapping result of the original image to generate the final tone mapping result of the original image.
[0146] Step 1016 includes step 1016a, which involves performing portrait region segmentation on the grayscale image to obtain a portrait region mask.
[0147] Step 1016b: Obtain the portrait region based on the portrait region mask and the tone mapping result of the original image, or based on the portrait region mask and the target tone mapping result of the original image.
[0148] Step 1016c: Perform global tone mapping on the portrait area to generate the global tone mapping result for the portrait area;
[0149] Step 1016d: The global tone mapping result of the portrait area is fused with the background area to generate the final tone mapping result of the original image;
[0150] Step 1018: Perform color correction and / or contrast enhancement processing on the sky area in the final tone mapping result of the original image to generate the output image of the original image.
[0151] In this embodiment, a grayscale image of the original image is obtained, and tone mapping is performed on the grayscale image to generate a tone-mapped result of the grayscale image. A linear mapping relationship between the tone-mapped result of the grayscale image and the grayscale image is calculated. Based on this linear mapping relationship, tone mapping is performed on the original image to generate a tone-mapped result of the original image. Since a grayscale image is a single-channel image, the tone mapping process only requires tone mapping of the single-channel pixel values. Therefore, a linear mapping relationship exists between the tone-mapped result of the grayscale image and the grayscale image. This linear mapping relationship is then calculated. Finally, tone mapping is performed on the original image based on this linear mapping relationship, thus achieving a linear transformation during the tone mapping process on the original image.
[0152] Traditional methods directly perform tone mapping on the original image, that is, tone mapping on each of the RGB components of the original image separately. This obviously alters the relationship between the RGB components, causing color cast and degrading image quality. However, in this embodiment, a linear transformation is implemented during tone mapping of the original image. Since a linear transformation preserves the relationship between the RGB components of the original image during tone mapping, it better retains the color information in the original image. Therefore, the color cast problem during tone mapping of the original image is avoided, thereby improving the image quality of the tone-mapped result of the generated original image.
[0153] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.
[0154] In one embodiment, such as Figure 11 As shown, an image processing apparatus 1100 is provided, the apparatus comprising:
[0155] The acquisition module 1120 is used to acquire the grayscale image of the original image;
[0156] The first tone mapping module 1140 is used to perform tone mapping on a grayscale image to generate a tone mapping result for the grayscale image;
[0157] The second tone mapping module 1160 is used to calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and to perform tone mapping on the original image according to the linear mapping relationship to generate the tone mapping result of the original image.
[0158] In one embodiment, such as Figure 12 As shown, the first tone mapping module 1140 includes:
[0159] The global tone mapping unit 1142 is used to perform global tone mapping on the grayscale image and generate the global tone mapping result of the grayscale image;
[0160] The local tone mapping unit 1144 is used to perform local tone mapping on the global tone mapping result of the grayscale image, generate the local tone mapping result of the grayscale image, and use the local tone mapping result of the grayscale image as the tone mapping result of the grayscale image.
[0161] In one embodiment, the local tone mapping unit 1144 is further configured to divide the global tone mapping result of the grayscale image into blocks to generate multiple grayscale image blocks; and to perform local tone mapping on each grayscale image block using histogram equalization to generate the local tone mapping result of the grayscale image.
[0162] In one embodiment, the second tone mapping module 1160 includes:
[0163] The tone mapping mask generation unit is used to calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and generate a tone mapping mask.
[0164] The second tone mapping unit is used to perform tone mapping on the original image based on the tone mapping mask, and generate the tone mapping result of the original image.
[0165] In one embodiment, the tone mapping mask generation unit is further configured to divide the pixel value of each pixel in the tone mapping result of the grayscale image by the pixel value of the corresponding pixel in the grayscale image to generate the gain value corresponding to each pixel in the grayscale image; and generate a tone mapping mask based on the gain value corresponding to each pixel in the grayscale image.
[0166] In one embodiment, the second tone mapping unit is further configured to adjust the gain of the original image according to the gain value corresponding to each pixel in the tone mapping mask, and generate a gain adjustment result of the original image; and to shift the gain adjustment result of the original image to generate a tone mapping result of the original image; wherein the bit width of the original image is greater than the bit width of the tone mapping result of the original image.
[0167] In one embodiment, such as Figure 13As shown, an image processing apparatus is provided, which further includes:
[0168] The color enhancement module 1170 is used to perform color enhancement processing on the tone mapping result of the original image according to the preset pixel mapping table, and generate the target tone mapping result of the original image.
[0169] In one embodiment, such as Figure 13 As shown, an image processing apparatus is provided, which further includes:
[0170] The target region processing module 1180 is used to process the target region in the tone mapping result of the original image or the target region in the target tone mapping result of the original image to generate the final tone mapping result of the original image.
[0171] In one embodiment, if the target area includes a human figure area, the target area processing module 1180 includes: a human figure area processing unit, used to brighten the human figure area in the tone mapping result of the original image or the human figure area in the target tone mapping result of the original image to generate the final tone mapping result of the original image.
[0172] If the target area includes a sky area, then the target area processing module 1180 includes: a sky area processing unit, used to perform color adjustment processing and / or contrast enhancement processing on the sky area in the tone mapping result of the original image or the sky area in the target tone mapping result of the original image, to generate the final tone mapping result of the original image.
[0173] In one embodiment, the portrait region processing unit is further configured to perform portrait region segmentation processing on the grayscale image to obtain a portrait region mask; obtain a portrait region based on the portrait region mask and the tone mapping result of the original image; or obtain a portrait region based on the portrait region mask and the target tone mapping result of the original image; the portrait region corresponds to the tone mapping result or the target tone mapping result respectively; perform global tone mapping on the portrait region to generate a global tone mapping result for the portrait region; and fuse the global tone mapping result of the portrait region with the background region to generate the final tone mapping result of the original image; the background region includes the background region in the tone mapping result of the original image or the background region in the target tone mapping result of the original image.
[0174] The division of the various modules in the above-described image processing device is merely for illustrative purposes. In other embodiments, the image processing device may be divided into different modules as needed to complete all or part of the functions of the above-described image processing device.
[0175] For specific limitations regarding the image processing apparatus, please refer to the limitations on the image processing method above, which will not be repeated here. Each module in the aforementioned image processing apparatus can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the operations corresponding to each module.
[0176] Figure 14 This is a schematic diagram of the internal structure of an electronic device in one embodiment. The electronic device can be any terminal device such as a mobile phone, tablet computer, laptop computer, desktop computer, PDA (Personal Digital Assistant), POS (Point of Sales), in-vehicle computer, wearable device, etc. The electronic device includes a processor and a memory connected via a system bus. The processor may include one or more processing units. The processor may be a CPU (Central Processing Unit) or a DSP (Digital Signal Processor), etc. The memory may include a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The computer programs can be executed by the processor to implement an image processing method provided in the following embodiments. The internal memory provides a cached runtime environment for the operating system computer programs in the non-volatile storage medium.
[0177] The various modules in the image processing apparatus provided in this application embodiment can be implemented in the form of a computer program. This computer program can run on an electronic device. The program modules constituted by this computer program can be stored in the memory of the electronic device. When the computer program is executed by a processor, it implements the steps of the method described in the embodiments of this application.
[0178] This application also provides a computer-readable storage medium. One or more non-volatile computer-readable storage media containing computer-executable instructions, which, when executed by one or more processors, cause the processors to perform the steps of an image processing method.
[0179] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform an image processing method.
[0180] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0181] Any references to memory, storage, databases, or other media used in this application may include non-volatile and / or volatile memory. Non-volatile memory may include ROM (Read-Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), or flash memory. Volatile memory may include RAM (Random Access Memory), which is used as external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as SRAM (Static Random Access Memory), DRAM (Dynamic Random Access Memory), SDRAM (Synchronous Dynamic Random Access Memory), Double Data Rate DDR SDRAM (Double Data Rate Synchronous Dynamic Random Access Memory), ESDRAM (Enhanced Synchronous Dynamic Random Access Memory), SLDRAM (Sync Link Dynamic Random Access Memory), RDRAM (Rambus Dynamic Random Access Memory), and DRDRAM (Direct Rambus Dynamic Random Access Memory).
[0182] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. An image processing method, characterized in that, The method includes: Obtain the grayscale image of the original image; The grayscale image is tone-mapped to generate a tone-mapped result for the grayscale image, wherein the tone mapping includes a global tone mapping. Calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and perform tone mapping on the original image according to the linear mapping relationship to generate the tone mapping result of the original image; During the processing of the target region in the tone mapping result of the original image, if the target region includes a human figure region, the grayscale image is processed to segment the human figure region to obtain a human figure region mask. The portrait region is obtained based on the portrait region mask and the tone mapping result of the original image; the portrait region corresponds to the tone mapping result respectively. Perform global tone mapping on the portrait area to generate the global tone mapping result for the portrait area; The global tone mapping result of the portrait area is fused with the background area to generate the final tone mapping result of the original image; the background area includes the background area in the tone mapping result of the original image.
2. The method according to claim 1, characterized in that, The step of performing tone mapping on the grayscale image to generate the tone mapping result of the grayscale image includes: Perform global tone mapping on the grayscale image to generate the global tone mapping result of the grayscale image; The global tone mapping result of the grayscale image is subjected to local tone mapping to generate the local tone mapping result of the grayscale image, and the local tone mapping result of the grayscale image is used as the tone mapping result of the grayscale image.
3. The method according to claim 2, characterized in that, The step of performing local tone mapping on the global tone mapping result of the grayscale image to generate the local tone mapping result of the grayscale image includes: The global tone mapping result of the grayscale image is divided into blocks to generate multiple grayscale image blocks; Histogram equalization is used to perform local tone mapping on each grayscale image block to generate the local tone mapping result of the grayscale image.
4. The method according to any one of claims 1-3, characterized in that, The step of calculating the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and performing tone mapping on the original image according to the linear mapping relationship to generate the tone mapping result of the original image includes: Calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and generate a tone mapping mask; The original image is tone-mapped based on the tone-mapping mask to generate the tone-mapping result of the original image.
5. The method according to claim 4, characterized in that, The step of calculating the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and generating a tone mapping mask, includes: The gain value corresponding to each pixel in the grayscale image is generated by dividing the pixel value of each pixel in the tone mapping result of the grayscale image by the pixel value of the corresponding pixel in the grayscale image. The tone mapping mask is generated based on the gain value corresponding to each pixel in the grayscale image.
6. The method according to claim 5, characterized in that, The step of performing tone mapping on the original image based on the tone mapping mask to generate the tone mapping result of the original image includes: Based on the gain value corresponding to each pixel in the tone mapping mask, the gain of the original image is adjusted to generate the gain adjustment result of the original image; The gain adjustment result of the original image is shifted to generate the tone mapping result of the original image; wherein the bit width of the original image is greater than the bit width of the tone mapping result of the original image.
7. The method according to any one of claims 1-3, characterized in that, The method further includes: The color enhancement process is performed on the tone mapping result of the original image according to the preset pixel mapping table to generate the target tone mapping result of the original image.
8. The method according to claim 7, characterized in that, The method further includes: The target region in the target tone mapping result of the original image is processed to generate the final tone mapping result of the original image.
9. The method according to claim 8, characterized in that, If the target region includes a human figure region, then the target region in the target tone mapping result of the original image is processed to generate the final tone mapping result of the original image, including: The portrait area in the target tone mapping result of the original image is brightened to generate the final tone mapping result of the original image; If the target region includes a sky region, then the target region in the tone mapping result of the original image or the target region in the target tone mapping result of the original image is processed to generate the final tone mapping result of the original image, including: Color correction and / or contrast enhancement processing are performed on the sky area in the tone mapping result of the original image or the sky area in the target tone mapping result of the original image to generate the final tone mapping result of the original image.
10. The method according to claim 9, characterized in that, Brightening the portrait area in the target tone mapping result of the original image to generate the final tone mapping result of the original image includes: The grayscale image is segmented to obtain a human image region mask. The portrait region is obtained based on the portrait region mask and the target tone mapping result of the original image; the portrait region corresponds to the target tone mapping result respectively; Perform global tone mapping on the portrait area to generate the global tone mapping result for the portrait area; The global tone mapping result of the portrait area is fused with the background area to generate the final tone mapping result of the original image; the background area includes the background area in the target tone mapping result of the original image.
11. An image processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire the grayscale image of the original image; The first tone mapping module is used to perform tone mapping on the grayscale image to generate the tone mapping result of the grayscale image, wherein the tone mapping includes global tone mapping; The second tone mapping module is used to calculate the linear mapping relationship between the tone mapping result of the grayscale image and the grayscale image, and to perform tone mapping on the original image according to the linear mapping relationship to generate the tone mapping result of the original image; The target region processing module is used to, during the processing of the target region in the tone mapping result of the original image, if the target region includes a human image region, perform human image region segmentation processing on the grayscale image to obtain a human image region mask; obtain the human image region based on the human image region mask and the tone mapping result of the original image; the human image region corresponds to the tone mapping result; perform global tone mapping on the human image region to generate a global tone mapping result for the human image region; and fuse the global tone mapping result of the human image region with the background region to generate the final tone mapping result of the original image; the background region includes the background region in the tone mapping result of the original image.
12. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the computer program is executed by the processor, the processor performs the steps of the image processing method as described in any one of claims 1 to 10.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the image processing method as described in any one of claims 1 to 10.
14. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the steps of the image processing method according to any one of claims 1 to 10.