Dynamic range mode switching method and device based on backlight scene intensity of camera

By acquiring YUV images in the camera and dividing them into block areas, calculating the grayscale mean and establishing a weight mapping relationship, the problem of poor imaging quality in the backlight scene is solved, and the precise evaluation of the intensity of the backlight scene and the rapid switching of the dynamic range mode are achieved, which improves the imaging quality and user experience.

CN119583952APending Publication Date: 2025-03-07SHENZHEN TVT DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411738801.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

Existing cameras are difficult to effectively express light and dark differences in backlight scenarios, resulting in poor imaging quality and poor results in prior art when using dynamic range synthesis methods in non-backlight scenarios.

Method used

By acquiring the YUV image, dividing it into multiple block areas, calculating the grayscale mean of each area, establishing a weight mapping relationship, performing weight average processing, calculating the detection value of the camera's backlight scene strength, and switching the dynamic range mode according to the detection value.

Benefits of technology

It realizes accurate evaluation of the intensity of the backlight scene, quickly switches the dynamic range mode, adapts to changes in the backlight scene, and improves imaging quality and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119583952A_ABST
    Figure CN119583952A_ABST
Patent Text Reader

Abstract

The invention discloses a dynamic range mode switching method and device based on the backlight scene intensity of a camera. The method comprises the following steps: acquiring a YUV image; equally dividing all pixel points of the YUV image into a plurality of square block areas; respectively calculating an average value of the gray values of all the pixel points in each square area to obtain a gray average value of each square area; calculating a minimum gray average value, a maximum gray average value and an average gray average value of the YUV image; establishing a first weight mapping relation and a second weight mapping relation; performing weighted average processing according to the first weight mapping relation and the second weight mapping relation to obtain a first weighted average value and a second weighted average value; calculating a detection value of the backlight scene intensity of the camera; and switching the dynamic range mode of the camera according to the detection value of the backlight scene intensity of the camera. According to the invention, the switching of the dynamic range mode is realized according to the backlight degree, so that the imaging quality of the camera in a backlight scene is optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cameras, and more particularly to a method and device for switching dynamic range modes based on the intensity of backlight scenes of cameras. Background Art

[0002] With the advancement of science and technology, the use of various camera devices is becoming increasingly widespread. In everyday situations such as taking photos, recording driving, and conducting security surveillance, people often encounter backlit scenes or scenes with significant differences in brightness. Limited by the limitations of photosensitive devices and digital signal transmission (that is, the limited dynamic range of cameras), images captured by cameras often fail to fully convey the original appearance of these scenes when depicting differences in brightness. To improve the dynamic range of cameras, different exposures can be taken over a short period of time, and the resulting images are then combined at a specified ratio to produce images with greater brightness differences. However, since the combined original images were not captured simultaneously, the final combined image is prone to deviations and distortion. Using this method to synthesize images in non-backlit scenes will result in significantly inferior results compared to the original image.

[0003] In view of this, for the above situation, it is necessary to design a method to determine the strength of backlight and switch the dynamic range mode according to the strength of backlight. Summary of the Invention

[0004] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method and device for switching dynamic range modes based on the intensity of backlight scenes of a camera.

[0005] To achieve the above object, the present invention adopts the following technical solutions:

[0006] In a first aspect, the present invention provides a method for switching dynamic range modes based on the intensity of a camera backlight scene, comprising:

[0007] Get the YUV image containing grayscale value information;

[0008] Divide all pixels of the YUV image into several square areas;

[0009] Calculate the average grayscale value of all pixels in each square area to obtain the grayscale mean of each square area;

[0010] According to the grayscale mean of each square area, the minimum grayscale mean, maximum grayscale mean and average grayscale mean of the YUV image are calculated respectively;

[0011] Establishing a first weight mapping relationship and a second weight mapping relationship according to the relationship between the grayscale mean of each square area and the minimum grayscale mean, the maximum grayscale mean, and the average grayscale mean of the YUV image;

[0012] Performing weighted averaging processing on the block area between the minimum grayscale mean and the average grayscale mean, and the block area between the average grayscale mean and the maximum grayscale mean according to the first weight mapping relationship and the second weight mapping relationship to obtain a first weighted mean and a second weighted mean;

[0013] Calculating a detection value of the camera's backlight scene intensity based on the first weighted mean and the second weighted mean;

[0014] The dynamic range mode of the camera is switched according to the detection value of the intensity of the backlight scene of the camera.

[0015] Furthermore, the number of pixels contained in each square area is C / (M×N), where M refers to the number of square areas in the length direction of the YUV image, N refers to the number of square areas in the width direction of the YUV image, and C refers to the total number of pixels in the YUV image.

[0016] Furthermore, the calculation formula for the grayscale mean of each square area is:

[0017]

[0018] Where Y ave (i) represents the average grayscale value of all pixels in the i-th square area, where i is 1, 2, 3, ..., M×N, and Y(i)(j) represents the grayscale value of the j-th pixel in the i-th square area, where j is 1, 2, 3, ..., C / (M×N).

[0019] Furthermore, the first weight mapping relationship and the second weight mapping relationship satisfy the following formula:

[0020]

[0021]

[0022] Where w small (i) represents the first weight mapping relationship, w big (i) represents the second weight mapping relationship, w1, w2, and w3 represent custom weight values, and w3 is greater than w2, w2 is greater than w1, Y black Indicates the minimum grayscale mean of the YUV image, Y white Indicates the maximum grayscale mean of the YUV image, Y mean Indicates the average grayscale value of the YUV image.

