Method and device for calculating image definition, equipment and storage medium

By obtaining the brightness information of the image and determining the applicable clarity evaluation function, the problem of poor multimodality and noise immunity of the image clarity evaluation function in the night scene of point light source is solved, and the accuracy of autofocus is improved.

CN120013807APending Publication Date: 2025-05-16BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311523412.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-15
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

In the prior art, in the night scene of point light source, the image clarity evaluation function has multimodality, poor noise resistance and instability, resulting in low autofocus accuracy and prone to loss of focus.

Method used

By acquiring the first brightness information and the second brightness information of the image, an applicable clarity evaluation function is determined. The first brightness information represents the overall brightness information of the image, and the second brightness information represents the brightness information of the non-light source region. Depending on different light source scenes, different clarity evaluation functions are selected, such as evaluation functions based on gradient information or light source size change rate.

Benefits of technology

By adapting to the clarity evaluation function of different light source scenes, the accuracy of image clarity is improved, and the impact of light sources on image clarity calculation is reduced, thereby improving the focus accuracy in automatic focus technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120013807A_ABST
    Figure CN120013807A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for calculating image definition, equipment and a storage medium. The method for calculating the image definition comprises the steps that first brightness information and second brightness information of a first image are obtained, the first brightness information represents overall brightness information of the first image, and the second brightness information represents brightness information of a non-light-source area in the first image; according to the first brightness information and the second brightness information, a definition evaluation function is determined, and the definition evaluation function is used for evaluating the definition of each frame of image collected continuously; and determining the definition of each image acquired after the first image based on the definition evaluation function. According to the method, the definition evaluation function is determined according to the light source condition of the first image, so that the definition evaluation function can adapt to the current light source condition, the influence of the light source on image definition calculation is avoided, and the determined definition of each image is more accurate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to a method, device, equipment and storage medium for calculating image clarity. Background Art

[0002] With the continuous breakthroughs in digital image processing technology, autofocus technology based on digital image processing has been widely used in various optical imaging systems. Autofocus technology based on digital image processing uses the image clarity evaluation function to calculate and evaluate the image clarity. According to the image clarity value and the autofocus search algorithm, the lens is driven to adjust its position until the lens position corresponding to the maximum image clarity is found, which is the focus position. Therefore, the key to improving autofocus accuracy lies in how to improve the quality of the image clarity evaluation function. Summary of the invention

[0003] In order to overcome the problems existing in the related art, the present disclosure provides a method, device, equipment and storage medium for calculating image clarity.

[0004] According to a first aspect of an embodiment of the present disclosure, a method for calculating image clarity is provided, the method comprising:

[0005] Acquire first brightness information and second brightness information of a first image, wherein the first brightness information represents overall brightness information of the first image, and the second brightness information represents brightness information of a non-light source area in the first image;

[0006] Determine a clarity evaluation function according to the first brightness information and the second brightness information, wherein the clarity evaluation function is used to evaluate the clarity of each frame of the continuously acquired image;

[0007] Based on the clarity evaluation function, the clarity of each image acquired after the first image is determined.

[0008] In an exemplary embodiment, acquiring first brightness information of a first image includes:

[0009] The first brightness information is determined according to a ratio of the number of pixels in the first image whose brightness values ​​are greater than a first value to the number of all pixels in the first image, wherein the first value is a preset ratio of a maximum brightness value in the first image.

[0010] In an exemplary embodiment, obtaining second brightness information of a first image includes:

[0011] Acquire a target area in the first image, wherein the brightness value of the pixel points in the target area is greater than a brightness threshold;

[0012] Determine a first light source area and a first non-light source area in the target area;

[0013] The second brightness information is determined according to the brightness values ​​of all pixels in the first non-light source area.

[0014] In an exemplary embodiment, the method further comprises:

[0015] The brightness threshold is determined according to the first brightness information and a mapping relationship, where the mapping relationship is a mapping relationship between the first brightness information and the brightness threshold.

[0016] In an exemplary embodiment, obtaining second brightness information of a first image includes:

[0017] Determine a second light source area and a second non-light source area in the first image;

[0018] The second brightness information is determined according to the brightness values ​​of the pixels in the second non-light source area.

[0019] In an exemplary embodiment, determining a clarity evaluation function according to the first brightness information and the second brightness information includes:

[0020] If the first brightness information and the second brightness information meet a first condition, determining that the clarity evaluation function is a first clarity evaluation function;

[0021] If the first brightness information and the second brightness information satisfy a second condition, the clarity evaluation function is determined to be a second clarity evaluation function, and the second clarity evaluation function is different from the first clarity evaluation function.

[0022] In an exemplary embodiment, the first condition characterizes that the first image is a small light source scene and the brightness information of the non-light source area is within a first range, and the first clarity evaluation function characterizes the mapping relationship between image clarity and gradient information of each pixel in the image.

