Exposure compensation method and apparatus, and electronic device
This application discloses an exposure compensation method and apparatus, and an electronic device, and pertains to the field of photographing technologies. The exposure compensation method includes: obtaining a target image block of a preview image in a shooting preview screen; and performing exposure compensation on the preview image based on scene type probability of the target image block; or performing exposure compensation on the preview image based on reflectivity of the target image block.
1 . An exposure compensation method, comprising:
obtaining a target image block of a preview image in a shooting preview screen; and
performing exposure compensation on the preview image based on scene type probability of the target image block; or
performing exposure compensation on the preview image based on reflectivity of the target image block;
wherein the performing exposure compensation on the preview image based on scene type probability of the target image block comprises:
extracting features of the target image block at different scales, performing multilevel nonlinear transformation on the features, and outputting a weighted sum of the features;
calculating the scene type probability of the target image block based on the weighted sum of the features;
determining a scene ty of the target image lock sed the scene type probability, wherein the scene type comprises a first scene, a second scene, and a third scene; and
performing exposure compensation on the preview image based on the scene type of the target image block;
wherein the performing exposure compensation on the preview image based on scene type of the target image block comprises:
determining an initial exposure value; and
in a case that the scene type of the target image block is the first scene, increasing a preset exposure value on the basis of the initial exposure value; in a case that the scene type of the target image block is the second scene, decreasing the preset exposure value on the basis of the initial exposure value; and in a case that the scene type of the target image block is the third scene, using the initial exposure value for exposure;
wherein before the performing exposure compensation on the preview image based on reflectivity of the target image block, the method further comprises:
extracting features of the target image block at different scales, and splicing the extracted features with a class feature of the target image block on a channel to obtain fused features;
performing multilevel nonlinear transformation on the fused features, and outputting a weighted sum of the fused features; and
calculating reflectivity of a subject in the target image block based on the weighted sum of the fused features, and determining the reflectivity of the subject as the reflectivity of the target image block.
2 . The method according to claim 1 , the performing exposure compensation on the preview image based on reflectivity of the target image block comprises:
determining an initial exposure value;
determining, based on the reflectivity of the target image block, a target adjustment amount on the basis of the initial exposure value; and
performing exposure compensation on the preview image based on the initial exposure value and the target adjustment amount.
3 . The method according to claim 2 , the performing exposure compensation on the preview image based on the initial exposure value and the target adjustment amount comprises:
in a case that the reflectivity of the target image block is greater than reflectivity of a gray card, increasing the target adjustment amount on the basis of the initial exposure value;
in a case that the reflectivity of the target image block is less than reflectivity of a gray card, decreasing the target adjustment amount on the basis of the initial exposure value; and
in a case that the reflectivity of the target image block is equal to reflectivity of a gray card, using the initial exposure value for exposure.
4 . An electronic device, comprising a processor, a memory, and a program or an instruction stored in the memory and executable on the processor, wherein the program or the instruction, when executed by the processor, causes the electronic device to implement:
obtaining a target image block of a preview image in a shooting preview screen; and
performing exposure compensation on the preview image based on scene type probability of the target image block; or
performing exposure compensation on the preview image based on reflectivity of the target image block;
wherein the performing exposure compensation on the preview image based on scene type probability of the target image block comprises:
extracting features of the target image block at different scales, performing multilevel nonlinear transformation on the features, and outputting a weighted sum of the features;
calculating the scene type probability of the target image block based on the weighted sum of the features;
determining a scene type of the target image block based on the scene type probability, wherein the scene type comprises a first scene, a second scene, and a third scene; and
performing exposure compensation on the preview image based on the scene type of the target image block;
wherein the performing exposure compensation on the preview image based on a scene type of the target image block comprises:
determining an initial exp sure value; and
in a case that the scene type of the target image block is the first scene, increasing a preset exposure value on the basis of the initial exposure value; in a case that the scene type of the target image block is the second scene, decreasing the preset exposure value on the basis of the initial exposure value; and in a case that the scene type of the target image block is the third scene, using the initial exposure value for exposure;
wherein the program or the instruction, when executed by the processor, further causes the electronic device to implement;
before the performing exposure compensation on the preview image based on reflectivity of the target image block,
extracting features of the target image block at different scales, and splicing the extracted features with a class feature of the target image block on a channel to obtain fused features;
performing multilevel nonlinear transformation on the fused features, and outputting a weighted sum of the fused features; and
calculating reflectivity of a subject in the target image block based on the weighted sum of the fused features, and determining the reflectivity of the subject as the reflectivity of the target image block.
5 . The electronic device according to claim 4 , the performing exposure compensation on the preview image based on reflectivity of the target image block comprises:
determining an initial exposure value;
determining, based on the reflectivity of the target image block, a target adjustment amount on the basis of the initial exposure value; and
performing exposure compensation on the preview image based on the initial exposure value and the target adjustment amount.
6 . The electronic device according to claim 5 , the performing exposure compensation on the preview image based on the initial exposure value and the target adjustment amount comprises:
in a case that the reflectivity of the target image block is greater than reflectivity of a gray card, increasing the target adjustment amount on the basis of the initial exposure value;
in a case that the reflectivity of the target image block is less than reflectivity of a gray card, decreasing the target adjustment amount on the basis of the initial exposure value; and
in a case that the reflectivity of the target image block is equal to reflectivity of a gray card, using the initial exposure value for exposure.
7 . A chip, comprising a processor and a communications interface, wherein the communications interface is coupled to the processor, and the processor is configured to run a program or an instruction, to implement steps of the exposure compensation method according to claim 1 .
8 . A non-transitory readable storage medium, wherein the non-transitory readable storage medium stores a program or an instruction, and the program or the instruction is executed by a processor to implement:
obtaining a target image block of a preview image in a shooting preview screen; and
performing exposure compensation on the preview image based on scene type probability of the target image block; or
performing exposure compensation on the preview image based on reflectivity of the target image block;
wherein the performing exposure compensation on the preview image based on scene type probability of the image block comprises:
extracting features of the target image block at different scales, performing multilevel nonlinear transformation on the features, and outputting a weighted sum of the features;
calculating the scene type probability of the target image block based on the weighted sum of the features;
determining a scene type of the target image block based on the scene type probability, wherein the scene type comprises a first scene, a second scene, and a third scene; and
performing exposure compensation on the preview image based on the scene type of the target image block;
wherein the performing exposure compensation on the preview image based on a scene type of the target image block comprises:
determining an initial exposure value; and
in a case that the scene type of the target image block is the first scene, increasing a preset exposure value on the basis of the initial exposure value; in a case that the scene type of the target image block is the second scene, decreasing the preset exposure value on the basis of the initial exposure value; and in a case that the scene type of the target image block is the third scene, using the initial exposure value for exposure;
wherein the program or the instruction is further executed by a processor to implement;
before the performing exposure compensation on the preview image based on reflectivity of the target image block,
extracting features of the target image block at different scales, and splicing the extracted features with a class feature of the target image block on a channel to obtain fused features;
performing multilevel nonlinear transformation on the fused features, and outputting a weighted sum of the fused features; and
calculating reflectivity of a subject in the target image block based on the weighted sum of the fused features, and determining the reflectivity of the subject as the reflectivity of the target image block.
9 . The non-transitory readable storage medium according to claim 8 , the performing exposure compensation on the preview image based on reflectivity of the target image block comprises:
determining an initial exposure value;
determining, based on the reflectivity of the target image block, a target adjustment amount on the basis of the initial exposure value; and
performing exposure compensation on the preview image based on the initial exposure value and the target adjustment amount.
10 . The non-transitory readable storage medium according to claim 9 , the performing exposure compensation on the preview image based on the initial exposure value and the target adjustment amount comprises:
in a case that the reflectivity of the target image block is greater than reflectivity of a gray card, increasing the target adjustment amount on the basis of the initial exposure value;
in a case that the reflectivity of the target image block is less than reflectivity of a gray card, decreasing the target adjustment amount on the basis of the initial exposure value; and
in a case that the reflectivity of the target image block is equal to reflectivity of a gray card, using the initial exposure value for exposure.