[0023] Furthermore, the calculation formulas for the first weighted mean and the second weighted mean are as follows:

[0024]

[0025] Where Y small represents the first weighted mean, Y big represents the second weighted mean.

[0026] Furthermore, the calculation formula for the detection value of the camera's backlight scene strength is as follows:

[0027]

[0028] Where testvalue represents the detection value of the camera's backlight intensity, and its value range is 0 to 1.

[0029] Furthermore, the switching of the dynamic range mode of the camera according to the detection value of the intensity of the backlight scene of the camera includes:

[0030] When the camera is operating in the first dynamic range mode, if the detection value of the camera's backlight scene intensity is detected to be greater than the first threshold, the camera is switched to the second dynamic range mode;

[0031] When the camera operates in the second dynamic range mode, if the detection value of the camera's backlight scene intensity is not greater than the second threshold, the camera is switched to the first dynamic range mode, and the first threshold is greater than the second threshold.

[0032] In a second aspect, the present invention also provides a dynamic range mode switching device based on the strength of the backlight scene of the camera, including an acquisition unit, a region division unit, a grayscale mean calculation unit, a YUV image mean calculation unit, a weight mapping creation unit, a weighted average processing unit, a detection value calculation unit and a mode switching unit;

[0033] The acquisition unit is used to acquire a YUV image containing grayscale value information;

[0034] The region division unit is used to divide all pixels of the YUV image into a number of square regions;

[0035] The grayscale mean calculation unit is used to calculate the average grayscale values ​​of all pixels in each square area to obtain the grayscale mean of each square area;

[0036] The YUV image mean value calculation unit is used to calculate the minimum grayscale mean, the maximum grayscale mean and the average grayscale mean of the YUV image according to the grayscale mean of each square area;

[0037] The weight mapping creation unit is used to establish a first weight mapping relationship and a second weight mapping relationship according to the relationship between the grayscale mean of each block area and the minimum grayscale mean, the maximum grayscale mean and the average grayscale mean of the YUV image;

[0038] The weighted average processing unit is configured to perform weighted average processing on the block area between the minimum grayscale mean and the average grayscale mean, and the block area between the average grayscale mean and the maximum grayscale mean according to the first weight mapping relationship and the second weight mapping relationship, so as to obtain a first weighted mean and a second weighted mean;

[0039] The detection value calculation unit is used to calculate the detection value of the camera's backlight scene intensity based on the first weighted mean and the second weighted mean;

[0040] The mode switching unit is used to switch the dynamic range mode of the camera according to the detection value of the intensity of the backlight scene of the camera.

[0041] In a third aspect, the present invention also provides a computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method for switching dynamic range modes based on the intensity of the camera backlight scene as described above is implemented.

[0042] In a fourth aspect, the present invention also provides a computer-readable storage medium, which stores a computer program, and the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the dynamic range mode switching method based on the strength of the camera backlight scene as described above.

[0043] Compared with the prior art, the present invention has the following advantages: a method for switching dynamic range modes based on the intensity of a camera backlight scene, comprising: obtaining a YUV image containing grayscale value information; dividing all pixel points of the YUV image into a number of square areas; calculating the average grayscale values ​​of all pixel points in each square area to obtain the grayscale mean of each square area; calculating the minimum grayscale mean, maximum grayscale mean and average grayscale mean of the YUV image according to the grayscale mean of each square area; and calculating the grayscale mean of each square area according to the grayscale mean of the YUV image. The invention relates to a method for accurately evaluating the intensity of a backlight scene in which a camera is located. The method comprises the following steps: determining the relationship between the maximum grayscale mean and the average grayscale mean, establishing a first weight mapping relationship and a second weight mapping relationship; performing weighted averaging processing on a block area between the minimum grayscale mean and the average grayscale mean, and a block area between the average grayscale mean and the maximum grayscale mean according to the first weight mapping relationship and the second weight mapping relationship, so as to obtain a first weighted mean and a second weighted mean; calculating a detection value of the intensity of a backlight scene in which a camera is located according to the first weighted mean and the second weighted mean; and switching a dynamic range mode of the camera according to the detection value of the intensity of the backlight scene in which the camera is located. The invention can accurately evaluate the intensity of a backlight scene in which a camera is located. The evaluation method comprehensively considers the brightness characteristics of different areas of an image, avoids the defects of a single parameter evaluation, and enables the detection value to accurately reflect the actual backlight situation by distinguishing and processing different brightness areas. At the same time, the method of dividing the block area reduces the amount of calculation, can quickly obtain the detection value and switch the dynamic range mode in time, and quickly adapt to changes in the backlight scene. The invention not only has higher feasibility in practical applications, but also improves the user experience during shooting and optimizes the imaging quality of the camera in backlight scenes.

[0044] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail as follows. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0046] Figure 1 A schematic diagram of a working scenario provided for a specific embodiment of the present invention;

[0047] Figure 2 A flowchart of a method for switching dynamic range modes based on the intensity of a camera's backlighting scene is provided in a specific embodiment of the present invention;

[0048] Figure 3 A schematic block diagram of a device for switching dynamic range modes based on the intensity of a camera's backlighting scene, provided in a specific embodiment of the present invention;