[0023] In an exemplary embodiment, the first clarity evaluation function is:

[0024]

[0025] Among them, fv represents the image clarity, I(i+1+n,j) represents the pixel value of the vertical neighborhood pixel point (i+1+n,j), I(i,j+1+n) represents the pixel value of the horizontal neighborhood pixel point (i,j+1+n), I(i,j) represents the pixel value of the pixel point (i,j), and N represents the step size.

[0026] In an exemplary embodiment, the second condition represents that the first image is a large light source scene or the first image is a small light source scene and the brightness information of the non-light source area is within a second range, and the second clarity evaluation function represents the mapping relationship between image clarity and the rate of change of light source size in the image.

[0027] In an exemplary embodiment, the second clarity evaluation function is:

[0028]

[0029] Where fv represents the image clarity, α represents the preset index and α>1, represents the ratio of the number of pixels in the light source area in the target area of ​​the first image to the number of all pixels in the target area of ​​the first image, It represents the ratio of the number of pixels in the light source area in the target area of ​​the current image to the number of all pixels in the target area of ​​the current image.

[0030] According to a second aspect of an embodiment of the present disclosure, a device for calculating image clarity is provided, the device comprising:

[0031] an acquisition module, configured to acquire first brightness information and second brightness information of a first image, wherein the first brightness information represents overall brightness information of the first image, and the second brightness information represents brightness information of a non-light source area in the first image;

[0032] A determination module is configured to determine a clarity evaluation function according to the first brightness information and the second brightness information, wherein the clarity evaluation function is used to evaluate the clarity of each frame of the continuously acquired image;

[0033] The processing module is configured to determine the clarity of each image collected after the first image based on the clarity evaluation function.

[0034] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0035] processor;

[0036] a memory for storing processor-executable instructions;

[0037] The processor is configured to execute the method as described in the first aspect of the embodiment of the present disclosure.

[0038] According to a fourth aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method described in the first aspect of the embodiment of the present disclosure.

[0039] Adopting the above-mentioned method of the present invention has the following beneficial effects: the overall brightness information of the first image and the brightness information of the non-light source area are determined through the first brightness information and the second brightness information, so that the light source situation of the first image can be known, and the clarity evaluation function is determined according to the first brightness information and the second brightness information, so that the clarity evaluation function can be adapted to the current light source situation to avoid the influence of the light source on the image clarity calculation, so that the clarity of each determined image is more accurate.

[0040] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0042] Figure 1 is a flow chart of a method for calculating image clarity according to an exemplary embodiment;

[0043] Figure 2 is a flow chart of a method for calculating image clarity according to an exemplary embodiment;

[0044] Figure 3 is a schematic diagram of pixels in a first image according to an exemplary embodiment;

[0045] Figure 4A is a schematic diagram of a small light source scene according to an exemplary embodiment;

[0046] Figure 4B is a schematic diagram of a first clarity evaluation function curve according to an exemplary embodiment;

[0047] Figure 4C is a schematic diagram showing a comparison of clarity evaluation function curves according to an exemplary embodiment;

[0048] Figure 5A is a schematic diagram of a large light source scene according to an exemplary embodiment;

[0049] Figure 5B is a schematic diagram of a first clarity evaluation function curve according to an exemplary embodiment;

[0050] Figure 5C is a schematic diagram showing a comparison of clarity evaluation function curves according to an exemplary embodiment;

[0051] Figure 6is a block diagram of a device for calculating image definition according to an exemplary embodiment;

[0052] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0054] In some embodiments, the image clarity evaluation function includes a gradient function, a variance function, a frequency domain function, and an entropy function, and the quality of the clarity evaluation function depends on its unimodality, accuracy, steepness, and stability. In a point light source night scene, since the pixels in the point light source area are saturated pixels, when the image is in a defocused state, the point light source is diffused, and the saturated pixel area will increase as the defocus degree increases, thereby affecting the actual light source situation in the scene. At this time, the above-mentioned image clarity evaluation function will have multiple pseudo peaks, causing the autofocus search algorithm to fall into a local peak. In a point light source night scene, due to the multi-peaks, poor noise resistance, and instability of the clarity evaluation function curve, the image clarity evaluation function cannot reflect the clarity of the image, and cannot find the maximum value of the image clarity, resulting in the image being out of focus in this scene.

[0055] In some embodiments, when calculating the image clarity for a night scene with a point light source, a saturated pixel template is usually used to remove saturated pixels in the image to obtain an image clarity evaluation function with saturated pixels removed. However, when the point light source is large, when the image clarity is calculated using the image clarity evaluation function with saturated pixels removed, less available image information remains in the image, and the accuracy of the image clarity calculated by the function decreases, resulting in a higher defocus rate; and, due to the influence of the large light source, even if the saturated pixels are removed, the subject area in the image is susceptible to the light source, which also reduces the accuracy of the image clarity and is prone to defocus problems. When the point light source is small and the subject area is dark overall, the image details are severely lost, the contrast is low, and the noise is large. At this time, when the clarity is calculated for the area with saturated pixels removed, the accuracy of the clarity will be greatly affected, resulting in a large defocus rate.

