Contrast adjustment methods, computer program products, electronic devices and storage media
By splitting the image into multiple frames and performing HDR fusion, the problem of insufficient dynamic range and detail in existing technologies is solved, thereby improving image detail and dynamic range.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING JIGAN TECH CO LTD
- Filing Date
- 2021-11-30
- Publication Date
- 2026-06-30
AI Technical Summary
Existing contrast enhancement algorithms produce images with low dynamic range and low detail.
The image to be adjusted is split into multiple frames and then fused using a high dynamic range fusion (HDR fusion) method to improve the dynamic range and detail of the image.
HDR fusion significantly improves the dynamic range and detail of images, resulting in fused images with both high detail and dynamic range.
Smart Images

Figure CN116205796B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and more specifically, to a contrast adjustment method, a computer program product, an electronic device, and a storage medium. Background Technology
[0002] Due to the characteristics of remote sensing imaging systems, lighting conditions during imaging, and the magnitude of radiation differences between ground objects within the image frame, the pixel values of most pixels in digital images are often concentrated in a relatively narrow dynamic range. This results in small contrast differences and a monotonous color tone. Therefore, contrast enhancement algorithms can be used to process the images. These algorithms are methods that improve the contrast of a single frame of an image by processing it with software algorithms.
[0003] In existing technologies, traditional image contrast enhancement algorithms such as Contrast Limited Adaptive Histogram Equalization (CLAHE), Adaptive Histogram Equalization (AHE), and Adaptive Contrast Enhancement (ACE) are generally used. However, the dynamic range and detail of the images obtained using these existing contrast enhancement algorithms are relatively low. Summary of the Invention
[0004] The purpose of this application is to provide a contrast adjustment method, computer program product, electronic device and storage medium to solve the technical problem that the dynamic range and detail of the resulting image obtained by the contrast enhancement algorithm in the prior art are both low.
[0005] In a first aspect, embodiments of this application provide a contrast adjustment method, comprising: acquiring an image to be adjusted; splitting the image to be adjusted into multiple frame-by-frame images; wherein each frame-by-frame image represents the result of image acquisition of a scene in the image to be adjusted at its corresponding exposure level or exposure time; performing HDR fusion on the multiple frame-by-frame images to obtain a fused image; and determining a first result image after contrast adjustment based on the fused image. In the above scheme, by splitting the image to be adjusted so that the resulting multiple frame-by-frame images represent the result of image acquisition at a single exposure level, an HDR fusion method can be used to fuse the multiple frame-by-frame images. Since HDR fusion can improve both the detail and dynamic range of the image, the fused image has a higher dynamic range and detail, and a first result image with a higher dynamic range and detail can be further determined based on the fused image.
[0006] In an optional implementation, splitting the image to be adjusted into multiple split images includes: splitting the image to be adjusted into N preliminary split images according to N-1 splitting thresholds, wherein the pixel values in each preliminary split image are distributed within a corresponding interval, and the N intervals corresponding to the N preliminary split images cover the actual pixel value range of the image to be adjusted; wherein N>1, and N is the total number of split images; mapping the pixel values in the N preliminary split images to obtain N split images; wherein the actual pixel value range of each split image is the same as the actual pixel value range of the image to be adjusted. In the above scheme, the image to be adjusted can be split based on N-1 splitting thresholds, and the pixel values in the split preliminary images can be mapped, thereby improving the dynamic range of the split images and thus improving the dynamic range of the first result image.
[0007] In an optional implementation, splitting the image to be adjusted into multiple split images includes: splitting the image to be adjusted into M+1 preliminary split images according to M splitting thresholds, wherein the pixel values in each preliminary split image are distributed within a corresponding interval, and the M+1 intervals corresponding to the M+1 preliminary split images cover the actual pixel value range of the image to be adjusted; wherein P-1 > M ≥ 1, and P is the total number of split images; mapping the pixel values in the M+1 preliminary split images to obtain M+1 intermediate images; wherein the actual pixel value range of each intermediate image is the same as the actual pixel value range of the image to be adjusted; interpolating PM-1 interpolated images between the M+1 intermediate images to obtain a total of P split images composed of the intermediate images and the interpolated images. In the above scheme, the image to be adjusted can be split by combining M splitting thresholds and interpolation, and the pixel values in the split preliminary images can be mapped to improve the dynamic range of the split images, thereby improving the dynamic range of the first result image.
[0008] In an optional implementation, the step of interpolating and calculating a PM-1 frame interpolated image between the intermediate images of the M+1 frames to obtain a total P-frame split image composed of the intermediate images and the interpolated images includes: using the intermediate images of the M+1 frames as the M+1 frame split image, calculating the mean image of two adjacent frame split images according to the interpolation calculation order, and inserting the calculated mean image between two adjacent frame split images as a new split image, until the P-frame split image is obtained. In the above scheme, by calculating the average frame of two adjacent frames as the interpolation frame, the transition between the final multi-frame split images is smooth, thereby improving the detail of the fused image obtained after HDR fusion.
[0009] In an optional implementation, obtaining the image to be adjusted includes: obtaining an original image; reducing the size of the original image to obtain the image to be adjusted. In the above scheme, after obtaining the original image, the original image can be reduced in size, and the reduced image to be adjusted can be split and merged, thereby reducing the computational load of the algorithm.
[0010] In an optional implementation, reducing the size of the original image to obtain the image to be adjusted includes: reducing the size of the original image multiple times to obtain the image to be adjusted. In the above scheme, during the process of reducing the size of the original image, multiple reductions can be performed to gradually reduce the original image to the image to be adjusted. During the successive reduction process, as much detail in the original image as possible can be preserved, thereby improving the detail of the fused image obtained after HDR fusion.
[0011] In an optional implementation, determining the contrast-adjusted first result image based on the fused image includes: determining the first result image based solely on the fused image; or, determining the first result image based on the fused image, the original image, and the image to be adjusted; wherein the image to be adjusted is an image obtained by downscaling the original image; or, determining the first result image based on the fused image and the image to be adjusted. In the above schemes, when the image to be adjusted is equivalent to the original image, the fused image can be directly determined as the first result image, or the first result image can be determined based on the fused image and the image to be adjusted; when the image to be adjusted is an image obtained by downscaling the original image, the first result image can be determined jointly based on the fused image, the original image, and the image to be adjusted, thereby improving the detail of the first result image.
[0012] In an optional implementation, determining the first result image based on the fused image, the original image, and the image to be adjusted includes: enlarging the fused image to obtain an enlarged fused image, and enlarging the image to be adjusted to obtain an enlarged image to be adjusted; wherein the enlarged fused image and the enlarged image to be adjusted have the same size as the original image; determining a contrast adjustment ratio based on the enlarged fused image and the enlarged image to be adjusted; and mapping the pixel values in the original image according to the contrast adjustment ratio to obtain the first result image. In the above scheme, when the image to be adjusted is an image obtained by shrinking the original image, the fused image and the image to be adjusted can be enlarged, and a contrast adjustment ratio can be determined based on the enlarged fused image and the image to be adjusted. Then, by adjusting the contrast ratio and the original image with complete details, a first result image with high detail can be obtained.
[0013] In an optional implementation, after determining the contrast-adjusted first result image based on the fused image, the method further includes: determining a specular mask corresponding to the original image; and fusing the original image and the first result image based on the specular mask to obtain a second result image. In the above scheme, the original image and the first result image can be fused based on the specular mask, thereby adaptively adjusting the brightness of certain regions in the first result image to obtain a second result image with better performance.
[0014] In an optional implementation, determining the specular mask corresponding to the original image includes: setting the pixel values of pixels in the original image whose pixel values are greater than a specular threshold to 1, and setting the pixel values of pixels in the original image whose pixel values are less than or equal to the specular threshold to 0, thereby obtaining the fusion mask; fusing the original image and the first result image according to the specular mask to obtain a second result image includes: for each pixel in the second result image, if the pixel value of its corresponding pixel in the specular mask is 1, then the pixel value of that pixel is determined to be the pixel value of its corresponding pixel in the original image; and if the pixel value of its corresponding pixel in the specular mask is 0, then the pixel value of that pixel is determined to be the pixel value of its corresponding pixel in the first result image. In the above scheme, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused using a specular mask to determine the pixel values of the highlight areas to be the pixel values of the corresponding pixels in the original image, thereby ensuring the brightness of the highlight areas.
[0015] In an optional implementation, fusing the original image and the first result image according to the specular mask to obtain a second result image includes: weighting the corresponding pixel values in the original image and the first result image according to the specular mask to obtain the second result image; wherein, the pixel values in the specular mask represent the fusion weights of the corresponding pixel values in the original image, and the pixel values in the specular mask are positively correlated with the corresponding pixel values in the original image, and the sum of the fusion weights of the pixel values in the original image and the fusion weights of the corresponding pixel values in the first result image is a fixed value. In the above scheme, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused using a specular mask. Pixels with higher pixel values have a larger proportion of pixel values in the original image, thereby ensuring the brightness of the highlight areas.
[0016] Secondly, embodiments of this application provide a contrast adjustment device, comprising: an acquisition module for acquiring an image to be adjusted; a splitting module for splitting the image to be adjusted into multiple split images; wherein each split image represents the result of image acquisition of a scene in the image to be adjusted at its corresponding exposure level or exposure time; a first fusion module for performing HDR fusion on the multiple split images to obtain a fused image; and a first determination module for determining a first result image after contrast adjustment based on the fused image. In the above scheme, by splitting the image to be adjusted so that the resulting multiple split images represent the result of image acquisition at a single exposure level, an HDR fusion method can be used to fuse the multiple split images. Since HDR fusion can improve both the detail and dynamic range of the image, the fused image has a higher dynamic range and detail, and a first result image with a higher dynamic range and detail can be further determined based on the fused image.
[0017] In an optional implementation, the splitting module is specifically used to: split the image to be adjusted into N preliminary split images according to N-1 splitting thresholds, wherein the pixel values in each preliminary split image are distributed within a corresponding interval, and the N intervals corresponding to the N preliminary split images cover the actual pixel value range of the image to be adjusted; wherein N>1, and N is the total number of split images; and map the pixel values in the N preliminary split images to obtain N split images; wherein the actual pixel value range of each split image is the same as the actual pixel value range of the image to be adjusted. In the above scheme, the image to be adjusted can be split based on N-1 splitting thresholds, and the pixel values in the split preliminary images can be mapped, thereby improving the dynamic range of the split images and thus improving the dynamic range of the first result image.
[0018] In an optional implementation, the splitting module is specifically used to: split the image to be adjusted into M+1 preliminary split images according to M splitting thresholds, wherein the pixel values in each preliminary split image are distributed within a corresponding interval, and the M+1 intervals corresponding to the M+1 preliminary split images cover the actual pixel value range of the image to be adjusted; wherein, P-1 > M ≥ 1, and P is the total number of split images; map the pixel values in the M+1 preliminary split images to obtain M+1 intermediate images; wherein the actual pixel value range of each intermediate image is the same as the actual pixel value range of the image to be adjusted; interpolate and calculate PM-1 interpolated images between the M+1 intermediate images to obtain a total of P split images composed of the intermediate images and the interpolated images. In the above scheme, the image to be adjusted can be split by combining M splitting thresholds and interpolation, and the pixel values in the split preliminary images can be mapped to improve the dynamic range of the split images, thereby improving the dynamic range of the first result image.
[0019] In an optional implementation, the splitting module is further configured to: use the intermediate image of the M+1 frame as the M+1 frame splitting image, calculate the mean image of two adjacent frame splitting images according to the interpolation calculation order, and insert the calculated mean image between two adjacent frame splitting images as a new splitting image, until the P frame splitting image is obtained. In the above scheme, by calculating the average frame of two adjacent frames as the interpolation frame, the transition between the final multi-frame splitting images is smooth, thereby improving the detail of the fused image obtained after HDR fusion.
[0020] In an optional implementation, the acquisition module is specifically used to: acquire the original image; and reduce the size of the original image to obtain the image to be adjusted. In the above scheme, after acquiring the original image, the original image can be reduced in size, and the reduced image to be adjusted can be split and merged, thereby reducing the computational load of the algorithm.
[0021] In an optional implementation, the acquisition module is further configured to: reduce the original image multiple times to obtain the image to be adjusted. In the above scheme, the process of reducing the original image can be repeated multiple times, gradually reducing the original image to the size of the image to be adjusted. During this successive reduction process, details in the original image can be preserved as much as possible, thereby improving the details of the fused image obtained after HDR fusion.
[0022] In an optional implementation, the first determining module is specifically used to: determine the first result image based solely on the fused image; or, determine the first result image based on the fused image, the original image, and the image to be adjusted; wherein the image to be adjusted is an image obtained by downscaling the original image; or, determine the first result image based on the fused image and the image to be adjusted. In the above scheme, when the image to be adjusted is equivalent to the original image, the fused image can be directly determined as the first result image, or the first result image can be determined based on the fused image and the image to be adjusted; when the image to be adjusted is an image obtained by downscaling the original image, the first result image can be determined jointly based on the fused image, the original image, and the image to be adjusted, thereby improving the detail of the first result image.
[0023] In an optional implementation, the first determining module is further configured to: enlarge the fused image to obtain an enlarged fused image, and enlarge the image to be adjusted to obtain an enlarged image to be adjusted; wherein the enlarged fused image and the enlarged image to be adjusted have the same size as the original image; determine a contrast adjustment ratio based on the enlarged fused image and the enlarged image to be adjusted; and map the pixel values in the original image according to the contrast adjustment ratio to obtain the first result image. In the above scheme, when the image to be adjusted is an image obtained by shrinking the original image, the fused image and the image to be adjusted can be enlarged, and a contrast adjustment ratio can be determined based on the enlarged fused image and the image to be adjusted. Then, by adjusting the contrast ratio and the original image with complete details, a first result image with higher details can be obtained.
[0024] In an optional embodiment, the contrast adjustment device further includes: a second determining module for determining the specular mask corresponding to the original image; and a second fusing module for fusing the original image and the first result image according to the specular mask to obtain a second result image. In the above scheme, the original image and the first result image can be fused based on the specular mask, thereby adaptively adjusting the brightness of certain areas in the first result image to obtain a second result image with better performance.
[0025] In an optional implementation, the second determining module is specifically used to: determine the pixel values of pixels in the original image whose pixel values are greater than the highlight threshold as 1, and determine the pixel values of pixels in the original image whose pixel values are less than or equal to the highlight threshold as 0, thereby obtaining the highlight mask; the step of fusing the original image and the first result image according to the highlight mask to obtain a second result image includes: for each pixel in the second result image, if the pixel value of its corresponding pixel in the highlight mask is 1, then the pixel value of that pixel is determined to be the pixel value of its corresponding pixel in the original image; and if the pixel value of its corresponding pixel in the highlight mask is 0, then the pixel value of that pixel is determined to be the pixel value of its corresponding pixel in the first result image. In the above scheme, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused using a highlight mask to determine the pixel values of the highlight areas to be the pixel values of the corresponding pixels in the original image, thereby ensuring the brightness of the highlight areas.
[0026] In an optional implementation, the second fusion module is specifically used to: weight the corresponding pixel values in the original image and the first result image according to the specular mask to obtain the second result image; wherein, the pixel values in the specular mask represent the fusion weights of the corresponding pixel values in the original image, and the pixel values in the specular mask are positively correlated with the corresponding pixel values in the original image, and the sum of the fusion weights of the pixel values in the original image and the fusion weights of the corresponding pixel values in the first result image is a fixed value. In the above scheme, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused using a specular mask. The higher the pixel value, the larger the proportion of the pixel value in the original image, thereby ensuring the brightness of the highlight areas.
[0027] Thirdly, embodiments of this application provide a computer program product, including: computer program instructions, which are read and executed by a processor to perform the method described in the first aspect.
[0028] Fourthly, embodiments of this application provide an electronic device, including: a processor, a memory, and a bus; the processor and the memory communicate with each other via the bus; the memory stores computer program instructions executable by the processor, and the processor can execute the method described in the first aspect by calling the computer program instructions.
[0029] Fifthly, embodiments of this application provide a computer-readable storage medium that stores computer program instructions, which, when executed by a computer, cause the computer to perform the method described in the first aspect.
[0030] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, embodiments of this application are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0031] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0032] Figure 1 A flowchart illustrating a contrast adjustment method provided in an embodiment of this application;
[0033] Figure 2 A structural block diagram of a contrast adjustment device provided in an embodiment of this application;
[0034] Figure 3 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0035] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0036] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating a contrast adjustment method provided in an embodiment of this application, which is applied to an electronic device. Specifically, the contrast adjustment method provided in this embodiment may include the following:
[0037] Step S101: Obtain the image to be adjusted.
[0038] Step S102: Divide the image to be adjusted into multiple split images; wherein each split image represents the result of image acquisition of the scene in the image to be adjusted under its corresponding exposure amount or exposure time.
[0039] Step S103: Perform HDR fusion on the multi-frame split images to obtain a fused image.
[0040] Step S104: Determine the first result image after contrast adjustment based on the fused image.
[0041] Specifically, the image to be adjusted is the image that requires contrast adjustment. As one implementation, the image to be adjusted can be the original image acquired by the electronic device. For example, the image to be adjusted can be an image acquired by an image acquisition module on the electronic device, and the electronic device can directly perform contrast adjustment on the acquired image; or, the image to be adjusted can be an image received by the electronic device, and the electronic device can directly perform contrast adjustment on the received image, etc.
[0042] It is understood that the electronic device can receive images sent by external devices (e.g., another electronic device, an image acquisition device, etc.) or read images stored in the cloud. This application does not impose specific limitations on this, and those skilled in the art can make appropriate adjustments according to the actual situation.
[0043] As another implementation, the image to be adjusted can be the image obtained by the electronic device after acquiring the original image and preprocessing it. For example, after the image acquisition module on the electronic device acquires an image, it first preprocesses the acquired image and then performs subsequent processing such as contrast adjustment on the preprocessed image; or, after the electronic device receives an image, it first preprocesses the received image and then performs subsequent processing such as contrast adjustment on the preprocessed image, etc.
[0044] It is understood that the preprocessing of images by electronic devices may include scaling the image, cropping the image, etc. The embodiments of this application do not impose specific limitations on this, and those skilled in the art can make appropriate adjustments according to the actual situation.
[0045] As another implementation method, the electronic device can also simultaneously acquire the original image and the image to be adjusted obtained after preprocessing the original image, and then directly perform subsequent processing such as contrast adjustment on the image to be adjusted.
[0046] After acquiring the image to be adjusted, the electronic device can split the image into multiple frames. During the splitting process, since subsequent High-Dynamic Range (HDR) fusion is required on these multiple frames, the splitting method should be set according to the principle of HDR fusion (HDR fusion is used to fuse images acquired at different exposure levels, such as EV-1, EV0, EV1, etc.) so that each frame of the resulting multi-frame split image can represent the result of image acquisition of the scene in the image to be adjusted at its corresponding exposure level or exposure time. The specific splitting method will be described in detail in subsequent embodiments and will not be discussed here.
[0047] Next, the electronic device can perform HDR fusion, fusing the multi-frame split images obtained above to obtain a corresponding fused image. Since HDR fusion can enhance image detail and dynamic range, it can produce a fused image with both high detail and dynamic range. As one implementation method, multi-exposure fusion, an HDR fusion method, can be used to fuse the multi-frame split images.
[0048] It is understood that multi-exposure fusion is merely an example of an HDR fusion method provided in this application embodiment. Those skilled in the art can adopt other HDR fusion methods according to actual circumstances, and this application embodiment does not make specific limitations on this.
[0049] Finally, the electronic device can determine the first result image after contrast adjustment based on the fused image. It can be understood that, as one implementation, when the image to be adjusted in step S101 is the original image acquired by the electronic device, the electronic device can directly determine the fused image as the first result image; as another implementation, when the image to be adjusted in step S101 is an image obtained after preprocessing the original image, the electronic device can perform certain processing on the fused image to obtain the first result image.
[0050] In the above scheme, the image to be adjusted is split into multiple frames, each representing the result of image acquisition at a certain exposure level. This allows for the fusion of these multiple frames using an HDR fusion method. Since HDR fusion enhances both image detail and dynamic range, the fused image exhibits high dynamic range and detail. Based on this fused image, a first result image with high dynamic range and detail can then be determined.
[0051] Furthermore, as described in the above embodiments, this application provides multiple methods for splitting the image to be adjusted. Among these, this application mainly introduces two splitting methods.
[0052] The first method directly splits the image to be adjusted into multi-frame images based on multiple splitting thresholds. In this method, step S102 may specifically include the following:
[0053] Step (1): The image to be adjusted is divided into N preliminary split images according to N-1 split thresholds. The pixel values in each preliminary split image are distributed in a corresponding interval. The N intervals corresponding to the N preliminary split images cover the actual pixel value range of the image to be adjusted.
[0054] Step (2) maps the pixel values in the N-frame initial split images to obtain N-frame split images; wherein the actual pixel value range of each split image is the same as the actual pixel value range of the image to be adjusted.
[0055] Specifically, assuming N is the total number of images to be split (N>1), the images to be adjusted can be split based on N-1 splitting thresholds. The specific size of the splitting thresholds is not specifically limited in this embodiment. As one implementation, the size of the splitting thresholds can be pre-set; as another implementation, the size of the splitting thresholds can be determined in real time by the electronic device according to the application scenario.
[0056] Understandably, the value of N can be preset according to requirements. The larger N is, the higher the accuracy of the contrast adjustment result, but the greater the computational load; while the smaller N is, the less computation the contrast adjustment result, but the lower the accuracy. Therefore, those skilled in the art can flexibly adjust the value of N according to the actual situation.
[0057] Furthermore, this application does not impose specific limitations on the size relationship between the N-1 splitting thresholds. The N-1 splitting thresholds can be uniformly increasing, for example, the splitting thresholds are 5, 10, 15...; or, the N-1 splitting thresholds can be non-uniformly increasing, for example, the splitting thresholds are 5, 15, 20...; or, the N-1 splitting thresholds may not be increasing.
[0058] Based on the aforementioned N-1 splitting thresholds, the image to be adjusted can be split into N preliminary split images. The pixel values in each preliminary split image are distributed within a corresponding interval, and the N intervals corresponding to the N preliminary split images cover the actual pixel value range of the image to be adjusted. It can be understood that the N intervals corresponding to the N preliminary split images covering the actual pixel value range of the image to be adjusted mean that the union of these N intervals equals the actual pixel value range of the image to be adjusted. For example, if the actual pixel value range of the image to be adjusted is 0-255, then the union of the N intervals corresponding to the N preliminary split images will also be 0-255.
[0059] In one implementation, the size of the intervals corresponding to the pixel values in the N-frame initially split image can be equal, for example, all being 5. In some cases, the N-1 splitting thresholds can just evenly divide the range of pixel values. In another implementation, the size of the intervals corresponding to the pixel values in the N-frame initially split image can also be unequal, for example, some intervals are 5 and some intervals are 10.
[0060] For example, if the range of pixel values in the image to be adjusted is 0-255, and the N-1 splitting thresholds are uniformly increasing (5, 10, 15...), and the interval sizes corresponding to the pixel values in the N initially split images are equal, then the intervals corresponding to the pixel values in the N initially split images are [0,5], [5,10], [10,15]...[250,255]. Correspondingly, the splitting process can be as follows: For the first initially split image, set the pixel values of pixels with values greater than 5 to 5, and retain the original pixel values of pixels with values less than 5; for the second initially split image, set the pixel values of pixels with values less than 5 to 5, set the pixel values of pixels with values greater than 10 to 10, and retain the original pixel values of pixels with values greater than 5 and less than 10...
[0061] For example, if the range of pixel values in the image to be adjusted is 0-255, and the N-1 splitting thresholds are non-uniformly increasing, namely 5, 15, 20..., and the size of the intervals corresponding to the pixel values in the N initial splitting images is not equal, then the intervals corresponding to the pixel values in the N initial splitting images are [0,5], [5,15], [15,20]...[245,255].
[0062] As can be seen, in the two examples above, the intervals corresponding to the pixel values in the N-frame initially segmented images do not overlap. It is understood that the intervals corresponding to the pixel values in the N-frame initially segmented images may also overlap; however, this embodiment will not be described in detail here, and those skilled in the art can make appropriate adjustments based on the above scheme.
[0063] After the image to be adjusted is split, the dynamic range of each initially split image is different because the pixel values of each frame correspond to different ranges. To improve the dynamic range of the initially split images, the pixel values of the initially split images can be mapped to expand the actual pixel value range of the pixel values in the initially split images to the actual pixel value range of the pixel values in the image to be adjusted, resulting in N frames of split images.
[0064] Since the pixel value range of each initially segmented image is different during the segmentation process, similar to images acquired under different exposure levels, the segmented image obtained from the initially segmented image can represent the result of image acquisition of the scene in the image to be adjusted under a corresponding exposure level.
[0065] Taking the first example above, the pixel values in the initially split N frames of the image correspond to the intervals [0,5], [5,15], [15,20]...[245,255], respectively. Each of these intervals can be mapped to the range [0,255]. For example: multiply each pixel value in the first interval by 51, subtract 5 from each pixel value in the second interval and multiply by 25.5... subtract 245 from each pixel value in the last interval and multiply by 25.5.
[0066] In the above scheme, the image to be adjusted can be split based on N-1 splitting thresholds, and the pixel values in the initially split images can be mapped to improve the dynamic range of the split images, thereby improving the dynamic range of the first result image.
[0067] The second method first divides the image to be adjusted into multiple preliminary split images based on multiple splitting thresholds, and then interpolates these preliminary split images to obtain the final multi-frame split image. In this method, step S102 may specifically include the following:
[0068] Step (1): The image to be adjusted is divided into M+1 preliminary split images according to M split thresholds. The pixel values in each preliminary split image are distributed in a corresponding interval. The M+1 intervals corresponding to the M+1 preliminary split images cover the actual pixel value range of the image to be adjusted.
[0069] Step (2) Map the pixel values in the initial split image of frame M+1 to obtain the intermediate image of frame M+1; wherein the actual pixel value range of each intermediate image is the same as the actual pixel value range of the image to be adjusted.
[0070] Step (3) interpolates the PM-1 frame interpolation image between the intermediate images of frame M+1 to obtain a total P-frame split image composed of the intermediate images and the interpolation images.
[0071] Specifically, assuming P is the total number of images to be split (P>1), the images to be adjusted can be split based on M splitting thresholds (P-1>M≥1). It can be seen that, unlike the previous embodiment, in this splitting method, the number of initially split images obtained according to the splitting thresholds is not the same as the number of images to be split. The number of initially split images is M+1 frames, while the number of images to be split is P frames.
[0072] It is understood that, similar to the previous embodiment, this application embodiment does not specifically limit the specific size of the splitting threshold and the size relationship between P-1 splitting thresholds. Those skilled in the art can make appropriate adjustments according to the actual situation.
[0073] Based on the aforementioned M splitting thresholds, the image to be adjusted can be split into M+1 preliminary split images. The pixel values in each preliminary split image are distributed within a corresponding interval, and the M+1 intervals corresponding to the M+1 preliminary split images cover the actual pixel value range of the image to be adjusted. It can be understood that the M+1 intervals corresponding to the M+1 preliminary split images covering the actual pixel value range of the image to be adjusted means that the union of these M+1 intervals equals the actual pixel value range of the image to be adjusted. For example, if the actual pixel value range of the image to be adjusted is 0-255, then the union of the M+1 intervals corresponding to the resulting M+1 preliminary split images will also be 0-255.
[0074] The specific implementation of the interval size corresponding to the pixel value in the initial split image of frame M+1 is similar to that of the interval size corresponding to the pixel value in the initial split image of frame P. Therefore, this application embodiment will not repeat the details.
[0075] After the image to be adjusted is split, the dynamic range of each initially split image is different because the pixel values of each initially split image have different ranges. In order to improve the dynamic range of the initially split images, the pixel values of the initially split images can be mapped to expand the actual pixel value range of the pixel values in the initially split images to the actual pixel value range of the pixel values in the image to be adjusted, thus obtaining the M+1 frame intermediate image.
[0076] After splitting and mapping the image to be adjusted, since the number of intermediate images in frame M+1 is still insufficient to meet the required number of split images (M+1 < P), interpolation can be used to expand the intermediate images in frame M+1 into split images in frame P. That is, based on the intermediate images in frame M+1, interpolated images in frame PM-1 are inserted to obtain a total of P split images composed of intermediate images and interpolated images.
[0077] There are various interpolation methods, and this application does not specifically limit the specific implementation method of interpolation. For example, interpolation can be performed by calculating the mean image of multiple intermediate images as the interpolation image; or, interpolation can be performed by randomly selecting multiple intermediate images as the interpolation image, etc.
[0078] In the above scheme, the image to be adjusted can be split by combining M splitting thresholds and interpolation, and the pixel values in the initial split image can be mapped to improve the dynamic range of the split image, thereby improving the dynamic range of the first result image.
[0079] The following describes a specific implementation of interpolation, namely, the steps described above for interpolating and calculating the interpolated image of frame PM-1 between the intermediate images of frame M+1 to obtain a total of P-frame split images composed of the intermediate images and the interpolated images. Specifically, it may include the following:
[0080] Step (1): Take the middle image of frame M+1 as the split image of frame M+1. Calculate the mean image of the split images of two adjacent frames according to the interpolation calculation order. Insert the calculated mean image between the split images of two adjacent frames as a new split image until the split image of frame P is obtained.
[0081] Specifically, using the intermediate image of frame M+1 as a base, the mean image of two adjacent split images is calculated according to a certain interpolation calculation order, and used as an interpolated image. This interpolated image is then inserted between the two adjacent split images to form a new split image. This process is repeated until the number of split images reaches P frames.
[0082] In this application, the specific implementation of the interpolation calculation order is not specifically limited. As one implementation, the electronic device can simultaneously calculate the mean image of multiple frames and insert the mean image. In this case, the interpolation calculation order can refer to which frames of split images are calculated as mean images. For example, assuming there are currently 5 split images and 7 split images are required, the interpolation calculation order can be specified as follows: calculate the mean image of the first and second split images and insert it between the first and second split images; calculate the mean image of the fourth and fifth split images and insert it between the fourth and fifth split images, thereby obtaining 7 split images.
[0083] Of course, there might be a situation where the number of split images after the first round of calculation still doesn't reach P frames. In this case, the next round of calculation can be performed based on the new split images obtained from the previous round. For example, assuming there are currently 5 split images and 8 split images are required, the interpolation calculation order can be specified as follows: calculate a mean image between the first and second split images and insert it between the first and second split images; calculate a mean image between the fourth and fifth split images and insert it between the fourth and fifth split images, thus obtaining 7 split images; then, the interpolation calculation order specifies that a mean image is calculated again based on the first and second split images in the new 7 split images and inserted between the first and second split images to obtain 8 split images.
[0084] As another implementation, the electronic device can calculate and insert the mean image of only one frame at a time. In this case, the interpolation calculation order can refer to the order in which the mean images are calculated. For example, assuming there are currently 2 split images and 6 split images are required, the interpolation calculation order can be specified as follows: First, calculate the mean image of the two split images and insert it between the two split images to obtain 3 split images; then, calculate the mean image of the first and second split images and insert it between the first and second split images to obtain 4 split images; next, calculate the mean image of the third and fourth split images and insert it between the third and fourth split images to obtain 5 split images; finally, calculate the mean image of the first and second split images and insert it between the first and second split images to obtain 6 split images.
[0085] It is understood that the interpolation calculation order can be preset or randomly generated by the electronic device, and this application embodiment does not impose any specific limitations on this.
[0086] It should be noted that during the interpolation process, depending on the different interpolation calculation order, the number of interpolated images calculated may be more than the number of images that actually need to be interpolated (for example, the number of images that need to be interpolated is 4, while the number of interpolated difference images calculated is 5). In this case, one frame of interpolated image can be discarded.
[0087] In the above scheme, the average frame of two adjacent frames can be calculated as the interpolation frame, so that the transition between the final multi-frame split images is smooth, thereby improving the details of the fused image obtained after HDR fusion.
[0088] Furthermore, as described in the above embodiments, this application provides multiple methods for acquiring an image to be adjusted. When the image to be adjusted acquired by the electronic device is an image obtained after scaling down the original image, step S101 may specifically include the following:
[0089] Step (1): Obtain the original image.
[0090] Step (2) reduces the size of the original image to obtain the image to be adjusted.
[0091] Specifically, a scaling factor can be preset, and then the original image can be reduced in size based on the scaling factor. This application does not impose specific limitations on the specific implementation method for reducing the original image; for example, bilinear interpolation can be used; or, random pixel discarding can be used, etc. Those skilled in the art can make appropriate adjustments according to the actual situation.
[0092] One implementation method is to scale the original image to the image to be adjusted in one step. Another implementation method is to scale the original image multiple times to obtain the image to be adjusted. For example, assuming a scaling factor of 8, the original image can be scaled down by a factor of 2 first, then by a factor of 2 again, then by a factor of 2 a third time, and finally by a factor of 2 a fourth time, resulting in an image to be adjusted that is scaled down by a factor of 8.
[0093] Therefore, in the process of reducing the size of the original image, multiple reductions can be performed to gradually shrink the original image to the size of the image to be adjusted. During this successive reduction process, as much detail as possible in the original image can be preserved, thereby improving the detail of the fused image obtained after HDR fusion.
[0094] In the above scheme, after obtaining the original image, the original image can be reduced in size, and the reduced image to be adjusted can be split and merged, thereby reducing the computational load of the algorithm.
[0095] Furthermore, as described in the above embodiments, the specific implementation method for determining the first result image varies depending on the image to be adjusted acquired by the electronic device. That is, step S104 may specifically include the following:
[0096] Step (1): Determine the first result image based solely on the fused image; or, determine the first result image based on the fused image, the original image, and the image to be adjusted; or, determine the first result image based on the fused image and the image to be adjusted.
[0097] Specifically, when the image to be adjusted in step S101 is the original image obtained by the electronic device, the electronic device can directly determine the fused image as the first result image. The specific implementation method for determining the first result image in this case will not be described in detail in this application embodiment.
[0098] Alternatively, when the image to be adjusted in step S101 is the original image acquired by the electronic device, the electronic device can also determine the first result image based on the fused image and the image to be adjusted. For example, a corresponding specular mask can be calculated based on the image to be adjusted, and the first result image can be determined based on the specular mask and the fused image. The implementation method of calculating the specular mask based on the image to be adjusted is similar to the implementation method of calculating the specular mask based on the image to be adjusted, which will be described in subsequent embodiments, and will not be described here.
[0099] When the image to be adjusted in step S101 is the image obtained after preprocessing the original image, the electronic device can determine the first result image based on the fused image, the original image, and the image to be adjusted obtained after scaling down the original image.
[0100] It is understandable that when the image to be adjusted in step S101 is an image obtained after preprocessing the original image, the electronic device can directly determine the fused image as the first result image. In the above scheme, when the image to be adjusted is equivalent to the original image, the fused image can be directly determined as the first result image. When the image to be adjusted is an image obtained by scaling down the original image, the first result image can be determined based on the fused image, the original image, and the image to be adjusted, thereby improving the detail of the first result image.
[0101] The following is a detailed description of a specific implementation method for an electronic device to determine a first result image based on a fused image, an original image, and an image to be adjusted. The steps for determining the first result image based on the fused image, the original image, and the image to be adjusted may specifically include the following:
[0102] Step (1) enlarge the fused image to obtain an enlarged fused image, and enlarge the image to be adjusted to obtain an enlarged image to be adjusted; wherein the enlarged fused image and the enlarged image to be adjusted are the same size as the original image.
[0103] Step (2): Determine the contrast adjustment ratio based on the magnified fused image and the magnified image to be adjusted.
[0104] Step (3) Map the pixel values in the original image according to the contrast adjustment ratio to obtain the first result image.
[0105] Specifically, the image to be adjusted is obtained by reducing the size of the original image, while the fused image is obtained by fusing the reduced split images. Therefore, both the image to be adjusted and the fused image can be enlarged first. Specifically, the fused image can be enlarged to the same size as the original image, and the image to be adjusted can be enlarged to the same size as the original image.
[0106] At this point, the magnified fused image and the magnified image to be adjusted are the same size. Therefore, the contrast adjustment ratio can be determined based on the magnified fused image and the magnified image to be adjusted. This contrast adjustment ratio indicates how the pixel values of the pixels in the original image should be adjusted. Then, the pixel values in the original image are mapped according to the contrast adjustment ratio to obtain the first result image.
[0107] As one implementation method, the pixel value of a pixel in the fused image can be divided by the pixel value of the corresponding pixel in the image to be adjusted to obtain the contrast adjustment ratio of the corresponding pixel in the original image. The process of calculating the contrast adjustment ratio and obtaining the first result image can be represented by the following formula:
[0108] Lres =L ori *L fusion_Big / L s_Big ;
[0109] Among them, L res L indicates ori L represents the original image. fusion_Big L represents the magnified fused image. s_Big This represents the enlarged image to be adjusted.
[0110] For example, the result of dividing the pixel value of a certain pixel in the fused image by the pixel value of the corresponding pixel in the image to be adjusted is 2; correspondingly, the pixel value of the corresponding pixel in the original image can be doubled, and the value obtained after doubling is the pixel value of the corresponding pixel in the first result image.
[0111] In the above scheme, when the image to be adjusted is the original image after being reduced in size, the fused image and the image to be adjusted can be enlarged, and a contrast adjustment ratio can be determined based on the enlarged fused image and the image to be adjusted. Then, by adjusting the contrast ratio and the original image with complete details, a first result image with higher details can be obtained.
[0112] Furthermore, after step S104 above, the contrast adjustment method provided in this application embodiment may further include the following:
[0113] Step (1) Determine the specular mask corresponding to the original image.
[0114] Step (2): The original image and the first result image are fused according to the specular mask to obtain the second result image.
[0115] Specifically, the electronic device can determine the corresponding specular mask based on the original image, and then fuse the original image and the first result image according to the specular mask to obtain the second result image. There are various ways for the electronic device to determine the specular mask, and this application embodiment does not specifically limit this method.
[0116] For example, an electronic device can replace the pixel value of a pixel in the original image with 0 or 1 based on a pre-set threshold; or, an electronic device can determine a weight based on the pixel value of a pixel in the original image; or, an electronic device can input the original image and the first result image into a pre-trained neural network to predict the corresponding mask, and the predicted mask can be binarized to 0 or 1, or normalized to the range [0,1], etc.
[0117] Understandably, depending on how the specular mask is determined, the electronic device obtains the second result image in different ways. However, generally speaking, the method for determining the second result image can be summarized by the following formula:
[0118] L res =M hl *L ori +(1-M hl )*L res ;
[0119] Among them, L res It means that M hl L represents a specular mask. ori This represents the original image.
[0120] In other words, based on the pixel values in the specular mask, the proportion of the pixel values in the second result image relative to the corresponding pixel values in the original image and the proportion of the corresponding pixel values in the first result image can be determined.
[0121] In the above scheme, since the image quality of some parts of the first result image after brightness adjustment may be worse than that of the image before adjustment, the original image and the first result image can be fused based on a specular mask, so as to adaptively adjust the brightness of some areas in the first result image, so that the two can complement each other to obtain a second result image with better effect.
[0122] The following describes two specific implementation methods for determining the specular mask corresponding to the image to be adjusted.
[0123] The first method, the step of determining the specular mask corresponding to the original image, may specifically include the following:
[0124] Step (1) determines the pixel value of the pixel point with a pixel value greater than the highlight threshold in the original image as 1, and determines the pixel value of the pixel point with a pixel value less than or equal to the highlight threshold in the original image as 0, thus obtaining the highlight mask.
[0125] Correspondingly, the step of fusing the original image and the first result image based on the specular mask to obtain the second result image may specifically include the following:
[0126] Step (1): For each pixel in the second result image, if the pixel value of its corresponding pixel in the specular mask is 1, then the pixel value of the pixel is determined to be the pixel value of its corresponding pixel in the original image; and if the pixel value of its corresponding pixel in the specular mask is 0, then the pixel value of the pixel is determined to be the pixel value of its corresponding pixel in the first result image.
[0127] Specifically, a highlight threshold can be preset (e.g., 250). For each pixel in the original image, if the pixel value of the original image is greater than the above highlight threshold, the pixel value of the corresponding pixel in the highlight mask can be set to 1; if the pixel value of the original image is less than the above highlight threshold, the pixel value of the corresponding pixel in the highlight mask can be set to 0. In this way, a highlight mask with a pixel value of 1 or 0 is obtained.
[0128] Then, based on the formula in the above embodiment, for each pixel in the second result image, if the pixel value of the corresponding pixel in the specular mask is 1, the pixel value of that pixel can be determined as the pixel value of the corresponding pixel in the original image; if the pixel value of the corresponding pixel in the specular mask is 0, the pixel value of that pixel can be determined as the pixel value of the corresponding pixel in the first result image.
[0129] In the above scheme, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused by a highlight mask to determine the pixel values of the highlight areas as the corresponding pixel values of the original image, thereby ensuring the brightness of the highlight areas.
[0130] The second method involves determining the specular mask based on the pixel values of the pixels in the original image. In this case, the step of fusing the original image and the first result image based on the specular mask to obtain the second result image can specifically include the following:
[0131] Step (1): Weight the corresponding pixel values in the original image and the first result image according to the specular mask to obtain the second result image; wherein, the pixel value in the specular mask represents the fusion weight of the corresponding pixel value in the original image, and the pixel value in the specular mask is positively correlated with the corresponding pixel value in the original image, and the sum of the fusion weight of the pixel value in the original image and the fusion weight of the corresponding pixel value in the first result image is a fixed value.
[0132] Specifically, in the previous embodiment, the pixel values in the specular mask only included 1 and 0, while in this embodiment, the pixel values in the specular mask include multiple values between [0,1]. As one implementation, the pixel values in the specular mask can represent the fusion weights of corresponding pixel values in the original image, and the pixel values in the specular mask are positively correlated with the corresponding pixel values in the original image. The sum of the fusion weights of the pixel values in the original image and the fusion weights of the corresponding pixel values in the first result image is a fixed value. Based on this fusion weight and the formula in the above embodiment, the second result image can be determined.
[0133] For example, assuming the above fixed value is 1, and in the original image, a certain pixel has a pixel value of 250, then the pixel value of the corresponding pixel in the specular mask can be determined as... Should This refers to the fusion weight of the corresponding pixel values in the original image. Correspondingly, the fusion weight of the corresponding pixel values in the first result image is... Therefore, the pixel value of the corresponding pixel in the second result image is... Multiply by the pixel value of the corresponding pixel in the original image and add Multiply by the pixel value of the corresponding pixel in the first result image.
[0134] In the above scheme, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused by a highlight mask. The higher the pixel value, the larger the proportion of the pixel value in the original image, thereby ensuring the brightness of the highlight areas.
[0135] Furthermore, after step S101, the image to be adjusted can be normalized, that is, converted into a [0,1] data format. As one implementation, during the conversion process, each pixel can be guaranteed to be a floating-point number (e.g., a 32-bit floating-point number, a 64-bit floating-point number). It is understood that the larger the bit value, the higher the accuracy of the contrast adjustment result but the greater the computational load; conversely, the smaller the bit value, the smaller the computational load of the contrast adjustment result but the lower the accuracy. Therefore, those skilled in the art can flexibly adjust the bit value according to the actual situation.
[0136] The following example illustrates the complete process of a contrast adjustment method provided in an embodiment of this application. Assume the original image is L. ori The image to be adjusted, L, is obtained after the original image is reduced in size. s The image to be adjusted is normalized to obtain an image L with pixel values in the range [0,1]. s .
[0137] Then, the electronic device can split the normalized image to be adjusted into two frames, one in the low-value domain and the other in the high-value domain, according to a preset splitting threshold of 0.5 (where M=2). The low-value domain frame L... low In this process, for each pixel in the image to be adjusted, if the pixel value is less than 0.5, the original value is retained; if it is greater than or equal to 0.5, it is set to 0.5. This yields a preliminary split image with pixel values in the range [0, 0.5]. Similarly, in a frame L with high value range... high In this process, for each pixel in the image to be adjusted, if the pixel value is greater than 0.5, the original value is retained; if it is less than or equal to 0.5, it is taken as 0.5. In this way, a preliminary split image with pixel values in the range of [0.5,1] is obtained.
[0138] Next, for L low and Lhigh Map the pixel values of the two frames to L low Multiply the pixel value of each pixel in the image by 2 to obtain an intermediate image with pixel values in the range [0,1]; similarly, L... high Subtracting 0.5 multiplied by 2 from the pixel value corresponding to each pixel point in the image yields an intermediate image with pixel values ranging from [0,1].
[0139] Based on the preset quantity N, in the above-mapped L low and L high Interpolation is performed between the frames to obtain N+1 frames of split image. Taking N as 5 as an example, first L... low and L high The mean image L is obtained by direct averaging. mid L low and L mid The mean image L is obtained by direct averaging. mid1 L high and L mid The mean image L is obtained by direct averaging. mid2 L mid1 and L mid The mean image L is obtained by direct averaging. mid3 L mid2 and L mid The mean image L is obtained by direct averaging. mid4 Currently, 5 new frames have been generated, so the L frames can be discarded. mid L remains low L mid1 L mid2 L mid3 L mid4 L high .
[0140] Next, after the above steps, we can obtain N+1 frame split images L. low L1…L i L high The multi-exposure fusion HDR fusion method can be used to fuse the above N+1 frame split images to obtain the fused image L. fusio n.
[0141] Next, the images L will be merged. fusion Enlarged to the original size to obtain L fusion_Big , put the small image L s Enlarged to the original size to obtain L s_Big Therefore, the first result image is...
[0142] Finally, based on the original image L ori Calculate the specular mask M hl If in Lori If the value of the upper pixel is greater than 250, then M hl The pixel value of the corresponding pixel is set to 1, otherwise it is set to 0. Therefore, the second result image is L. res =M hl *L ori +(1-M hl )*L res .
[0143] Please refer to Figure 2 , Figure 2 The present application provides a structural block diagram of a contrast adjustment device 200, which may include: an acquisition module 201 for acquiring an image to be adjusted; a splitting module 202 for splitting the image to be adjusted into multiple split images; wherein each split image represents the result of image acquisition of a scene in the image to be adjusted at its corresponding exposure level or exposure time; a first fusion module 203 for performing HDR fusion on the multiple split images to obtain a fused image; and a first determination module 204 for determining a first result image after contrast adjustment based on the fused image.
[0144] In this embodiment, the image to be adjusted is split into multiple frames, each representing the result of image acquisition at a certain exposure level. This allows for the fusion of these multiple frames using an HDR fusion method. Since HDR fusion enhances both image detail and dynamic range, the fused image exhibits higher dynamic range and detail. Based on this fused image, a first result image with both high dynamic range and detail can be further determined.
[0145] Furthermore, the splitting module 202 is specifically used to: split the image to be adjusted into N preliminary split images according to N-1 splitting thresholds, wherein the pixel values in each preliminary split image are distributed within a corresponding interval, and the N intervals corresponding to the N preliminary split images cover the actual pixel value range of the image to be adjusted; wherein, N>1, and N is the total number of split images; and map the pixel values in the N preliminary split images to obtain N split images; wherein the actual pixel value range of each split image is the same as the actual pixel value range of the image to be adjusted.
[0146] In this embodiment of the application, the image to be adjusted can be split based on N-1 splitting thresholds, and the pixel values in the initially split image can be mapped to improve the dynamic range of the split image, thereby improving the dynamic range of the first result image.
[0147] Further, the splitting module 202 is specifically used for: splitting the image to be adjusted into M+1 preliminary split images according to M splitting thresholds, wherein the pixel values in each preliminary split image are distributed within a corresponding interval, and the M+1 intervals corresponding to the M+1 preliminary split images cover the actual pixel value range of the image to be adjusted; wherein, P-1 > M ≥ 1, and P is the total number of split images; mapping the pixel values in the M+1 preliminary split images to obtain M+1 intermediate images; wherein the actual pixel value range of each intermediate image is the same as the actual pixel value range of the image to be adjusted; interpolating and calculating PM-1 interpolated images between the M+1 intermediate images to obtain...
[0148] In this embodiment, the image to be adjusted can be split by combining M splitting thresholds and interpolation, and the pixel values in the initially split image can be mapped to improve the dynamic range of the split image, thereby improving the dynamic range of the first result image.
[0149] Furthermore, the splitting module 202 is also used to: take the intermediate image of the M+1 frame as the split image of the M+1 frame, calculate the mean image of two adjacent split images according to the interpolation calculation order, and insert the calculated mean image between two adjacent split images as a new split image, until the N-frame split image is obtained.
[0150] In this embodiment, the average frame of two adjacent frames can be calculated as the interpolation frame, thereby making the transition between the final multi-frame split images smoother and improving the details of the fused image obtained after HDR fusion.
[0151] Furthermore, the acquisition module 201 is specifically used for: acquiring the original image; reducing the size of the original image to obtain the image to be adjusted.
[0152] In this embodiment of the application, after obtaining the original image, the original image can be reduced in size, and the reduced image to be adjusted can be split and merged, thereby reducing the computational load of the algorithm.
[0153] Furthermore, the acquisition module 201 is also used to: reduce the size of the original image multiple times to obtain the image to be adjusted.
[0154] In this embodiment of the application, the process of reducing the original image can be repeated multiple times, gradually reducing the original image to the size of the image to be adjusted. During this successive reduction process, as much detail as possible in the original image can be preserved, thereby improving the detail of the fused image obtained after HDR fusion.
[0155] Furthermore, the first determining module 204 is specifically used to: determine the first result image based solely on the fused image; or, determine the first result image based on the fused image, the original image, and the image to be adjusted; wherein the image to be adjusted is an image obtained by reducing the size of the original image; or, determine the first result image based on the fused image and the image to be adjusted.
[0156] In the embodiments of this application, when the image to be adjusted is equivalent to the original image, the fused image can be directly determined as the first result image, or the first result image can be determined based on the fused image and the image to be adjusted; when the image to be adjusted is an image obtained by shrinking the original image, the first result image can be determined based on the fused image, the original image and the image to be adjusted, thereby improving the detail of the first result image.
[0157] Furthermore, the first determining module 204 is also configured to: enlarge the fused image to obtain an enlarged fused image, and enlarge the image to be adjusted to obtain an enlarged image to be adjusted; wherein the enlarged fused image and the enlarged image to be adjusted have the same size as the original image; determine a contrast adjustment ratio based on the enlarged fused image and the enlarged image to be adjusted; and map the pixel values in the original image according to the contrast adjustment ratio to obtain the first result image.
[0158] In the embodiments of this application, when the image to be adjusted is an image obtained by shrinking the original image, the fused image and the image to be adjusted can be enlarged, and a contrast adjustment ratio can be determined based on the enlarged fused image and the image to be adjusted. Then, by adjusting the contrast ratio and the original image with complete details, a first result image with higher details can be obtained.
[0159] Furthermore, the contrast adjustment device 200 further includes: a second determining module for determining the highlight mask corresponding to the original image; and a second fusing module for fusing the original image and the first result image according to the highlight mask to obtain a second result image.
[0160] In this embodiment, the original image and the first result image can be fused based on a specular mask, thereby adaptively adjusting the brightness of some areas in the first result image to obtain a second result image with better effect.
[0161] Furthermore, the second determining module is specifically used to: determine the pixel values of pixels in the original image whose pixel values are greater than the highlight threshold as 1, and determine the pixel values of pixels in the original image whose pixel values are less than or equal to the highlight threshold as 0, thereby obtaining the highlight mask; the step of fusing the original image and the first result image according to the highlight mask to obtain the second result image includes: for each pixel in the second result image, if the pixel value of its corresponding pixel in the highlight mask is 1, then the pixel value of the pixel is determined to be the pixel value of its corresponding pixel in the original image, and if the pixel value of its corresponding pixel in the highlight mask is 0, then the pixel value of the pixel is determined to be the pixel value of its corresponding pixel in the first result image.
[0162] In this embodiment, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused using a highlight mask to determine the pixel values of the highlight areas as the pixel values of the corresponding pixels in the original image, thereby ensuring the brightness of the highlight areas.
[0163] Furthermore, the second fusion module is specifically used to: weight the corresponding pixel values in the original image and the first result image according to the specular mask to obtain the second result image; wherein, the pixel values in the specular mask represent the fusion weights of the corresponding pixel values in the original image, and the pixel values in the specular mask are positively correlated with the corresponding pixel values in the original image, and the sum of the fusion weights of the pixel values in the original image and the fusion weights of the corresponding pixel values in the first result image is a fixed value.
[0164] In this embodiment, since the highlight areas in the first result image may be darkened, the original image and the first result image can be fused using a highlight mask. The higher the pixel value, the larger the proportion of the pixel value in the original image, thereby ensuring the brightness of the highlight areas.
[0165] Please refer to Figure 3 , Figure 3 This application provides a structural block diagram of an electronic device 300, which includes at least one processor 301, at least one communication interface 302, at least one memory 303, and at least one communication bus 304. The communication bus 304 enables direct communication between these components, the communication interface 302 facilitates signaling or data communication with other node devices, and the memory 303 stores machine-readable instructions executable by the processor 301. When the electronic device 300 is running, the processor 301 communicates with the memory 303 via the communication bus 304, and the contrast enhancement method described above is executed when the machine-readable instructions are invoked by the processor 301.
[0166] For example, the processor 301 in this embodiment of the application can read computer program instructions from the memory 303 via the communication bus 304 and execute the computer program instructions to implement the following method: Step S101: Acquire the image to be adjusted. Step S102: Divide the image to be adjusted into multiple frame-by-frame images; wherein each frame-by-frame image represents the result of image acquisition of the scene in the image to be adjusted under a corresponding exposure level. Step S103: Perform HDR fusion on the multiple frame-by-frame images to obtain a fused image. Step S104: Determine the first result image after contrast adjustment based on the fused image.
[0167] Processor 301 can be an integrated circuit chip with signal processing capabilities. The processor 301 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.
[0168] The memory 303 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0169] Understandable. Figure 3 The structure shown is for illustrative purposes only; the electronic device 300 may also include components that are more advanced than those shown. Figure 3 The more or fewer components shown, or having the same Figure 3 The different configurations shown. Figure 3The components shown can be implemented using hardware, software, or a combination thereof. In the embodiments of this application, electronic device 300 can be, but is not limited to, physical devices such as desktop computers, laptops, smartphones, smart wearable devices, and in-vehicle devices, or virtual devices such as virtual machines. Furthermore, electronic device 300 is not necessarily a single device; it can be a combination of multiple devices, such as a server cluster, etc.
[0170] This application also provides a computer program product, including computer program instructions stored on a computer-readable storage medium. When the computer program instructions are executed by a computer, the computer can perform the steps of the contrast enhancement method in the above embodiments, such as: acquiring an image to be adjusted; splitting the image to be adjusted into multiple frame split images; wherein each frame split image represents the result of image acquisition of a scene in the image to be adjusted at a corresponding exposure level; performing HDR fusion on the multiple frame split images to obtain a fused image; and determining a first result image after contrast adjustment based on the fused image.
[0171] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0172] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0173] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0174] It should be noted that if the function is implemented as a software module 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 this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0175] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.
[0176] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A contrast adjustment method, characterized in that, include: Obtain the image to be adjusted; The image to be adjusted is split into multiple frame split images; wherein each frame split image represents the result of image acquisition of the scene in the image to be adjusted at its corresponding exposure level or exposure time; The multi-frame split images are HDR fused to obtain a fused image; Based on the fused image, determine the first result image after contrast adjustment; The step of splitting the image to be adjusted into multiple frame-by-frame images includes: The image to be adjusted is divided into M+1 preliminary split images according to M split thresholds. The pixel values in each preliminary split image are distributed in a corresponding interval. The M+1 intervals corresponding to the M+1 preliminary split images cover the actual pixel value range of the image to be adjusted. Wherein, P-1>M≥1, and P is the total number of split images. The pixel values in the initially split image of frame M+1 are mapped to obtain intermediate images of frame M+1; wherein, the actual pixel value range of each intermediate image is the same as the actual pixel value range of the image to be adjusted; Interpolate the intermediate images of the M+1 frames to calculate the interpolated image of the PM-1 frame, and obtain a total P-frame split image composed of the intermediate images and the interpolated image.
2. The contrast adjustment method according to claim 1, characterized in that, The step of interpolating and calculating the PM-1 frame interpolated image between the intermediate images of the M+1 frames to obtain a total P-frame split image composed of the intermediate images and the interpolated image includes: The intermediate image of frame M+1 is used as the split image of frame M+1. According to the interpolation calculation order, the mean image of the split images of two adjacent frames is calculated, and the calculated mean image is inserted between the split images of two adjacent frames as a new split image, until the split image of frame P is obtained.
3. The contrast adjustment method according to any one of claims 1-2, characterized in that, The process of acquiring the image to be adjusted includes: Obtain the original image; The original image is reduced in size to obtain the image to be adjusted.
4. The contrast adjustment method according to claim 3, characterized in that, The step of determining the first contrast-adjusted result image based on the fused image includes: The first result image is determined solely based on the fused image; or, The first result image is determined based on the fused image, the original image, and the image to be adjusted; wherein the image to be adjusted is the image obtained by reducing the size of the original image; or, The first result image is determined based on the fused image and the image to be adjusted.
5. The contrast adjustment method according to claim 4, characterized in that, Determining the first result image based on the fused image, the original image, and the image to be adjusted includes: The fused image is enlarged to obtain an enlarged fused image, and the image to be adjusted is enlarged to obtain an enlarged image to be adjusted; wherein the enlarged fused image and the enlarged image to be adjusted are the same size as the original image; The contrast adjustment ratio is determined based on the magnified fused image and the magnified image to be adjusted; The pixel values in the original image are mapped according to the contrast adjustment ratio to obtain the first result image.
6. The contrast adjustment method according to claim 3, characterized in that, After determining the contrast-adjusted first result image based on the fused image, the method further includes: Determine the specular mask corresponding to the original image; The original image and the first result image are fused together using the specular mask to obtain the second result image.
7. The contrast adjustment method according to claim 6, characterized in that, Determining the specular mask corresponding to the original image includes: The pixel values of pixels in the original image that are greater than the highlight threshold are determined as 1, and the pixel values of pixels in the original image that are less than or equal to the highlight threshold are determined as 0, thus obtaining the highlight mask; The step of fusing the original image and the first result image according to the specular mask to obtain the second result image includes: For each pixel in the second result image, if the pixel value of its corresponding pixel in the specular mask is 1, then the pixel value of that pixel is determined to be the pixel value of its corresponding pixel in the original image; and if the pixel value of its corresponding pixel in the specular mask is 0, then the pixel value of that pixel is determined to be the pixel value of its corresponding pixel in the first result image.
8. The contrast adjustment method according to claim 6, characterized in that, The step of fusing the original image and the first result image according to the specular mask to obtain the second result image includes: The second result image is obtained by weighting the corresponding pixel values in the original image and the first result image according to the specular mask; wherein, the pixel value in the specular mask represents the fusion weight of the corresponding pixel value in the original image, and the pixel value in the specular mask is positively correlated with the corresponding pixel value in the original image, and the sum of the fusion weight of the pixel value in the original image and the fusion weight of the corresponding pixel value in the first result image is a fixed value.
9. A computer program product, characterized in that, include: Computer program instructions, which, when read and executed by a processor, perform the method as described in any one of claims 1-8.
10. An electronic device, characterized in that, include: Processor, memory, and bus; The processor and the memory communicate with each other via the bus; The memory stores computer program instructions that can be executed by the processor, and the processor can invoke the computer program instructions to perform the method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a computer, cause the computer to perform the method as described in any one of claims 1-8.