[0049] Figure 4 A schematic block diagram of a computer device provided in accordance with a specific embodiment of the present invention. DETAILED DESCRIPTION

[0050] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0051] It will be understood that when used in this specification and the appended claims, the terms “comprises” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0052] It should also be understood that the terms used in the present specification are only for the purpose of describing particular embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.

[0053] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0054] Before further describing the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are explained. The nouns and terms involved in the embodiments of the present invention are subject to the following explanations.

[0055] Pixel: refers to the small squares of an image. These small squares have a clear position and assigned color values. The color and position of the small squares determine the appearance of the image.

[0056] YUV color space: A method of expressing color, where Y reflects the brightness of the image, U and V reflect color information, describe the image color and saturation, and are used to specify the color of pixels.

[0057] Grayscale value: This refers to the numerical value representing brightness or darkness in each pixel of an image. Generally, a black and white image has a single grayscale value per pixel, while a color image has three grayscale values: red, green, and blue (RGB). In the YUV color space, the Y channel is used to reflect the brightness of the image, and the method used in this invention is based on this parameter.

[0058] Backlight: Also known as backlighting, the camera's shooting direction is opposite to the light's direction, resulting in underexposed objects and overexposed areas due to excessive light. In backlit scenes, the image is often polarized, with one image showing bright and one dark.

[0059] Dynamic Range: After external information (such as light and sound) is converted into information for transmission, storage, and processing by the camera, it generally has only a specific range of values ​​(external information smaller than this range is uniformly counted as the minimum amount; external information larger than this range is uniformly counted as the maximum amount). The ratio of the maximum and minimum values ​​in this range is the dynamic range.

[0060] Weighted Mean: A statistical term used in statistics. In a weighted mean, each data point is assigned a weight, which determines its importance in calculating the average. The weighted mean is calculated by multiplying the values ​​of each data point by the weight, summing the results, and dividing by the sum of all the weights.

[0061] Threshold: Also called critical value, a threshold generally refers to a range that cannot be exceeded; or a boundary limit, exceeding which changes the operating state of the device.

[0062] Exposure: This technique adjusts the camera's light sensor's exposure time, signal amplification, and other parameters to achieve a desired brightness. Underexposure results in a dark image, while overexposure results in a completely white image. Neither underexposure nor overexposure reflects the subject's true appearance.

[0063] like Figure 1 As shown in the working scene diagram provided by the specific embodiment of the present invention, the camera captures the image of the subject and evaluates the light intensity of the backlit scene in which the camera is located, thereby adaptively switching the dynamic range alignment mode. The subject can be a person or an object.

[0064] like Figure 2 As shown, an embodiment of the present invention provides a method for switching dynamic range modes based on the intensity of a camera backlight scene, including the following steps S10-S80.

[0065] S10. Obtain a YUV image containing grayscale value information.

[0066] Set up a shooting environment and put the camera into shooting working state. After image processing, output a YUV image containing grayscale value information. The Y in the YUV image is the grayscale value of the pixel.

[0067] S20, dividing all pixels of the YUV image into a number of square areas.

[0068] In this embodiment, to facilitate calculations and reduce the processor's computational burden, M × N should be smaller than the total number of pixels in the YUV image currently captured by the camera. M refers to the number of square regions along the length of the YUV image, and N refers to the number of square regions along the width of the YUV image. To ensure more reliable data, the values ​​of M and N should not be too small. Generally, both values ​​should be greater than 10, meaning that the number of square regions along both the length and width directions is greater than 10.

[0069] The number of pixels contained in each square area is C / (M×N), where C refers to the total number of pixels in the YUV image.

[0070] S30 , respectively calculating the average grayscale values ​​of all pixels in each square area to obtain the grayscale mean value of each square area.

[0071] For each square area, we traverse all the pixels within it, add up their grayscale values, and then divide by the total number of pixels in the square area to obtain the grayscale mean of the square area. By calculating the grayscale mean of each square area, we can quickly understand the average brightness of each local area, providing a basis for subsequently determining the overall brightness distribution of the image.

[0072] In this embodiment, the calculation formula for the grayscale mean of each square area is:

[0073]

[0074] Where Y ave (i) represents the average grayscale value of all pixels in the i-th square area, where i is 1, 2, 3, ..., M×N, and U(i)(j) represents the grayscale value of the j-th pixel in the i-th square area, where j is 1, 2, 3, ..., C / (M×N).

[0075] S40 , respectively calculating the minimum grayscale mean, the maximum grayscale mean, and the average grayscale mean of the YUV image according to the grayscale mean of each square area.

[0076] Specifically, the minimum grayscale mean of the YUV image here refers to all Y aveThe smallest value in (i). The maximum grayscale mean here refers to the value of all Y ave The maximum value in (i). The average grayscale mean here refers to the average grayscale value of all Y ave (i) Add them up and then divide by the total number of blocks M×N.

[0077] In this embodiment, specifically, the minimum grayscale mean value of the YUV image is Y black , the maximum grayscale mean of the YUV image is Y white , the average grayscale mean of the YUV image is Y mean , then the three quantities are obtained by the following formulas:

[0078] Y black =min(Y ave (i)};

[0079] Y white =max(Y ave (i)};

[0080]