[0056] Therefore, the key to improving the focusing accuracy of point light source night scenes lies in selecting an image clarity evaluation function suitable for the scene.

[0057] In an exemplary embodiment of the present disclosure, in order to overcome the problem of low image clarity accuracy existing in the related art, a method for calculating image clarity is provided, including: obtaining first brightness information and second brightness information of a first image, the first brightness information representing the overall brightness information of the first image, and the second brightness information representing the brightness information of the non-light source area in the first image; determining a clarity evaluation function based on the first brightness information and the second brightness information, the clarity evaluation function being used to evaluate the clarity of each frame of the continuously collected image; and determining the clarity of each image collected after the first image based on the clarity evaluation function. The method in the embodiment of the present disclosure can determine the clarity evaluation function based on the brightness information in the image, so that the clarity evaluation function is applicable to the current light source condition, so that the calculated clarity of each image is more accurate.

[0058] In an exemplary embodiment of the present disclosure, a method for calculating image clarity is provided. Figure 1 is a flow chart of a method for calculating image clarity according to an exemplary embodiment. Figure 1 As shown, the following steps are included:

[0059] Step S101, obtaining first brightness information and second brightness information of a first image, wherein the first brightness information represents the overall brightness information of the first image, and the second brightness information represents the brightness information of a non-light source area in the first image;

[0060] Step S102, determining a clarity evaluation function according to the first brightness information and the second brightness information, where the clarity evaluation function is used to evaluate the clarity of each frame of the continuously acquired image;

[0061] Step S103: determining the clarity of each image collected after the first image based on the clarity evaluation function.

[0062] The method in the disclosed embodiments is applied to electronic devices, including smart phones, tablets, smart watches, smart monitoring devices and other electronic devices with image capture functions. The application scenarios are autofocus scenarios when capturing night scene images of point light sources or other scenarios that require clarity calculation for multiple frames of continuously captured night scene images, where the multiple frames of night scene images all correspond to the same captured picture.

[0063] In step S101, the first image represents the first few frames of the continuously acquired multiple frames of night scene images, for example, the first frame or the second frame of the continuously acquired multiple frames. The first brightness information and the second brightness information can be determined by the grayscale value or pixel value of the pixel in the first image. The overall brightness information of the first image can reflect the light source scene in the first image. If the image is brighter as a whole, it means that the first image is a large light source scene; if the image is darker as a whole, it means that the first image is a small light source scene. The brightness information of the non-light source area in the first image can reflect the brightness effect of the light source on the subject area. If the non-light source area is brighter or darker, it means that the light source has a greater impact on the brightness of the subject area. If the non-light source area is at a normal brightness, it means that the light source has a smaller impact on the brightness of the subject area. Among them, the subject area is the area other than the light source.

[0064] In step S102, since different light source conditions have different effects on image clarity, and the first brightness information and the second brightness information can reflect the light source conditions in the first image, the clarity evaluation function is determined according to the first brightness information and the second brightness information, so that the clarity evaluation function can be adapted to the light source conditions of the current image to avoid the influence of the light source on the clarity calculation. By calculating the clarity of each frame of the continuously acquired image through the determined clarity evaluation function, a clarity value with high accuracy can be obtained.

[0065] When the first brightness information and the second brightness information meet different conditions, different clarity evaluation functions are determined. For example, when the first image is determined to be a large light source scene according to the first brightness information, since the light source in the large light source scene has a greater influence on the brightness of the subject area, there is no need to further determine the second brightness information. At this time, if the image clarity evaluation function is determined based on the pixel value of the pixel point of the image, it will cause the problem of low accuracy of the clarity value, so it should be avoided to determine the image clarity evaluation function based on the pixel value of the pixel point of the image; when the first image is determined to be a small light source scene according to the first brightness information, if the brightness of the small light source is very large or very small, it will have a greater impact on the brightness of the subject area, and it should also be avoided to determine the image clarity evaluation function based on the pixel value of the pixel point of the image. If the brightness of the small light source is within the normal brightness range, it will not have a greater impact on the brightness of the subject area, and the subject area will be illuminated by the small light source. At this time, the image clarity evaluation function is determined based on the pixel value of the pixel point of the image, and a clarity value with higher accuracy can be obtained.

[0066] In step S103, the clarity values ​​of the images collected after the first image are calculated according to the determined clarity evaluation function. In the autofocus scenario, the frame with the highest clarity can be determined according to the clarity values ​​of the images, and the lens is driven to the lens position when the frame is collected to determine the focus position.

