Image dynamic range calibration method and electronic device
By performing dynamic range calibration on HDR images generated in electronic devices, and using YUV format images generated from standard raw images to process gain images, the problem of visual differences between HDR images and preview images is solved, and the user experience and image quality are improved.
Patent Information
- Application Number
- CN202310953742.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2043-07-31
AI Technical Summary
When an electronic device shoots a high dynamic range image, there is a large visual difference between the generated HDR image and the preview image viewed by the user, which affects the user experience.
By using the YUV format image generated by the standard raw image to perform dynamic range calibration on the high dynamic range gain image, the target image is generated, which improves the image quality and visual effects of the HDR image and reduces the visual effect difference between the HDR image and the preview image.
It improves the user experience. Through dynamic range calibration, the generated HDR image is closer to the video image previewed by the user, improving the visual effect and quality of the image.
Smart Images

Figure CN117710264B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image processing, and in particular to a method and electronic device for calibrating the dynamic range of an image. Background Art
[0002] The dynamic range of an image refers to the grayscale ratio of the brightest part to the darkest part of the image. In other words, the dynamic range of an image is a measure of the brightness levels that can be presented in an image. Generally speaking, the higher the dynamic range of an image, the richer the details in the image and the closer it is to the real environment. To this end, electronic devices (e.g., mobile phones) provide users with the function of shooting high dynamic range (HDR) images so that the images presented to users can include more image details and better reflect the visual effects of real scenes.
[0003] When a user takes a picture, the electronic device generally displays a preview video for the user in the interface, so that the user can complete the picture taking based on the preview image. However, there is a big difference in the visual effect between the HDR image provided by the electronic device to the user when the user takes the picture and the image in the preview video viewed by the user (hereinafter referred to as the preview image), which affects the user experience. Summary of the invention
[0004] The present application provides a dynamic range calibration method for an image and an electronic device, which can reduce the visual effect difference between an HDR image captured by an electronic device and a preview image viewed by a user, thereby improving the user experience.
[0005] In the first aspect, an embodiment of the present application provides a method for calibrating the dynamic range of an image, including: obtaining a first image and a second image; the first image is a gain image with a high dynamic range; the second image is an image in a YUV format; the second image is generated according to a standard raw image; the standard raw image is a standard raw image in a raw image used to generate the first image; the first image is dynamically calibrated using the second image to obtain a target image, and the target image is a high dynamic range image. In this method, the first image is dynamically calibrated using a second image in a YUV format generated using a standard raw image, and the standard raw image is a standard raw image in a multi-frame raw image used to generate the first image, thereby improving the image quality and visual effect of the generated HDR image, reducing the visual effect difference between the HDR image and the preview image viewed by the user, and improving the user experience.
[0006] In a possible implementation manner, the using the second image to perform dynamic range calibration on the first image to obtain a target image includes: generating a first weight map of the first image and a second weight map of the second image; constructing a first image pyramid of the first image, a second image pyramid of the second image, a third image pyramid of the first weight map, and a fourth image pyramid of the second weight map; and generating the target image according to the first image pyramid, the second image pyramid, the third image pyramid, and the fourth image pyramid.
[0007] In one possible implementation, generating a first weight map for the first image and a second weight map for the second image includes: determining Gaussian filtering parameters of the first image and Gaussian filtering parameters of the second image according to exposure; updating a first lookup table for the first image and a second lookup table for the second image according to the Gaussian filtering parameters of the first image and the Gaussian filtering parameters of the second image; generating a first weight map for the first image according to the first lookup table for the first image, and generating a second weight map for the second image according to the second lookup table for the second image.
[0008] In a possible implementation manner, before constructing the third image pyramid of the first weight map and the fourth image pyramid of the second weight map, the method further includes: performing Gaussian filtering on the first weight map and the second weight map respectively.
[0009] In one possible implementation, Gaussian filtering is performed on the first weight map, including: filling the first weight map to obtain a filled first weight map; Gaussian filtering the filled first weight map according to the Gaussian filtering parameters of the first image; and / or Gaussian filtering is performed on the second weight map, including: filling the second weight map to obtain a filled second weight map; Gaussian filtering the filled second weight map according to the Gaussian filtering parameters of the second image.
[0010] In a possible implementation manner, generating a target image according to the first image pyramid, the second image pyramid, the third image pyramid, and the fourth image pyramid includes: fusing the first image pyramid, the second image pyramid, the third image pyramid, and the fourth image pyramid to obtain a first fused pyramid; fusing the first image pyramid and the second image pyramid to obtain a second fused pyramid; and reconstructing an image according to the first fused pyramid and the second fused pyramid to obtain the target image.
[0011] In a possible implementation manner, the fusing the first image pyramid, the second image pyramid, the third image pyramid, and the fourth image pyramid to obtain a first fused pyramid includes: fusing the first image pyramid and the third image pyramid to obtain a second fused pyramid; fusing the second image pyramid and the fourth image pyramid to obtain a third fused pyramid; and fusing the second fused pyramid and the third fused pyramid to obtain the first fused pyramid.
[0012] In a possible implementation manner, the fusing the first image pyramid and the third image pyramid to obtain a second fused pyramid includes: multiplying pixel values of corresponding points of the first image pyramid and the third image pyramid and obtaining a product thereof as the pixel value of the corresponding point of the second fused pyramid.
[0013] In a possible implementation, fusing the second fused pyramid and the third fused pyramid to obtain the first fused pyramid includes: adding pixel values of corresponding points of the second fused pyramid and the third fused pyramid to obtain a sum as the pixel value of the corresponding point of the first fused pyramid.
[0014] In a possible implementation, obtaining the first image and the second image includes: receiving a first operation of a user; in response to the first operation, driving a camera to capture multiple frames of raw images; the multiple frames of raw images have different exposure amounts; generating the first image according to the multiple frames of raw images; and generating the second image according to a standard raw image in the multiple frames of raw images.
[0015] In a possible implementation, generating the first image according to the multiple frames of raw images includes: generating an LDR image according to the multiple frames of raw images; and performing dynamic range expansion on the LDR image to obtain the first image.
[0016] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory; wherein one or more computer programs are stored in the memory, and the one or more computer programs include instructions, and when the instructions are executed by the processor, the electronic device executes any one of the methods described in the first aspect.
[0017] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute any of the methods described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0020] Figure 2 A schematic diagram of a software structure of an electronic device provided in an embodiment of the present application;
[0021] Figure 3 A schematic diagram of a flow chart of a method for calibrating the dynamic range of an image provided in an embodiment of the present application;
[0022] Figure 4 A schematic diagram of an interface of a method for calibrating the dynamic range of an image provided in an embodiment of the present application;
[0023] Figure 5 Another schematic diagram of a flow chart of a method for calibrating the dynamic range of an image provided in an embodiment of the present application;
[0024] Figure 6 A schematic diagram of another structure of an electronic device provided in an embodiment of the present application;
[0025] Figure 7 Based on the embodiments of the present application Figure 6 A schematic flow chart of another method for calibrating the dynamic range of an image of the structure shown;
[0026] Fig. 8A A schematic diagram of an image in a preview video provided in an embodiment of the present application;
[0027] Figure 8B A schematic diagram of an image without dynamic range calibration provided in an embodiment of the present application;
[0028] Figure 8C An image schematic diagram of dynamic range calibration provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The terms used in the implementation section of this application are only used to explain the specific embodiments of this application and are not intended to limit this application.
[0030] The dynamic range of an image refers to the grayscale ratio of the brightest part to the darkest part of the image. In other words, the dynamic range of an image is a measure of the brightness levels that can be presented in an image. Generally speaking, the higher the dynamic range of an image, the richer the details in the image and the closer it is to the real environment. To this end, electronic devices (e.g., mobile phones) provide users with the function of shooting high dynamic range (HDR) images so that the images presented to users can include more image details and better reflect the visual effects of real scenes.
[0031] In one embodiment, when shooting an HDR image, the electronic device drives the camera to shoot multiple frames of raw images with different exposures, generates a low dynamic range (LDR) image based on the multiple frames of raw images, performs dynamic range expansion and other processing on the LDR image to obtain an HDR image, and provides the HDR image to the user as the image obtained by shooting. However, there is a large difference in visual effect between the above HDR image generated by the electronic device and the image in the preview video watched by the user (hereinafter referred to as the preview image), and public opinions such as "the brightness of the real image is very different from the preview", "what you see is not what you get", and "obvious transformation" may appear, affecting the user experience.
[0032] To this end, an embodiment of the present application provides another method for calibrating the dynamic range of an image, which can calibrate the dynamic range of an image during the process of generating an HDR image, reduce the visual effect difference between the HDR image and the preview image, and improve the user experience.
[0033] First, the nouns appearing in the embodiments of the present application are explained exemplarily.
[0034] The dynamic range of an image refers to the grayscale ratio between the brightest part and the darkest part of the image. In other words, the dynamic range of an image is a measure of the brightness level that can be presented in the image.
[0035] YUV: It is a color encoding mode, in which Y represents brightness (Luminance), that is, grayscale value, U represents chrominance (Chrominance), and V represents concentration (Chroma). It is used to describe the color and saturation of the image and is used to specify the color of the pixel.
[0036] Image pyramid: The image pyramid of an image is a set of image resolutions that are gradually reduced in a pyramid shape (from bottom to top) and are derived from the image. The image pyramid of an image can be obtained by gradient downsampling. The higher the level (the closer to the top of the pyramid), the smaller the image and the lower the resolution.
[0037] Gaussian Pyramid: For an image, the image pyramid generated by Gaussian filtering and downsampling is called a Gaussian pyramid. In some instances, the bottom layer of the Gaussian pyramid of an image is the image, and each layer upward will reduce the resolution of the image through Gaussian filtering and downsampling.
[0038] Laplacian Pyramid: Laplacian Pyramid exists to achieve image reconstruction of Gaussian Pyramid. The Laplacian Pyramid of an image is generated based on the Gaussian Pyramid of the image, which is the difference image between the Gaussian Pyramid and the previous layer after upsampling.
[0039] Raw image: An unprocessed and uncompressed photo format. In other words, a raw image is the original data of the complementary metal oxide semiconductor (CMOS) or charge coupled device (CCD) image sensor in the camera that converts the captured light source signal into a digital signal. The raw image records the original information of the image sensor, and can also record some metadata generated by the camera shooting, such as the sensitivity (ISO) setting, shutter speed, aperture value, white balance, etc.
[0040] The electronic device of the embodiment of the present application is an electronic device including a camera, such as a mobile phone, a tablet computer (PAD), a smart wearable device such as a smart watch, etc.
[0041] Figure 1 A schematic diagram of the structure of an electronic device is shown. Figure 1 As shown, the electronic device 100 may include a processor 110, a memory 120, a camera 130, etc.
[0042] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0043] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0044] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0045] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0046] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0047] The memory 120 can be used to store computer executable program codes, which include instructions. The memory 120 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the memory 120, and / or instructions stored in a memory provided in the processor.
[0048] The camera 130 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the image signal processing (ISP) to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 130, where N is a positive integer greater than 1.
[0049] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. Taking the (Android) system as an example, the software structure of the electronic device 100 is exemplified.
[0050] Figure 2 1 is a software structure block diagram of the electronic device 100 according to an embodiment of the present invention.
[0051] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom: application layer, application framework layer (also called system framework layer), system library and Android runtime layer, hardware abstraction layer (HAL) and kernel layer.
[0052] The application layer may include several applications (hereinafter referred to as applications). In the embodiment of the present application, the application layer may include: an image capture application, such as a camera application.
[0053] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer, including various components and services to support the Android development of developers. In the embodiment of the present application, the application framework layer may include a camera service, etc.
[0054] The system library and Android runtime layer include the system library and Android Runtime. The system library can include multiple functional modules, such as surface manager, libc, etc. The Android runtime is responsible for the scheduling and management of the Android system, specifically including the core library and virtual machine. Among them, the core library contains two parts: one part is the function functions that need to be called by the Java language, and the other part is the Android core library; the virtual machine is used to run Android applications developed using the Java language.
[0055] The HAL layer is an interface layer between the operating system kernel and the hardware circuit. The HAL layer includes but is not limited to: the camera hardware abstraction layer (Camera HAL), which is used to process the image stream.
[0056] The kernel layer is the layer between hardware and software. The kernel layer may include: camera driver, etc. The camera driver is used to drive the camera.
[0057] Below, combined with the above Figure 1 and Figure 2 The structure of the electronic device shown illustrates the dynamic range calibration method of the image according to the embodiment of the present application.
[0058] Figure 3 is a flow chart of a method for calibrating the dynamic range of an image provided in an embodiment of the present application. Figure 3 As shown, the method may include:
[0059] Step 301: obtaining a first image and a second image; the first image is a high dynamic range gain image; the second image is an image in YUV format; the second image is generated according to a standard raw image; the standard raw image is a standard raw image in the raw image used to generate the first image.
[0060] A gain image is an image composed of the gains of each pixel. In other words, the pixel value of each pixel in the gain image is the gain of the pixel. The gain of a pixel can be a multiple or an increase of the pixel value of the pixel. A gain image with a high dynamic range means that the gain image has a high dynamic range.
[0061] The first image may be a single-channel image, and the single-channel pixel value of each pixel may also be referred to as the grayscale value of the pixel.
[0062] Optionally, the electronic device may drive the camera to capture multiple frames of raw images at different exposure levels, generate an LDR image according to the multiple frames of raw images, and perform dynamic range expansion on the LDR image to obtain the above-mentioned first image.
[0063] The method for expanding the dynamic range of the LDR image can be implemented using a related dynamic range expansion algorithm such as an irradiance reconstruction method or a direct fusion method, which is not limited in the embodiments of the present application. Optionally, when expanding the dynamic range of the LDR image, it can be implemented through a neural network.
[0064] When the electronic device drives the camera to shoot multiple frames of raw images at different exposures, it can first calculate an exposure estimate according to the brightness of the environment in which the electronic device is located, use the exposure estimate as the standard exposure, increase and decrease the exposure based on the standard exposure, obtain multiple exposures including the standard exposure, shoot a frame of image at each of the multiple exposures, and thus obtain multiple frames of raw images. In one example, the electronic device can use a related step exposure method to shoot the multiple frames of raw images.
[0065] In the embodiment of the present application, the raw image taken under the above standard exposure is called a standard raw image. In some examples, the above standard raw image can also be called a normalraw image.
[0066] In some examples, the standard exposure value may also be referred to as EV0, which refers to the brightness of the subject that can achieve correct exposure when photographed at ISO 100, aperture 1.0, shutter speed 1 second or their equivalent combinations.
[0067] Step 302: Use the second image to perform dynamic range calibration on the first image to obtain a target image, which is a high dynamic range image.
[0068] The above-mentioned second image is an image in YUV format generated according to the standard raw image among the multiple raw images used to generate the first image. The image is generally closer to the image in the preview video provided to the user by the image capture application in terms of visual effect. From the user's perspective, the visual effect difference between the image and the real scene is small. Therefore, using the second image to calibrate the dynamic range of the first image can make the target image closer to the video image previewed by the user, thereby improving the image quality and visual effect of the HDR image.
[0069] It should be noted that if in some scenarios, the image in the preview video provided to the user by the image capture application is not the second image but other images, the second image can also be expanded to other images with visual effects close to the image previewed by the user.
[0070] In the method, a second image in YUV format generated by a standard raw image is used to perform dynamic range calibration on the first image. The standard raw image is a standard raw image in a multi-frame raw image used to generate the first image, thereby improving the image quality and visual effect of the generated HDR image, reducing the visual effect difference between the HDR image and the preview image, and improving the user experience.
[0071] Figure 4 1 is a schematic diagram of a user interface implementation of a method for calibrating the dynamic range of an image according to an embodiment of the present application. Figure 4 As shown, it may include:
[0072] The user opens the camera application and enters the image preview interface, such as shown in interface 31. The image preview interface can display a preview video, and the image preview interface includes: an image capture control 32, which is used by the user to trigger image capture.
[0073] The user clicks the image capture control 32, and accordingly, the camera application detects the user's selection operation on the image capture control 32, that is, detects the user's image capture trigger operation, and the camera application triggers the image capture process to generate and store an HDR image.
[0074] It should be noted that the image dynamic range calibration method provided in the embodiment of the present application can be executed in the image capture process triggered by the camera application, so that the generated HDR image is a HDR image with dynamic range calibration, thereby improving the visual effect of the HDR image.
[0075] It should be noted that the above Figure 4 The user interface implementation shown is only an example. The dynamic range calibration method of the image provided in the embodiment of the present application can also be applied to other image capture scenarios, such as a photo operation triggered by a user during video capture or a photo operation automatically triggered by an application.
[0076] Figure 5 is a flow chart of a method for calibrating the dynamic range of an image provided by an embodiment of the present application. The method can be executed by an electronic device, such as Figure 5 As shown, the method may include:
[0077] Step 501: An image capture triggering operation is detected.
[0078] In one example, Figure 4 In the illustrated scenario, the user may click on the image capture control 32 in the image preview interface provided by the camera application, and accordingly, the electronic device detects the image capture triggering operation.
[0079] Step 502: In response to an image capture triggering operation, driving a camera to capture multiple frames of raw images; the multiple frames of raw images have different exposure amounts.
[0080] Step 503: Generate an LDR image according to the multiple frames of raw images, perform dynamic range expansion on the LDR image, and obtain a gain image drcy with a high dynamic range.
[0081] For the sake of convenience, the high dynamic range gain image is referred to as the gain image below.
[0082] The high dynamic range gain image drcy is also the first image.
[0083] Step 504: Generate a reference image ispy in a YUV format according to a standard raw image in the multiple frames of raw images.
[0084] Step 505: Determine Gaussian filter parameters of the gain image drcy and Gaussian filter parameters of the reference image ispy according to the exposure.
[0085] Optionally, Gaussian filtering parameters of the gain image drcy and the Gaussian filtering parameters of the reference image ispy corresponding to different exposure amounts can be pre-set in the electronic device. In this step, the corresponding Gaussian filtering parameters of the gain image drcy and the Gaussian filtering parameters of the reference image ispy can be found according to the exposure amount, thereby obtaining the Gaussian filtering parameters of the gain image drcy and the Gaussian filtering parameters of the reference image ispy.
[0086] Optionally, the Gaussian filtering formula may be: The above-mentioned Gaussian filter parameters may include α, m and σ in the formula, where α represents the coefficient, m represents the mean, and σ represents the covariance. Accordingly, in the embodiment of the present application, the Gaussian filter parameters of the gain image drcy can be recorded as: drc-σ, drc-m, drc-α, and the Gaussian filter parameters of the reference image ispy can be recorded as: isp-σ, isp-m, isp-α.
[0087] Step 506: Generate a weight map drcweight1 for the gain image drcy and a weight map ispyweight1 for the reference image ispy according to the Gaussian filtering parameters of the gain image drcy and the Gaussian filtering parameters of the reference image ispy.
[0088] Optionally, this step may specifically include:
[0089] Update the LUT table drcLUT of the gain image drcy and the LUT table ispLUT of the reference image ispy according to the Gaussian filtering parameters of the gain image drcy and the Gaussian filtering parameters of the reference image ispy.
[0090] Convert the gain image into a weight map drcweight1 according to the drcLUT table of the gain image drcy, and convert the reference image isp into a weight map ispyweight1 according to the ispLUT table of the reference image ispy.
[0091] Optionally, the LUT table of the gain image drcy and the LUT table of the reference image ispy may be preset in the electronic device. In the embodiments of the present application, the LUT table of the gain image drcy is denoted as the drcLUT table, and the LUT table of the reference image ispy is denoted as the ispLUT table. The specific implementation of the preset drcLUT table and ispLUT table in the electronic device is not limited in the embodiments of the present application. The process of updating the drcLUT table and the ispLUT table in this step is as follows, for example:
[0092] Update the ispLUT table of the reference image ispy according to the parameter isp-m of the reference image ispy. Specifically, update the mapping relationship of the gray values less than isp-m in the ispLUT table of the reference image ispy to map the gray values less than isp-m to isp-m, that is, when i < isp-m, update the mapping relationship of i to: ispLut[i] = ispLut[isp-m];
[0093] Update the drcLUT table of the gain image drcy according to the parameter drc-m of the gain image drcy and the updated ispLUT table of the reference image ispy. Specifically, update the mapping relationship of the gray values less than drc-m in the drcLUT table of the gain image drcy to: map the gray values less than drc-m to the larger value of the mapped values in the drcLUT table and the ispLUT table, that is, when i < drc-m, update the mapping relationship of i to: drcLut[i] = Max(drcLut[i], ispLut[i]);
[0094] The mapping value of the grayscale value in the ispLUT table after the reference image ispy is updated is set to: the difference between the maximum bit width and the mapping value of the grayscale value, that is, the mapping relationship of i is updated to: ispLut[i]=MaxBitWidth-drcLut[i].
[0095] Optionally, the grayscale value i may be in the range of 0 to 1024.
[0096] Optionally, for the gain image, the grayscale value of each pixel point (x, y) is mapped according to the mapping value found in the drcLUT table as the weight value of the pixel point (x, y), that is: ispWeight[x, y] = ispLut[isp[x, y]], and the weight map drcweight1 is generated according to the weight values of each pixel point; for the reference image, the grayscale value of each pixel point (x, y) is mapped according to the mapping value found in the ispLUT table as the weight value of the pixel point (x, y), that is, drcWeight[x, y] = drcLut[drc[x, y]], and the weight map ispweight1 is generated according to the weight values of each pixel point.
[0097] Step 507: Gaussian filtering is performed on the weight map drcweight1 of the gain image drcy according to the Gaussian filtering parameters of the gain image drcy to obtain the weight map drcweight2; Gaussian filtering is performed on the weight map ispweight1 of the reference image isp according to the Gaussian filtering parameters of the reference image isp to obtain the weight map ispweight2 of the reference image ispy.
[0098] Optionally, before performing Gaussian filtering on the weight map drcweight1 and the weight map ispweight1, padding processing may be performed on the weight map drcweight1 and the weight map ispweight1 so that Gaussian filtering can be performed on the pixel points at the edge positions of the weight map drcweight1 and the weight map ispweight1.
[0099] This step is optional. By performing Gaussian filtering on the weight map, the accuracy of the weight map can be improved.
[0100] Step 508: construct a Gaussian pyramid T1 of the weight map drcweight2, construct a Laplacian pyramid L1 of the gain image drcy, construct a Gaussian pyramid T2 of the weight map ispweight2, and construct a Laplacian pyramid L2 of the reference image ispy.
[0101] The specific method of constructing the Gaussian pyramid and the Laplacian pyramid in this step is not limited in the embodiment of the present application. It should be noted that the information such as the number of layers of the constructed Gaussian pyramid 1, Gaussian pyramid 2, Laplacian pyramid 1, and Laplacian pyramid 2 is the same to complete the fusion processing in the subsequent steps.
[0102] Step 509: fusing Gaussian pyramid 1, Gaussian pyramid 2, Laplacian pyramid 1, and Laplacian pyramid 2 to obtain a fused pyramid, and fusing Gaussian pyramid 1 and Gaussian pyramid 2 to obtain a weighted pyramid.
[0103] Optionally, this step may include:
[0104] The Gaussian pyramid T1 and the Laplacian pyramid L1 are fused to obtain the primary fused pyramid F1;
[0105] The Gaussian pyramid T2 and the Laplacian pyramid L2 are fused to obtain a primary fused pyramid F2;
[0106] The primary fusion pyramid F1 and the primary fusion pyramid F2 are fused to obtain a secondary fusion pyramid F3.
[0107] Optionally, the Gaussian pyramid T1 and the Laplacian pyramid L1 are fused, which may specifically include:
[0108] The pixel values of the corresponding points of the Gaussian pyramid T1 and the Laplacian pyramid L1 are multiplied, and the product is used as the pixel value of the corresponding point in the primary fusion pyramid F1.
[0109] Optionally, the Gaussian pyramid T2 and the Laplacian pyramid L2 are fused, which may specifically include:
[0110] The pixel values of the corresponding points of the Gaussian pyramid 2 and the Laplacian pyramid 2 are multiplied, and the product is used as the pixel value of the corresponding point in the primary fusion pyramid 2.
[0111] Optionally, the primary fusion pyramid F1 and the primary fusion pyramid F2 are fused to obtain a fusion pyramid F3, which may specifically include:
[0112] The pixel values of the corresponding points of the primary fusion pyramid F1 and the primary fusion pyramid F2 are added together, and the obtained sum is used as the pixel value of the corresponding point in the fusion pyramid F3.
[0113] Optionally, the Gaussian pyramid T1 and the Gaussian pyramid T2 are fused to obtain the weight pyramid W1, which may specifically include:
[0114] The corresponding points of Gaussian pyramid T1 and Gaussian pyramid T2 are added together, and the obtained sum is used as the pixel value of the corresponding point in weight pyramid W1.
[0115] Step 510: Reconstruct the Laplacian pyramid according to the fusion pyramid F3 and the weight pyramid W1 to obtain a target image.
[0116] Optionally, this step may include:
[0117] Divide the pixel values of the corresponding points of the fusion pyramid F3 and the weighted pyramid W1, and use the quotient as the pixel value of the corresponding point in the target pyramid;
[0118] The target pyramid is upsampled layer by layer to obtain the target image.
[0119] Optionally, the target image may be an HDR image, which is used as an HDR image captured by a camera application.
[0120] Figure 5 In the method shown, a reference image isp in YUV format generated by a standard raw image is used to perform dynamic range calibration on the gain image to generate a target image. The standard raw image is a standard raw image in a multi-frame raw image used to generate the gain image, thereby improving the image quality and visual effect of the generated HDR image.
[0121] Figure 6 This is another structural diagram of an electronic device provided in an embodiment of the present application, including: a camera application, a camera HAL, a camera driver and a camera.
[0122] The camera HAL may include: a control module, an LDR image generation module, a dynamic range extension module, a format conversion module and a dynamic range calibration module.
[0123] The control module can be used to communicate with the camera application and the camera driver, and is also used to determine the exposure of the raw image taken by the camera, etc.
[0124] The LDR image generation module is used to generate LDR images based on multiple frames of raw images.
[0125] The dynamic range extension module is used to expand the dynamic range of the LDR image to obtain a gain image with a high dynamic range.
[0126] The format conversion module is used to convert the raw image into a reference image in YUV format.
[0127] The dynamic range calibration module is used to perform dynamic range calibration on the gain image using a reference image to obtain a target image.
[0128] Optionally, the electronic device can be connected to the computer by, for example, Figure 2When the Android system shown is implemented, the camera application can be located in the application layer of the electronic device, the camera HAL can be located in the HAL layer of the electronic device, the camera driver can be located in the kernel layer of the electronic device, and the camera can be located in the hardware layer of the electronic device. It should be noted that the above is only an example, and in different operating systems, the above structure and its layer can be adaptively changed, and the embodiments of the present application are not limited thereto.
[0129] Figure 7 The embodiment of the present application provides Figure 6 A flow chart of a method for calibrating the dynamic range of an image of the structure shown in FIG. Figure 7 As shown, the method may include:
[0130] Step 701: The camera application detects a photo-taking trigger operation.
[0131] Step 702: The camera application sends a photo-taking request to the control module in the camera HAL.
[0132] Step 703: The control module sends a photo taking instruction to the camera driver.
[0133] The shooting instructions can indicate the exposure required for shooting raw images.
[0134] Step 704: the camera driver receives the photo-taking instruction, drives the camera to take a raw image according to the exposure amount, obtains multiple frames of raw images, and sends the multiple frames of raw images to the control module.
[0135] Step 705: The control module sends multiple frames of raw images to the LDR image generation module.
[0136] Step 706: The LDR image generation module receives multiple frames of raw images, generates an LDR image according to the multiple frames of raw images, and sends the LDR image to the dynamic range extension module.
[0137] Step 707: The dynamic range extension module dynamically extends the LDR image to obtain an HDR gain image, and sends the HDR gain image to the dynamic range calibration module.
[0138] Step 708: The control module sends the normalraw image in the multiple frames of raw images to the format conversion module.
[0139] Step 709: The format conversion module converts the normalraw image into an image in YUV format, and sends the YUV image to the dynamic range calibration module.
[0140] There is no restriction on the execution order between steps 705 to 707 and steps 708 to 709.
[0141] Step 710: The dynamic range calibration module uses the reference image to perform dynamic range calibration on the gain image to obtain an HDR image.
[0142] The HDR image obtained here is also the target image mentioned above.
[0143] The implementation of this step may refer to the aforementioned steps 406 to 412.
[0144] The specific implementation of the dynamic range calibration module using the reference image to calibrate the dynamic range of the gain image can be referred to steps 506 to 511, which will not be described in detail here.
[0145] Step 711: The dynamic range calibration module sends the target image to the control module.
[0146] Step 712: The control module sends the HDR image to the camera application, and the camera application saves the HDR image as the captured image.
[0147] It should be noted that if the camera HAL is provided with an interface for the camera application to access the dynamic range calibration module, the dynamic range calibration module may also send the target image directly to the camera application without forwarding by the control module.
[0148] Fig. 8A The image shown is an image in a preview video displayed to the user by the image capture application. Figure 8B The image shown is an example of an HDR image without dynamic range adjustment. Figure 8C The image shown is an HDR image obtained after dynamic range adjustment. By comparison, the HDR image obtained after dynamic range adjustment does not have the problem of darkening, and the visual effect is closer to the image in the preview video, which solves the problem of large difference in brightness between the HDR image and the image in the preview video.
[0149] An embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the processor is used to implement the method provided in the embodiment of the present application.
[0150] The embodiment of the present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer executes the method provided by the embodiment of the present application.
[0151] The embodiment of the present application also provides a computer program product, which includes a computer program. When the computer program is run on a computer, it enables the computer to execute the method provided by the embodiment of the present application.
[0152] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0153] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0154] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0155] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk, and other media that can store program codes.
[0156] The above is only a specific implementation of the present application. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for calibrating the dynamic range of an image, characterized in that: include: Acquire a first image and a second image; The first image is a high dynamic range gain image, and the first image is obtained by performing dynamic range expansion on an LDR image generated according to multiple frames of raw images; The second image is an image in YUV format; The second image is generated according to a standard raw image; the standard raw image is a standard raw image in a raw image used to generate the first image; generating a first weight map for the first image and a second weight map for the second image; constructing a first image pyramid of the first image, a second image pyramid of the second image, a third image pyramid of the first weight map, and a fourth image pyramid of the second weight map; generating a target image according to the first image pyramid, the second image pyramid, the third image pyramid, and the fourth image pyramid, wherein the target image is a high dynamic range image; The step of generating a target image according to the first image pyramid, the second image pyramid, the third image pyramid and the fourth image pyramid includes: fusing the first image pyramid, the second image pyramid, the third image pyramid and the fourth image pyramid to obtain a first fused pyramid; fusing the third image pyramid and the fourth image pyramid to obtain a second fused pyramid; An image is reconstructed according to the first fused pyramid and the second fused pyramid to obtain the target image.
2. The method according to claim 1, characterized in that The generating a first weight map of the first image and a second weight map of the second image comprises: Determining a Gaussian filter parameter of the first image and a Gaussian filter parameter of the second image according to the exposure; Update a first lookup table for the first image and a second lookup table for the second image according to a Gaussian filter parameter of the first image and a Gaussian filter parameter of the second image; A first weight map of the first image is generated according to a first lookup table of the first image, and a second weight map of the second image is generated according to a second lookup table of the second image.
3. The method according to claim 2, characterized in that Before constructing the third image pyramid of the first weight map and the fourth image pyramid of the second weight map, the method further includes: Gaussian filtering is performed on the first weight map and the second weight map respectively.
4. The method according to claim 3, characterized in that Performing Gaussian filtering on the first weight map includes: Performing filling processing on the first weight map to obtain a filled first weight map; performing Gaussian filtering on the filled first weight map according to Gaussian filtering parameters of the first image; and / or, Performing Gaussian filtering on the second weight map includes: Performing a filling process on the second weight map to obtain a filled second weight map; Gaussian filtering is performed on the filled second weight map according to the Gaussian filtering parameters of the second image.
5. The method according to any one of claims 1 to 4, characterized in that: The fusing the first image pyramid, the second image pyramid, the third image pyramid and the fourth image pyramid to obtain a first fused pyramid includes: fusing the first image pyramid and the third image pyramid to obtain a third fused pyramid; fusing the second image pyramid and the fourth image pyramid to obtain a fourth fused pyramid; The third fused pyramid and the fourth fused pyramid are fused to obtain the first fused pyramid.
6. The method according to claim 5, characterized in that The fusing the first image pyramid and the third image pyramid to obtain a third fused pyramid includes: The product obtained by multiplying the pixel values of the corresponding points of the first image pyramid and the third image pyramid is used as the pixel value of the corresponding point of the third fused pyramid.
7. The method according to claim 5, characterized in that Fusing the third fused pyramid and the fourth fused pyramid to obtain the first fused pyramid includes: A sum of the pixel values of the corresponding points of the third fused pyramid and the fourth fused pyramid is used as the pixel value of the corresponding point of the first fused pyramid.
8. The method according to any one of claims 1 to 4, characterized in that: The obtaining of the first image and the second image comprises: Receiving a first operation from a user; In response to the first operation, driving the camera to capture multiple frames of raw images; the multiple frames of raw images have different exposure amounts; Generate the first image according to the multiple frames of raw images; The second image is generated according to a standard raw image among the multiple frames of raw images.
9. An electronic device, characterized in that: include: Processor, memory; One or more computer programs are stored in the memory, and the one or more computer programs include instructions, which, when executed by the processor, enable the electronic device to perform the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed on a computer, enables the computer to execute the method according to any one of claims 1 to 8.