[0081] S50 , establishing a first weight mapping relationship and a second weight mapping relationship according to the relationship between the grayscale mean of each square area and the minimum grayscale mean, the maximum grayscale mean, and the average grayscale mean of the YUV image.

[0082] In this embodiment, in order to maintain generality, the closer the grayscale mean is to the average grayscale mean of the YUV image, the greater the weight of the block area, and the farther away, the smaller the weight. Therefore, two different weight mapping relationships can be set, namely, the first weight mapping relationship w small (i) and the second weight mapping relationship w big (i). w small (i) Mainly focus on Y black Towards Y mean Close to the situation, w big (i) Main Y mean Towards Y white Close situation.

[0083] The first weight mapping relationship and the second weight mapping relationship satisfy the following formula:

[0084]

[0085]

[0086] Where w small (i) represents the first weight mapping relationship, w big(i) represents the second weight mapping relationship, w1, w2, and w3 represent custom weight values, and w3 is greater than w2, w2 is greater than w1, Y black Indicates the minimum grayscale mean of the YUV image, Y white Indicates the maximum grayscale mean of the YUV image, Y mean Indicates the average grayscale value of the YUV image.

[0087] To facilitate understanding of these two mapping relationships, the specific mapping examples are as follows:

[0088] For w small (i), when Y ave (i) = Y black When small (i) = w1; when Y ave (i)=(Y mean +Y black ) / 2, w small (i) = w2; Y ave (i) = Y mean When w small (i) = w3.

[0089] For w big (i), when Y ave (i) = Y mean When big (i)=w3;when Y ave (i)=(Y mean +Y white ) / 2, w big (i)=w2; when Y ave (i) = Y white When w big (i) = w1.

[0090] The weight mapping relationship can reasonably allocate weights according to the grayscale conditions of different block areas, so as to more accurately reflect the characteristics of different brightness areas in subsequent processing, which is crucial for the analysis and processing of backlit scenes.

[0091] S60. Perform weighted averaging processing on the block area between the minimum grayscale mean and the average grayscale mean, and the block area between the average grayscale mean and the maximum grayscale mean according to the first weight mapping relationship and the second weight mapping relationship to obtain a first weighted mean and a second weighted mean.

[0092] Specifically, for the square area belonging to the two grayscale intervals, the grayscale values ​​of the pixels are weighted averaged according to the corresponding weight mapping relationship.

[0093] In this embodiment, the calculation formulas for the first weighted mean and the second weighted mean are as follows:

[0094]

[0095]

[0096] Where Y small represents the first weighted mean, Y big represents the second weighted mean.

[0097] Through weighted averaging processing, a weighted mean value that can better reflect the characteristics of key brightness areas in the image can be obtained, which helps to accurately judge the intensity of backlit scenes.

[0098] S70. Calculate a detection value of the camera's backlight scene intensity based on the first weighted mean and the second weighted mean.

[0099] In this embodiment, the calculation formula of the detection value of the backlight scene intensity of the camera is as follows:

[0100]

[0101] Where testvalue represents the detection value of the camera's backlight intensity, and its value range is 0 to 1. Generally, the closer the detection value is to 1, the stronger the backlight in the current scene is; conversely, the closer the value is to 0, the weaker the backlight in the current scene is.

[0102] The detection value of the camera's backlight scene intensity can quantitatively represent the intensity of the camera's backlight scene, providing a basis for switching the camera's dynamic range mode.

[0103] S80: Switch the dynamic range mode of the camera according to the detection value of the intensity of the backlight scene of the camera.

[0104] In one embodiment, step S80 specifically includes the following steps: S801 - S802 .

[0105] S801: When the camera operates in a first dynamic range mode, if a detection value of the intensity of the backlight scene detected by the camera is greater than a first threshold, the camera is switched to a second dynamic range mode.

[0106] S802: When the camera operates in the second dynamic range mode, if the detection value of the camera's backlight scene intensity is not greater than a second threshold, the camera is switched to the first dynamic range mode, where the first threshold is greater than the second threshold.

[0107] The first threshold and the second threshold can be flexibly set according to actual operation. Generally, the first threshold is greater than the second threshold to ensure the stability of system operation.

[0108] For steps S801-S802, the camera typically includes a first dynamic range mode and a second dynamic range mode. The first dynamic range mode may be a standard dynamic range (SDR) mode, which performs well in normal lighting scenarios but may cause blown highlights or darkened shadows in high-contrast scenes such as backlighting. The second dynamic range mode may be a high dynamic range (HDR) mode, which can handle a wider brightness range and better preserve details in highlights and shadows in backlighting scenarios.

[0109] The first threshold and the second threshold can be flexibly set according to actual operation. Generally, the first threshold is greater than the second threshold to ensure the stability of system operation. Specifically, the first threshold is a pre-set value used to determine when it is necessary to switch from the first dynamic range mode to the second dynamic range mode. The determination of this threshold requires comprehensive consideration of factors such as the performance of the camera and the type of shooting scene. When the calculated detection value of the camera's backlight scene strength is greater than the first threshold, it indicates that the current backlight scene is strong and the SDR mode may not be able to handle it well, and it is necessary to switch to the HDR mode.

[0110] Assume the first dynamic range mode is SDR, and the first threshold is set to 0.6. The camera is capturing an indoor scene. The room is dimly lit, but there is a large window, which creates backlighting. The camera calculates the backlight intensity detection value to be 0.7. Since 0.7 > 0.6, the camera switches from SDR mode to HDR mode. In HDR mode, the camera can better balance the brightness of the highlights in the window and the shadows in the room, resulting in richer details in the entire image.