[0067] In an exemplary embodiment of the present disclosure, the overall brightness information of the first image and the brightness information of the non-light source area are determined through the first brightness information and the second brightness information, so the light source situation of the first image can be known. According to the first brightness information and the second brightness information, a clarity evaluation function is determined, and the clarity evaluation function can be adapted to the current light source situation to avoid the influence of the light source on the image clarity calculation, so that the clarity of each determined image is more accurate, thereby improving the focusing accuracy in the autofocus technology or the accuracy of other uses.

[0068] In an exemplary embodiment of the present disclosure, a method for calculating image clarity is provided. Figure 2 is a flow chart of a method for calculating image clarity according to an exemplary embodiment. Figure 2 As shown, the following steps are included:

[0069] Step S201, determining first brightness information according to a ratio of the number of pixels in the first image whose brightness values ​​are greater than a first value to the number of all pixels in the first image, wherein the first value is a preset ratio of a maximum brightness value in the first image;

[0070] Step S202, obtaining second brightness information of the first image;

[0071] Step S203, determining a condition satisfied by the first brightness information and the second brightness information;

[0072] If the first brightness information and the second brightness information meet the first condition, execute step S204; if the first brightness information and the second brightness information meet the second condition, execute step S205;

[0073] Step S204, determining the clarity evaluation function as a first clarity evaluation function;

[0074] Step S205 , determining that the clarity evaluation function is a second clarity evaluation function, where the second clarity evaluation function is different from the first clarity evaluation function.

[0075] Step S206: determining the clarity of each image collected after the first image based on the clarity evaluation function.

[0076] In step S201, the brightness value can be determined by the pixel value or grayscale value of the pixel point, and the maximum brightness value among the brightness values ​​of all the pixels of the first image is determined. The preset ratio of the maximum brightness value is recorded as the first value, and the number of pixels in the first image whose brightness value is greater than the first value and the number of all the pixels in the first image are counted, and the ratio of the two is the first brightness information. Since the pixel point with the maximum brightness value in the point light source night scene is the pixel point where the center of the light source is located, the preset ratio is a value that can characterize the brightness range of the point light source, for example, the preset ratio is 75%. If the number of pixels with brightness values ​​greater than the first value accounts for a high proportion, it means that the brightness range of the point light source in the image is large, indicating that it is a large light source scene; if the number of pixels with brightness values ​​greater than the first value accounts for a low proportion, it means that the brightness range of the point light source in the image is small, indicating that it is a small light source scene.

[0077] In one example, the preset ratio is 75%, and the brightness values ​​in the first image that are greater than the first value I 75% The number of pixels in the first image is recorded as m, and the number of all pixels in the first image is recorded as M. Then the first brightness information p1 is expressed as:

[0078] In step S202, the second brightness information is obtained in one of the following two ways:

[0079] The first one includes the following steps:

[0080] S21-1, acquiring a target area in the first image, wherein the brightness value of the pixel points in the target area is greater than a brightness threshold.

[0081] The brightness threshold is an empirical value and is used to obtain the target area in the first image. When dividing the light source area and the non-light source area, the pixels with lower brightness values ​​in the image will affect the classification effect and classification speed. For example, the pixels with lower brightness values ​​account for 1 / 2 of all pixels. When dividing the light source area and the non-light source area, it is easy to divide the pixels with lower brightness values ​​into the non-light source area, but the image information of this part of the area is seriously lost, which will reduce the accuracy of subsequent calculations.

[0082] In some possible implementations, the brightness threshold is determined according to the first brightness information and a mapping relationship, where the mapping relationship is a mapping relationship between the first brightness information and the brightness threshold.

[0083] Because the pixels with lower brightness values ​​are different in different light source scenes, for example, in a small light source scene, the pixel with a grayscale value of 0 is a pixel with a lower brightness value, and in a large light source scene, the pixel with a grayscale value of the minimum grayscale value is a pixel with a lower brightness value. Therefore, when the first brightness information is different, the brightness threshold is also different, which can more accurately filter out the pixels with lower brightness values.

[0084] The mapping relationship between the first brightness information and the brightness threshold can be a functional relationship between the first brightness information and the brightness threshold, and the first brightness information is input into the functional relationship to obtain the brightness threshold; it can also be a mapping relationship table between the first brightness information or the brightness range and the brightness threshold, and the corresponding brightness threshold is queried from the mapping relationship table according to the first brightness information or the brightness range to which the first brightness information belongs.