[0111] Through this switching mechanism, when the camera is in the first dynamic range mode (such as SDR mode) and encounters a strong backlit scene, it can switch to the second dynamic range mode (such as HDR mode) in time, thereby effectively avoiding the problems of overexposed highlights and dark shadows, improving the quality of the captured image, and ensuring that the details in the backlit scene can be clearly captured.

[0112] When the camera is in the second dynamic range mode (such as HDR mode), although it can handle a larger brightness range, in some scenes with relatively uniform lighting, the HDR mode may bring unnecessary computational burden and possible color distortion and other problems. Therefore, a second threshold is set to determine whether it is possible to switch from HDR mode back to SDR mode. The second threshold is smaller than the first threshold. This is because when switching from HDR mode back to SDR mode, it is necessary to ensure that the backlight scene is relatively weak to ensure that a better shooting effect can be obtained in SDR mode. When the detection value of the camera's backlight scene strength is not greater than the second threshold, it indicates that the backlight intensity of the current scene has been reduced to a range that the SDR mode can handle, so the camera is switched back to SDR mode.

[0113] Assume that the second threshold is set to 0.4. After the camera switches to HDR mode, the indoor light changes over time. Perhaps the curtains are partially drawn, or the position of the sun changes, which reduces the backlight intensity. The detection value of the camera's backlight scene intensity is recalculated to be 0.3. Since 0.3≤0.4, the camera will switch from HDR mode back to SDR mode. This can avoid unnecessary resource consumption and possible image quality issues caused by continuing to use HDR mode in scenes that do not require HDR mode. This switching mechanism enables the camera to flexibly switch between different dynamic range modes according to the actual backlight scene intensity. While ensuring that it can process backlight scenes, it optimizes the camera's resource utilization and avoids excessive use of HDR mode in scenes that do not require high dynamic range processing, thereby obtaining better shooting effects in different lighting environments.

[0114] The present invention can accurately evaluate the intensity of the backlight scene in which the camera is located. This evaluation method comprehensively considers the brightness characteristics of different areas of the image, avoids the defects of single parameter evaluation, and makes the detection value accurately reflect the actual backlight situation by distinguishing and processing different brightness areas. At the same time, the block area division method is used to reduce the amount of calculation, and can quickly obtain the detection value and switch the dynamic range mode in time to quickly adapt to changes in the backlight scene. It not only has higher feasibility in practical applications, but also improves the user experience during the shooting process and optimizes the imaging quality of the camera in backlight scenes.

[0115] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0116] The embodiment of the present invention further provides a device for switching a dynamic range mode based on the intensity of a camera backlight scene, which is used to perform the steps of any embodiment of the method for switching a dynamic range mode based on the intensity of a camera backlight scene. Figure 3 , Figure 3 A schematic block diagram of a dynamic range mode switching device 100 based on the strength of a camera backlight scene provided in an embodiment of the present application is shown. The dynamic range mode switching device 100 based on the strength of a camera backlight scene specifically includes an acquisition unit 110, an area division unit 120, a grayscale mean calculation unit 130, a YUV image mean calculation unit 140, a weight mapping creation unit 150, a weighted average processing unit 160, a detection value calculation unit 170 and a mode switching unit 180.

[0117] The acquisition unit 110 is used to acquire a YUV image containing grayscale value information.

[0118] Set up a shooting environment and put the camera into shooting working state. After image processing, output a YUV image containing grayscale value information. The Y in the YUV image is the grayscale value of the pixel.

[0119] The area division unit 120 is used to divide all pixels of the YUV image into a number of square areas.

[0120] In this embodiment, to facilitate calculations and reduce the processor's computational burden, M × N should be smaller than the total number of pixels in the YUV image currently captured by the camera. M refers to the number of square regions along the length of the YUV image, and N refers to the number of square regions along the width of the YUV image. To ensure more reliable data, the values ​​of M and N should not be too small. Generally, both values ​​should be greater than 10, meaning that the number of square regions along both the length and width directions is greater than 10.

[0121] The number of pixels contained in each square area is C / (M×N), where C refers to the total number of pixels in the YUV image.

[0122] The grayscale mean calculation unit 130 is used to calculate the average grayscale values ​​of all pixels in each square area to obtain the grayscale mean of each square area.

[0123] For each square area, we traverse all the pixels within it, add up their grayscale values, and then divide by the total number of pixels in the square area to obtain the grayscale mean of the square area. By calculating the grayscale mean of each square area, we can quickly understand the average brightness of each local area, providing a basis for subsequently determining the overall brightness distribution of the image.

[0124] In this embodiment, the calculation formula for the grayscale mean of each square area is:

[0125]

[0126] Where Y ave (i) represents the average grayscale value of all pixels in the i-th square area, where i is 1, 2, 3, ..., M×N, and Y(i)(j) represents the grayscale value of the j-th pixel in the i-th square area, where j is 1, 2, 3, ..., C / (M×N).

[0127] The YUV image mean value calculation unit 140 is used to calculate the minimum grayscale mean value, the maximum grayscale mean value and the average grayscale mean value of the YUV image according to the grayscale mean value of each block area.

[0128] Specifically, the minimum grayscale mean of the YUV image here refers to all Y ave The smallest value in (i). The maximum grayscale mean here refers to the value of all Y ave The maximum value in (i). The average grayscale mean here refers to the average grayscale value of all Y ave (i) Add them up and then divide by the total number of blocks M×N.

[0129] In this embodiment, specifically, the minimum grayscale mean value of the YUV image is Y black , the maximum grayscale mean of the YUV image is Y white , the average grayscale mean of the YUV image is Y mean , then the three quantities are obtained by the following formulas:

[0130] Y black =min{Y ave (i)};

[0131] Y white =max{Y ave (i)};

[0132]

[0133] The weight mapping creation unit 150 is used to establish a first weight mapping relationship and a second weight mapping relationship according to the relationship between the grayscale mean of each block area and the minimum grayscale mean, maximum grayscale mean and average grayscale mean of the YUV image.

[0134] In this embodiment, in order to maintain generality, the closer the grayscale mean is to the average grayscale mean of the YUV image, the greater the weight of the block area, and the farther away, the smaller the weight. Therefore, two different weight mapping relationships can be set, namely, the first weight mapping relationship w small (i) and the second weight mapping relationship wbig (i). w small (i) Mainly focus on Y black Towards Y mean Close to the situation, w big (i) Main Y mean Towards Y white Close situation.

[0135] The first weight mapping relationship and the second weight mapping relationship satisfy the following formula:

[0136]

[0137] Where w small (i) represents the first weight mapping relationship, w big (i) represents the second weight mapping relationship, w1, w2, and w3 represent custom weight values, and w3 is greater than w2, w2 is greater than w1, Y black Indicates the minimum grayscale mean of the YUV image, Y white Indicates the maximum grayscale mean of the YUV image, Y mean Indicates the average grayscale value of the YUV image.

[0138] To facilitate understanding of these two mapping relationships, the specific mapping examples are as follows:

[0139] For w small (i), when Y ave (i) = Y black When w small (i) = w1; when Y ave (i)=(Y mean +Y black ) / 2, w small (i) = w2; Y ave (i) = Y mean When w small (i) = w3.

[0140] For w big (i), when Y ave (i) = Y mean When w big (i)=w3;when Y ave (i)=(Y mean +Y white ) / 2, w big (i)=w2; when Y ave (i) = Y white When w big (i) = w1.

[0141] The weight mapping relationship can reasonably allocate weights according to the grayscale conditions of different block areas, so as to more accurately reflect the characteristics of different brightness areas in subsequent processing, which is crucial for the analysis and processing of backlit scenes.

[0142] The weighted average processing unit 160 is used to perform weighted average processing on the block area between the minimum grayscale mean and the average grayscale mean, and the block area between the average grayscale mean and the maximum grayscale mean according to the first weight mapping relationship and the second weight mapping relationship to obtain a first weighted mean and a second weighted mean.

[0143] Specifically, for the square area belonging to the two grayscale intervals, the grayscale values ​​of the pixels are weighted averaged according to the corresponding weight mapping relationship.

[0144] In this embodiment, the calculation formulas for the first weighted mean and the second weighted mean are as follows:

[0145]

[0146] Where Y small represents the first weighted mean, Y big represents the second weighted mean.

[0147] Through weighted averaging processing, a weighted mean value that can better reflect the characteristics of key brightness areas in the image can be obtained, which helps to accurately judge the intensity of backlit scenes.

[0148] The detection value calculation unit 170 is used to calculate the detection value of the camera's backlight scene intensity based on the first weighted average and the second weighted average.

[0149] In this embodiment, the calculation formula of the detection value of the backlight scene intensity of the camera is as follows:

[0150]

[0151] Where testvalue represents the detection value of the camera's backlight intensity, and its value range is 0 to 1. Generally, the closer the detection value is to 1, the stronger the backlight in the current scene is; conversely, the closer the value is to 0, the weaker the backlight in the current scene is.

[0152] The detection value of the camera's backlight scene intensity can quantitatively represent the intensity of the camera's backlight scene, providing a basis for switching the camera's dynamic range mode.

[0153] The mode switching unit 180 is used to switch the dynamic range mode of the camera according to the detection value of the intensity of the backlight scene of the camera.

[0154] In one embodiment, the mode switching unit 180 includes a first mode switching module and a second mode switching module. The first mode switching module is configured to, when the camera is operating in the first dynamic range mode, switch the camera to the second dynamic range mode if the detection value of the camera's backlight intensity is greater than a first threshold. The second mode switching module is configured to, when the camera is operating in the second dynamic range mode, switch the camera to the first dynamic range mode if the detection value of the camera's backlight intensity is less than a second threshold, where the first threshold is greater than the second threshold.

[0155] The first threshold and the second threshold can be flexibly set according to actual operation. Generally, the first threshold is greater than the second threshold to ensure the stability of system operation.

[0156] Cameras typically have a primary dynamic range mode and a secondary dynamic range mode. The primary dynamic range mode may be the standard dynamic range (SDR) mode, which performs well in generally lit scenes but may cause blown highlights or darkened shadows in scenes with high light contrast, such as backlighting. The secondary dynamic range mode may be the high dynamic range (HDR) mode, which can handle a wider brightness range and better preserve details in highlights and shadows in backlit scenes.