[0085] In one example, the brightness information is determined by the grayscale value of the pixel. The first brightness information is recorded as p1, and the brightness threshold is recorded as Q. Table 1 shows the mapping relationship between the first brightness information and the brightness threshold, where I 75% represents 75% of the maximum grayscale value in the first image, I mid Represents the median grayscale value of all pixels in the first image, I min represents the minimum grayscale value in the first image, max(I mid ,I 75% ) means taking I mid and I 75% The maximum value in min(I mid ,I 75% ) means taking I mid and I 75% For example, if the grayscale values ​​of all pixels in the first image are 1, 2, 3, 4, and 5 respectively, then I 75% 5×75%=3.75, I mid is 3, I min is 1, max(I mid ,I 75% ) is 3.75, min(I mid ,I 75% ) is 3. As shown in Table 1, according to the range to which the first brightness information belongs, the brightness threshold corresponding thereto can be determined.

[0086] Table 1

[0087]

[0088] S21 - 2 , determining a first light source area and a first non-light source area in the target area.

[0089] The pixels in the target area are classified into a first light source area and a first non-light source area according to their brightness values. For example, a fuzzy clustering algorithm is used for the classification, and the area with a larger cluster center is the first light source area, and the other areas in the target area are the first non-light source areas.

[0090] S21 - 3 , determining second brightness information according to the brightness values ​​of all pixels in the first non-light source area.

[0091] An average value of the brightness values ​​of all pixels in the first non-light source area is determined as the second brightness information.

[0092] This method filters the pixels in the first image through a brightness threshold, selects the brighter pixels in the first image, and deletes the darker pixels in the first image. When performing binary classification on the target area to extract the light source area, it can improve the classification effect and classification speed, and improve the accuracy of the division of the light source area and the non-light source area.

[0093] The second method includes the following steps:

[0094] S22-1, determining a second light source area and a second non-light source area in the first image.

[0095] The pixels in the first image are classified into a second light source area and a second non-light source area according to their brightness values. For example, a fuzzy clustering algorithm is used for the classification, and the area with a larger cluster center is the second light source area, and the other areas are the second non-light source area.

[0096] S22-2, determining second brightness information according to the brightness values ​​of the pixels in the second non-light source area.

[0097] An average value of the brightness values ​​of all pixels in the second non-light source area is determined as the second brightness information.

[0098] In step S203, determining conditions satisfied by the first brightness information and the second brightness information;

[0099] If the first brightness information and the second brightness information meet the first condition, execute step S204; if the first brightness information and the second brightness information meet the second condition, execute step S205;

[0100] When the first image is a scene with a large light source, the light source has a relatively large influence on the brightness of the subject area, and it is necessary to avoid determining the image clarity evaluation function based on the pixel values ​​of the image pixels. When the first image is a scene with a small light source, if the brightness of the small light source is very large or very small, it will have a relatively large influence on the brightness of the subject area, and it is also necessary to avoid determining the image clarity evaluation function based on the pixel values ​​of the image pixels. If the brightness of the small light source is within the normal brightness range, it will not have a relatively large influence on the brightness of the subject area, and the subject area will be illuminated by the small light source. At this time, determining the image clarity evaluation function based on the pixel values ​​of the image pixels can obtain a clarity value with high accuracy. Therefore, the scene with a small light source and the brightness of the small light source having a relatively small influence on the brightness of the subject area is classified as one case, and the scene with a large light source and the scene with a small light source and the small light source having a relatively large influence on the brightness of the subject area are classified as another case.

[0101] The first condition indicates that the first image is a small light source scene and the brightness information of the non-light source area is within a first range, and the second condition indicates that the first image is a large light source scene or the first image is a small light source scene and the brightness information of the non-light source area is within a second range, wherein the first range indicates that the non-light source area is in a normal brightness range, indicating that the brightness of the small light source has little effect on the brightness of the subject area; the second range indicates that the non-light source area is brighter or darker, indicating that the small light source has a greater effect on the brightness of the subject area.

[0102] In some embodiments, the first brightness information is recorded as p1, and the second brightness information is recorded as I mean , the first range is greater than 35 and less than or equal to 165, and the second range is the grayscale value range outside the first range, then the first condition is expressed as: And 35 mean ≤165, the second condition is expressed as: or And I mean ≤35 or And I mean >165.

[0103] In step S204, the clarity evaluation function is determined to be a first clarity evaluation function.

[0104] The first clarity evaluation function represents the mapping relationship between image clarity and the gradient information of each pixel in the image. The gradient information is a multi-step differential mean gradient value. The gradient information of each pixel in the first image is calculated. Figure 3 is a schematic diagram of pixels in a first image according to an exemplary embodiment. Figure 3 As shown, C 1,1 Indicates the pixel point for which the gradient information is currently to be calculated, C 1,2 , C 1,3 , C 1,4 represents its horizontal neighborhood pixel, C 2,1 , C 3,1 , C 4,1 represents its vertical neighborhood pixel. Both the horizontal area and the vertical neighborhood include three pixels, so the step size is 3. The step difference mean gradient value represents the sum of the square differences between each neighborhood pixel and the current pixel within the step range. Then the average value is calculated for each step, so the pixel C 1,1 The gradient information T is:

[0105]

[0106] Where T represents the pixel C 1,1 Gradient information of pixel C, I(1,1) represents 1,1 The pixel value of I(1+1+n,1) represents the pixel point C​1,1 The vertical neighborhood pixel C 2,1 , C 3,1 , C 4,1 The pixel value of I(1,1+1+n) represents the pixel point C 1,1 The horizontal neighborhood pixel C 1,2 , C 1,3 , C 1,4 The pixel value of .

[0107] The image clarity is the sum of the gradient information of each pixel. When the step size is 3, the first clarity evaluation function is:

[0108]

[0109] Among them, fv represents the image clarity, I(i+1+n,j) represents the pixel value of the vertical neighborhood pixel point (i+1+n,j), I(i,j+1+n) represents the pixel value of the horizontal neighborhood pixel point (i,j+1+n), and I(i,j) represents the pixel value of the pixel point (i,j).

[0110] In some implementations, the first clarity evaluation function is:

[0111]

[0112] Among them, fv represents the image clarity, I(i+1+n,j) represents the pixel value of the vertical neighborhood pixel point (i+1+n,j), I(i,j+1+n) represents the pixel value of the horizontal neighborhood pixel point (i,j+1+n), I(i,j) represents the pixel value of the pixel point (i,j), and N represents the step size.

[0113] In step S205 , the clarity evaluation function is determined to be a second clarity evaluation function.

[0114] The second clarity evaluation function characterizes the mapping relationship between image clarity and the rate of change of the size of the light source in the image. The size of the light source is determined by the ratio of the number of pixels in the light source area to the number of all pixels. The number of pixels in the light source area is recorded as N, and the number of all pixels is recorded as N. total , then the light source size is the pixel ratio of the light source area for: The light source area may be a light source area divided in the first image, or may be a light source area divided in the target area.

[0115] For the first image in a large light source scene, a large number of saturated pixels will appear in the out-of-focus state, resulting in a larger divided light source area. Therefore, the smaller the proportion of light source area pixels, the smaller the saturated pixels and the clearer the image. Therefore, the light source size is inversely proportional to Proportional to the image clarity. The clarity of the first image is recorded as fv1. Recorded as The definition of the image acquired after the first image is recorded as fv2. Recorded as but Therefore, the ratio of the reciprocal of the size of the light source of the current frame image to the reciprocal of the size of the light source of the first image can reflect the ratio between the clarity of the current frame image and the clarity of the first image. If the clarity of the first image is a fixed value, it can reflect the clarity of the current frame image. Among them, the ratio of the reciprocal of the size of the light source of the current frame image to the reciprocal of the size of the light source of the first image is the light source size change rate. The greater the light source size change rate, the higher the image clarity.

[0116] In some implementations, the second clarity evaluation function is:

[0117]

[0118] Where fv represents the image clarity, α represents the preset index and α>1, represents the ratio of the number of pixels in the light source area in the target area of ​​the first image to the number of all pixels in the target area of ​​the first image, Indicates the ratio of the number of light source area pixels in the target area of ​​the current image to the number of all pixels in the target area of ​​the current image.

[0119] In step S206, the clarity of each image acquired after the first image is determined based on the clarity evaluation function.

[0120] In some embodiments, Figure 4A is a schematic diagram of a small light source scene according to an exemplary embodiment. Figure 4A As shown, the subject area under different defocus states is less affected by the light source, and the first clarity evaluation function is used at this time. Figure 4B is a schematic diagram of a first clarity evaluation function curve according to an exemplary embodiment. Figure 4B As shown, the horizontal axis represents the image sequence continuously collected during the autofocus process, and the vertical axis represents the clarity value of each image. It can be seen that the first clarity evaluation function curve has only one peak, has a single peak type, and has good noise resistance and stability. Therefore, when combined with the search algorithm for autofocus, the lens position of the image with the highest clarity can be found accurately and quickly. Figure 4C is a schematic diagram showing a comparison of clarity evaluation function curves according to an exemplary embodiment. Figure 4CAs shown, curve a represents the first clarity evaluation function curve, curve b represents the conventional clarity evaluation function curve after removing saturated pixels in the prior art, the horizontal axis represents the image sequence continuously collected during the autofocus process, and the vertical axis represents the clarity value of each image. It can be seen that curve b has multiple pseudo peaks and poor stability. When combined with the search algorithm for autofocus, it is easy to fall into the local maximum value.