[0157] The first threshold and the second threshold can be flexibly set according to actual operation. Generally, the first threshold is greater than the second threshold to ensure the stability of system operation. Specifically, the first threshold is a pre-set value used to determine when it is necessary to switch from the first dynamic range mode to the second dynamic range mode. The determination of this threshold requires comprehensive consideration of factors such as the performance of the camera and the type of shooting scene. When the calculated detection value of the camera's backlight scene strength is greater than the first threshold, it indicates that the current backlight scene is strong and the SDR mode may not be able to handle it well, and it is necessary to switch to the HDR mode.

[0158] Assume the first dynamic range mode is SDR, and the first threshold is set to 0.6. The camera is capturing an indoor scene. The room is dimly lit, but there is a large window, which creates backlighting. The camera calculates the backlight intensity detection value to be 0.7. Since 0.7 > 0.6, the camera switches from SDR mode to HDR mode. In HDR mode, the camera can better balance the brightness of the highlights in the window and the shadows in the room, resulting in richer details in the entire image.

[0159] Through this switching mechanism, when the camera is in the first dynamic range mode (such as SDR mode) and encounters a strong backlit scene, it can switch to the second dynamic range mode (such as HDR mode) in time, thereby effectively avoiding the problems of overexposed highlights and dark shadows, improving the quality of the captured image, and ensuring that the details in the backlit scene can be clearly captured.

[0160] When the camera is in the second dynamic range mode (such as HDR mode), although it can handle a larger brightness range, in some scenes with relatively uniform lighting, the HDR mode may bring unnecessary computational burden and possible color distortion and other problems. Therefore, a second threshold is set to determine whether it is possible to switch from HDR mode back to SDR mode. The second threshold is smaller than the first threshold. This is because when switching from HDR mode back to SDR mode, it is necessary to ensure that the backlight scene is relatively weak to ensure that a better shooting effect can be obtained in SDR mode. When the detection value of the camera's backlight scene strength is not greater than the second threshold, it indicates that the backlight intensity of the current scene has been reduced to a range that the SDR mode can handle, so the camera is switched back to SDR mode.

[0161] Assume that the second threshold is set to 0.4. After the camera switches to HDR mode, the indoor light changes over time. Perhaps the curtains are partially drawn, or the position of the sun changes, which reduces the backlight intensity. The detection value of the camera's backlight scene intensity is recalculated to be 0.3. Since 0.3≤0.4, the camera will switch from HDR mode back to SDR mode. This can avoid unnecessary resource consumption and possible image quality issues caused by continuing to use HDR mode in scenes that do not require HDR mode. This switching mechanism enables the camera to flexibly switch between different dynamic range modes according to the actual backlight scene intensity. While ensuring that it can process backlight scenes, it optimizes the camera's resource utilization and avoids excessive use of HDR mode in scenes that do not require high dynamic range processing, thereby obtaining better shooting effects in different lighting environments.

[0162] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned dynamic range mode switching device 100 based on the strength of the camera backlight scene and each unit can refer to the corresponding description in the aforementioned method embodiment. For the convenience and brevity of the description, it will not be repeated here.

[0163] The above-mentioned dynamic range mode switching device based on the intensity of the backlight scene of the camera can be implemented in the form of a computer program. The computer program can be used in the following example. Figure 4 Runs on the computer device shown.

[0164] See also Figure 4 , Figure 4 700 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 700 may be a server, wherein the server may be an independent server or a server cluster composed of multiple servers.

[0165] like Figure 4As shown, the computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method for switching the dynamic range mode based on the intensity of the camera backlight scene are implemented.

[0166] The computer device 700 may be a terminal or a server and includes a processor 720 , a memory, and a network interface 750 connected via a system bus 710 , wherein the memory may include a non-volatile storage medium 730 and an internal memory 740 .

[0167] The non-volatile storage medium 730 can store an operating system 731 and a computer program 732. When the computer program 732 is executed, the processor 720 can execute a method for switching dynamic range modes based on the intensity of the backlight scene of the camera.

[0168] The processor 720 is used to provide computing and control capabilities and support the operation of the entire computer device 700.

[0169] The internal memory 740 provides an environment for the operation of the computer program 732 in the non-volatile storage medium 730. When the computer program 732 is executed by the processor 720, the processor 720 can execute a dynamic range mode switching method based on the intensity of the camera backlight scene.

[0170] The network interface 750 is used for network communication, such as sending assigned tasks, etc. It will be understood by those skilled in the art that Figure 4 The structure shown in the figure is merely a block diagram of a portion of the structure related to the present invention and does not limit the computer device 700 to which the present invention is applied. The specific computer device 700 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement. The processor 720 is used to execute program code stored in the memory to implement a method for switching dynamic range modes based on the intensity of the backlight scene in the camera.

[0171] Those skilled in the art will understand that Figure 4 The embodiment of the computer device shown in the figure does not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such an embodiment, the structure and function of the memory and processor are the same as those in the figure. Figure 4 The embodiments shown are consistent and will not be described again here.

[0172] It should be understood that in the embodiment of the present application, the processor 720 may be a central processing unit (CPU), and the processor 720 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0173] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when executed by a processor, the computer program implements the method for switching dynamic range modes based on the intensity of backlighting in a camera, as disclosed in an embodiment of the present invention.

[0174] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. 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 the present invention.

[0175] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, or units with the same function may be combined into one unit. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be an electrical, mechanical or other form of connection.