[0121] In some embodiments, Figure 5A is a schematic diagram of a large light source scene according to an exemplary embodiment. Figure 5A As shown, in a scene with a large light source, there are many saturated pixels, and the subject area under different defocus states is greatly affected by the light source. At this time, the second clarity evaluation function is used. Figure 5B is a schematic diagram of a first clarity evaluation function curve according to an exemplary embodiment. Figure 5B As shown, the horizontal axis represents the image sequence continuously collected during the autofocus process, and the vertical axis represents the clarity value of each image. It can be seen that the second clarity evaluation function curve has only one peak, has a single-peak type, and has good noise resistance and stability. Therefore, when combined with the search algorithm for autofocus, the lens position of the image with the highest clarity can be found accurately and quickly. Figure 5C is a schematic diagram showing a comparison of clarity evaluation function curves according to an exemplary embodiment. Figure 5C As shown, curve a represents the second clarity evaluation function curve, curve b represents the conventional clarity evaluation function curve after removing saturated pixels in the prior art, the horizontal axis represents the image sequence continuously collected during the autofocus process, and the vertical axis represents the clarity value of each image. It can be seen that curve b has multiple pseudo peaks and poor stability. When combined with the search algorithm for autofocus, it is easy to fall into the local maximum value.

[0122] Therefore, the method for calculating image clarity in the present disclosure can determine an applicable clarity evaluation function according to the light source conditions to ensure the accuracy of the clarity of continuously acquired multiple frames of images calculated using the clarity evaluation function.

[0123] In an exemplary embodiment of the present disclosure, a device for calculating image clarity is provided. Figure 6 is a block diagram of a device for calculating image definition according to an exemplary embodiment. Figure 6 As shown, the device comprises:

[0124] An acquisition module 601 is configured to acquire first brightness information and second brightness information of a first image, wherein the first brightness information represents overall brightness information of the first image, and the second brightness information represents brightness information of a non-light source area in the first image;

[0125] A determination module 602 is configured to determine a clarity evaluation function according to the first brightness information and the second brightness information, where the clarity evaluation function is used to evaluate the clarity of each frame of the continuously acquired image;

[0126] The processing module 603 is configured to determine the clarity of each image collected after the first image based on the clarity evaluation function.

[0127] In an exemplary embodiment, the acquisition module 601 is further configured to:

[0128] The first brightness information is determined according to a ratio of the number of pixels in the first image whose brightness values ​​are greater than a first value to the number of all pixels in the first image, wherein the first value is a preset ratio of a maximum brightness value in the first image.

[0129] In an exemplary embodiment, the acquisition module 601 is further configured to:

[0130] Acquire a target area in the first image, wherein the brightness value of the pixel points in the target area is greater than a brightness threshold;

[0131] Determine a first light source area and a first non-light source area in the target area;

[0132] The second brightness information is determined according to the brightness values ​​of all pixels in the first non-light source area.

[0133] In an exemplary embodiment, the acquisition module 601 is further configured to:

[0134] A brightness threshold is determined according to the first brightness information and a mapping relationship, where the mapping relationship is a mapping relationship between the first brightness information and the brightness threshold.

[0135] In an exemplary embodiment, the acquisition module 601 is further configured to:

[0136] Determine a second light source area and a second non-light source area in the first image;

[0137] The second brightness information is determined according to the brightness value of the pixel point in the second non-light source area.

[0138] In an exemplary embodiment, the determination module 602 is further configured to:

[0139] If the first brightness information and the second brightness information meet the first condition, determining the clarity evaluation function to be the first clarity evaluation function;

[0140] If the first brightness information and the second brightness information satisfy the second condition, the clarity evaluation function is determined to be a second clarity evaluation function, and the second clarity evaluation function is different from the first clarity evaluation function.

[0141] In an exemplary embodiment, the first condition represents that the first image is a small light source scene and the brightness information of the non-light source area is within a first range, and the first clarity evaluation function represents the mapping relationship between the image clarity and the gradient information of each pixel in the image.

[0142] In an exemplary embodiment, the first clarity evaluation function is:

[0143]

[0144] Among them, fv represents the image clarity, I(i+1+n,j) represents the pixel value of the vertical neighborhood pixel point (i+1+n,j), I(i,j+1+n) represents the pixel value of the horizontal neighborhood pixel point (i,j+1+n), I(i,j) represents the pixel value of the pixel point (i,j), and N represents the step size.

[0145] In an exemplary embodiment, the second condition characterizes that the first image is a large light source scene or the first image is a small light source scene and the brightness information of the non-light source area is within a second range, and the second clarity evaluation function characterizes the mapping relationship between image clarity and the rate of change of light source size in the image.

[0146] In an exemplary embodiment, the second clarity evaluation function is:

[0147]

[0148] Where fv represents the image clarity, α represents the preset index and α>1, represents the ratio of the number of pixels in the light source area in the target area of ​​the first image to the number of all pixels in the target area of ​​the first image, Indicates the ratio of the number of light source area pixels in the target area of ​​the current image to the number of all pixels in the target area of ​​the current image.