[0176] The units described as separate components may or may not be physically separate, and 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 these units may be selected according to actual needs to achieve the objectives of the embodiments of the present invention.

[0177] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0178] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.

[0179] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A method for switching dynamic range modes based on the intensity of a camera backlight scene, characterized in that: include: Get the YUV image containing gray value information; Divide all pixels of the YUV image into several square areas; Calculate the average grayscale value of all pixels in each square area to obtain the grayscale mean value of each square area; According to the grayscale mean of each square area, the minimum grayscale mean, maximum grayscale mean and average grayscale mean of the YUV image are calculated respectively; According to the relationship between the grayscale mean of each square area and the minimum grayscale mean, the maximum grayscale mean and the average grayscale mean of the YUV image, a first weight mapping relationship and a second weight mapping relationship are established; Performing weighted averaging processing on the square area between the minimum grayscale mean and the average grayscale mean, and the square area between the average grayscale mean and the maximum grayscale mean according to the first weight mapping relationship and the second weight mapping relationship, so as to obtain a first weighted mean and a second weighted mean; Calculating a detection value of the intensity of the backlight scene of the camera according to the first weighted mean and the second weighted mean; The dynamic range mode of the camera is switched according to the detection value of the intensity of the backlight scene of the camera.

2. The method for switching dynamic range modes based on the intensity of the backlight scene of the camera according to claim 1, characterized in that: The number of pixels contained in each square area is C / (M×N), where M refers to the number of square areas in the length direction of the YUV image, N refers to the number of square areas in the width direction of the YUV image, and C refers to the total number of pixels in the YUV image.

3. The method for switching dynamic range modes based on the intensity of the backlight scene of the camera according to claim 1, characterized in that: The calculation formula for the grayscale mean of each square area is: Where Y ave (i) represents the average grayscale value of all pixels in the i-th square area, where i is 1, 2, 3, ..., M×N, and Y(i)(j) represents the grayscale value of the j-th pixel in the i-th square area, where j is 1, 2, 3, ..., C / (M×N).

4. The method for switching dynamic range modes based on the intensity of the backlight scene of the camera according to claim 1, characterized in that: The first weight mapping relationship and the second weight mapping relationship satisfy the following formula: In the formula, w small (i) represents the first weight mapping relationship, w big (i) represents the second weight mapping relationship, w1, w2, and w3 represent custom weight values, and w3 is greater than w2, w2 is greater than w1, Y black Indicates the minimum grayscale mean of the YUV image, Y white Indicates the maximum grayscale mean of the YUV image, Y mean Represents the average grayscale value of the YUV image.

5. The method for switching dynamic range modes based on the intensity of the backlight scene of the camera according to claim 1, characterized in that: The calculation formulas for the first weighted mean and the second weighted mean are as follows: Where Y small represents the first weighted mean, Y big represents the second weighted mean.

6. The method for switching dynamic range modes based on the intensity of the backlight scene of the camera according to claim 1, characterized in that: The calculation formula of the camera's backlight scene strength detection value is as follows: Where testvalue represents the detection value of the camera's backlight scene strength, and its value range is 0 to 1.

7. The method for switching dynamic range modes based on the intensity of the backlight scene of a camera according to claim 1, characterized in that: The switching of the dynamic range mode of the camera according to the detection value of the intensity of the backlight scene of the camera includes: When the camera is operating in the first dynamic range mode, if the detection value of the camera's backlight scene intensity is detected to be greater than the first threshold, the camera is switched to the second dynamic range mode; When the camera operates in the second dynamic range mode, if the detection value of the camera backlight scene strength is not greater than the second threshold, the camera is switched to the first dynamic range mode, and the first threshold is greater than the second threshold.

8. A dynamic range mode switching device based on the intensity of the camera backlight scene, characterized in that: It includes an acquisition unit, a region division unit, a grayscale mean calculation unit, a YUV image mean calculation unit, a weight mapping creation unit, a weighted average processing unit, a detection value calculation unit, and a mode switching unit; The acquisition unit is used to acquire a YUV image containing gray value information; The area division unit is used to divide all the pixels of the YUV image into a number of square areas; The grayscale mean value calculation unit is used to calculate the average grayscale values ​​of all pixels in each square area to obtain the grayscale mean value of each square area; The YUV image mean value calculation unit is used to calculate the minimum grayscale mean value, the maximum grayscale mean value and the average grayscale mean value of the YUV image according to the grayscale mean value of each square area; The weight mapping creation unit is used to establish a first weight mapping relationship and a second weight mapping relationship according to the relationship between the grayscale mean of each square area and the minimum grayscale mean, the maximum grayscale mean and the average grayscale mean of the YUV image; The weighted average processing unit is used to perform weighted average processing on the block area between the minimum grayscale mean and the average grayscale mean, and the block area between the average grayscale mean and the maximum grayscale mean according to the first weight mapping relationship and the second weight mapping relationship, so as to obtain a first weighted mean and a second weighted mean; The detection value calculation unit is used to calculate the detection value of the camera backlight scene strength according to the first weighted mean and the second weighted mean; The mode switching unit is used to switch the dynamic range mode of the camera according to the detection value of the intensity of the backlight scene of the camera.

9. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for switching the dynamic range mode based on the intensity of the camera backlight scene as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor, the processor executes the dynamic range mode switching method based on the strength of the camera backlight scene as described in any one of claims 1 to 7.