[0149] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0150] Figure 7 is a block diagram of an electronic device 700 according to an exemplary embodiment.

[0151] Reference Figure 7 , the electronic device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .

[0152] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.

[0153] The memory 704 is configured to store various types of data to support operations on the electronic device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0154] The power supply component 706 provides power to various components of the electronic device 700. The power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 700.

[0155] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0156] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.

[0157] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0158] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 can detect the open / closed state of the electronic device 700, the relative positioning of components, such as the display and keypad of the electronic device 700, and the sensor assembly 714 can also detect the position change of the electronic device 700 or a component of the electronic device 700, the presence or absence of user contact with the electronic device 700, the orientation or acceleration / deceleration of the electronic device 700, and the temperature change of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0159] The communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices. The electronic device 700 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0160] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0161] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by a processor 720 of an electronic device 700 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0162] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a method for calculating image clarity, wherein the method includes any of the above methods.

[0163] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0164] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for calculating image clarity, characterized in that: The method comprises: Acquire first brightness information and second brightness information of a first image, wherein the first brightness information represents overall brightness information of the first image, and the second brightness information represents brightness information of a non-light source area in the first image; Determine a clarity evaluation function according to the first brightness information and the second brightness information, wherein the clarity evaluation function is used to evaluate the clarity of each frame of the continuously acquired image; Based on the clarity evaluation function, the clarity of each image acquired after the first image is determined.

2. The method according to claim 1, characterized in that The acquiring first brightness information of the first image includes: The first brightness information is determined according to a ratio of the number of pixels in the first image whose brightness values ​​are greater than a first value to the number of all pixels in the first image, wherein the first value is a preset ratio of a maximum brightness value in the first image.

3. The method according to claim 1, characterized in that: Acquiring second brightness information of the first image, including: Acquire a target area in the first image, wherein the brightness value of the pixel points in the target area is greater than a brightness threshold; Determine a first light source area and a first non-light source area in the target area; The second brightness information is determined according to the brightness values ​​of all pixels in the first non-light source area.

4. The method according to claim 3, characterized in that The method further comprises: The brightness threshold is determined according to the first brightness information and a mapping relationship, where the mapping relationship is a mapping relationship between the first brightness information and the brightness threshold.

5. The method according to claim 1, characterized in that Acquiring second brightness information of the first image, including: Determine a second light source area and a second non-light source area in the first image; The second brightness information is determined according to the brightness values ​​of the pixels in the second non-light source area.

6. The method according to claim 1, characterized in that The determining of a clarity evaluation function according to the first brightness information and the second brightness information comprises: If the first brightness information and the second brightness information meet a first condition, determining that the clarity evaluation function is a first clarity evaluation function; If the first brightness information and the second brightness information satisfy a second condition, the clarity evaluation function is determined to be a second clarity evaluation function, and the second clarity evaluation function is different from the first clarity evaluation function.

7. The method according to claim 6, characterized in that The first condition represents that the first image is a small light source scene and the brightness information of the non-light source area is within a first range, and the first clarity evaluation function represents the mapping relationship between image clarity and gradient information of each pixel in the image.

8. The method according to claim 7, characterized in that The first clarity evaluation function is: Among them, fv represents the image clarity, I(i+1+n,j) represents the pixel value of the vertical neighborhood pixel point (i+1+n,j), I(i,j+1+n) represents the pixel value of the horizontal neighborhood pixel point (i,j+1+n), I(i,j) represents the pixel value of the pixel point (i,j), and N represents the step size.

9. The method according to claim 6, characterized in that The second condition represents that the first image is a large light source scene or the first image is a small light source scene and the brightness information of the non-light source area is within a second range, and the second clarity evaluation function represents the mapping relationship between image clarity and the rate of change of light source size in the image.

10. The method according to claim 9, characterized in that The second clarity evaluation function is: Where fv represents the image clarity, α represents the preset index and α>1, represents the ratio of the number of pixels in the light source area in the target area of ​​the first image to the number of all pixels in the target area of ​​the first image, It represents the ratio of the number of pixels in the light source area in the target area of ​​the current image to the number of all pixels in the target area of ​​the current image.

11. A device for calculating image clarity, characterized in that: The device comprises: an acquisition module, configured to acquire first brightness information and second brightness information of a first image, wherein the first brightness information represents overall brightness information of the first image, and the second brightness information represents brightness information of a non-light source area in the first image; A determination module is configured to determine a clarity evaluation function according to the first brightness information and the second brightness information, wherein the clarity evaluation function is used to evaluate the clarity of each frame of the continuously acquired image; The processing module is configured to determine the clarity of each image collected after the first image based on the clarity evaluation function.

12. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 10.

13. A non-transitory computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 10.