Focusing method, focusing device, electronic equipment and storage medium
By dividing the image area into multiple sub-regions in a flat area scene, the target area to be focused is determined, and the problem of low focus accuracy in a flat area scene is solved, and image clarity and user experience are improved.
Patent Information
- Application Number
- CN202311737225.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2025-06-17
AI Technical Summary
In flat area scenes, existing focusing methods are difficult to accurately focus, resulting in the image being out of focus and affecting the user's photography experience.
By determining the flat area in the current frame preview image and dividing the area except the flat area into a plurality of sub-regions, the target area to be focused is determined.
It improves the focus accuracy in flat area scenes, reduces the probability of focusing on the front and back scenes of the subject target, and improves the image imaging clarity and user photography experience.
Smart Images

Figure CN120166293A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of image capture, and particularly to a focusing method, a focusing device, an electronic device, and a storage medium. Background Art
[0002] In recent years, with the development of science and technology, digital cameras have become increasingly popular, and taking pictures with digital cameras has become more and more frequent. Users' requirements for the photo-taking effect of mobile terminals are also getting higher and higher. When using devices such as digital cameras and mobile phone cameras to capture an object, the focusing accuracy determines the quality of the image formation. The focusing area is the target area of interest in focusing. During the focusing process, if the focusing area contains too much background information, it will interfere with the system and prevent it from focusing on the main target, resulting in focusing failure. Therefore, the selection of the focusing area plays a crucial role in the focusing accuracy.
[0003] Currently, the focusing method is usually achieved by measuring the focusing values of some feature points in the image. However, in a flat area scene, there are no obvious edge details and textures and other features in the focusing area, resulting in the defocus of the image in this scene. Therefore, selecting a suitable focusing area is the key to improving the focusing accuracy in a flat area scene. Summary of the Invention
[0004] To overcome the problems existing in the related art, the present disclosure provides a focusing method, a focusing device, an electronic device, and a storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a focusing method, including:
[0006] Determining whether the current focusing area in the current frame preview image is a flat area;
[0007] When it is determined that the current focusing area is a flat area, determining whether there is a non-flat area among a plurality of first areas other than the current focusing area in the current frame preview image, and the current frame preview image is divided into the current focusing area and the plurality of first areas;
[0008] If there is the non-flat area, dividing the non-flat area to obtain a plurality of sub-areas;
[0009] Determining a target area to be focused according to the plurality of sub-areas.
[0010] According to a second aspect of an embodiment of the present disclosure, there is provided a focusing device, including:
[0011] A first determination module, configured to determine whether the current focusing area in the current frame preview image is a flat area;
[0012] A second determination module, configured to determine whether there is a non-flat area in a plurality of first areas other than the current focus area in the current frame preview image when it is determined that the current focus area is a flat area, where the current frame preview image is divided into the current focus area and the plurality of first areas;
[0013] A division module, configured to divide the non-flat area into a plurality of sub-areas if there is the non-flat area;
[0014] A third determination module, configured to determine a target area to be focused on according to the plurality of sub-areas.
[0015] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, including:
[0016] A processor;
[0017] A memory for storing instructions executable by the processor;
[0018] Wherein, when the processor is configured to execute the executable instructions, the steps of the focusing method provided in the first aspect of the present disclosure are implemented.
[0019] According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of the focusing method provided in the first aspect of the present disclosure are implemented.
[0020] By adopting the above technical solutions, when it is determined that there is a non-flat area, the non-flat area is further divided into a plurality of sub-areas, and then, a target area to be focused on is determined according to the plurality of sub-areas. That is, the fine granularity of the division of the current frame preview image is improved, the probability of focusing on the foreground and background of the main target can be reduced, the focusing accuracy in the scene of a flat area can be effectively improved, the image imaging clarity can be improved, and thus the user's photo-taking experience can be improved.
[0021] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0023] Figure 1 is a flowchart of a focusing method shown according to an exemplary embodiment.
[0024] Figure 2 is a schematic diagram of dividing a current frame preview image shown according to an exemplary embodiment.
[0025] Figure 3 It is a curve of the luminance weight information of a target area shown according to an exemplary embodiment.
[0026] Figure 4 It is a schematic diagram of dividing a non-flat area shown according to an exemplary embodiment.
[0027] Figure 5 It is a flowchart of another focusing method shown according to an exemplary embodiment.
[0028] Figure 6 It is a block diagram of a focusing device shown according to an exemplary embodiment.
[0029] Figure 7 It is a block diagram of an electronic device shown according to an exemplary embodiment. Detailed implementation manners
[0030] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0031] It should be noted that all actions of obtaining signals, information or data in the present disclosure are carried out on the premise of complying with the corresponding data protection regulations and policies of the country where it is located and obtaining the authorization given by the owner of the corresponding device.
[0032] Currently, the commonly used focusing window selection methods mainly include the central window selection method, the multi-region window selection method, the non-uniform sampling window selection method, the region contrast window selection method, the first-order moment window selection method, the visual attention mechanism window selection method, etc. Traditional methods such as the central window selection method, the multi-region window selection method, and the non-uniform sampling window selection method belong to the fixed window method. Once the scene within the focusing window belongs to a flat area scene, it is very easy to have a defocus situation. And methods such as the region contrast window selection method and the visual attention mechanism window selection method belong to the dynamic window selection method. Although they can dynamically select the focusing window, generally, such focusing window selection methods automatically select the area with the richest edge details for focusing. When the depth difference between the focusing subject and the background with the richest edge details is relatively large, using such focusing window selection methods is very easy to focus on the foreground and background of the main target, resulting in defocus. Therefore, the focusing accuracy in the scene of a flat area is relatively low, and a clear image cannot be obtained, affecting the user's photo-taking experience.
[0033] In view of this, the present disclosure provides a focusing method, a focusing device, an electronic device, and a storage medium, which reduce the probability of focusing on the foreground and background of the main target, effectively improve the focusing accuracy in a flat area scene, improve the clarity of the image, and thus enhance the user's photo-taking experience.
[0034] Figure 1 It is a flowchart of a focusing method shown according to an exemplary embodiment. As Figure 1 shown, the method may include the following steps.
[0035] In step S11, determine whether the current focusing area in the current frame preview image is a flat area.
[0036] In the present disclosure, the current focusing area may be a default focusing area. Exemplarily, the default focusing area may be the central focusing window area of the preview image. It should be noted that when the user turns on the camera configured in the terminal device, the camera will complete focusing based on the default focusing area, for example, the central focusing window area in the preview image. However, if the central focusing window area is a flat area, there may be a situation where focusing fails and cannot be focused.
[0037] Here, the preview image is the image content that changes in real time according to the change of the camera of the terminal device or the change of the focal length of the camera, etc.; when the user uses the terminal device to take a picture, the preview image will be displayed in real time in the display area of the terminal device.
[0038] When taking a picture, in order to ensure that the picture is taken clearly, it is usually necessary to focus the imaging device; the so-called "focusing" refers to the process of adjusting the distance between the camera of the imaging device and the image sensor so that the image sensor forms a clear image.
[0039] In step S12, when it is determined that the current focusing area is a flat area, determine whether there is a non-flat area among a plurality of first areas other than the current focusing area in the current frame preview image.
[0040] In the present disclosure, in order to achieve successful focusing to capture a clear image, if the current focusing area is a flat area, it is further determined whether there is a non-flat area among a plurality of first areas other than the current focusing area in the current frame preview image, so as to determine the target area to be focused from the first areas and focus on the target area. Among them, the current frame preview image is divided into the current focusing area and a plurality of first areas.
[0041] Figure 2 It is a schematic diagram of dividing the current frame preview image shown according to an exemplary embodiment. As Figure 2As shown, the maximum rectangle represents the current frame preview image. The central window area in the current frame preview image, i.e., the area filled with dashed lines in the figure, represents the current focus area, and each area adjacent to the current focus area is the first area. That is, in Figure 2 the previous frame preview image is divided into the current focus area and eight first areas.
[0042] It should be understood that in order to improve the accuracy of determining whether an area is a flat area, in the present disclosure, the current frame preview image can also be filtered first, and after removing image noise, then determine whether the current focus area is a flat area and whether there is a non-flat area in the multiple first areas. Exemplarily, first, obtain the current frame preview image, then, filter the current frame preview image using the Gaussian filtering algorithm, and finally, determine whether the current focus area in the filtered current frame preview image is a flat area, and, determine whether there is a non-flat area in the multiple first areas other than the current focus area in the current frame preview image.
[0043] In step S13, if there is a non-flat area, the non-flat area is divided into multiple sub-areas.
[0044] In step S14, the target area to be focused on is determined according to the multiple sub-areas.
[0045] Adopting the above technical solution, when it is determined that there is a non-flat area, the non-flat area is further divided into multiple sub-areas, and then, the target area to be focused on is determined according to the multiple sub-areas. That is, improving the fine-grainedness of the division of the current frame preview image can reduce the probability of focusing on the foreground and background of the main target, effectively improve the focusing accuracy in the flat area scene, improve the image imaging clarity, and thus improve the user's photo-taking experience.
[0046] To enable those skilled in the art to better understand the focusing method provided by the present disclosure, a complete embodiment is used to describe the focusing method below.
[0047] It should be noted that in the present disclosure, the specific implementation manner of step S11 for determining whether the current focus area in the current frame preview image is a flat area is similar to that of step S12 for determining whether there is a non-flat area in the multiple first areas other than the current focus area in the current frame preview image. Therefore, in the present disclosure, the following method can be used to determine whether the current focus area in the current frame preview image is a flat area, and / or, determine whether there is a non-flat area in the multiple first areas other than the current focus area in the current frame preview image.
[0048] In one embodiment, the target area is the current focus area and / or the first area, and the following method is used to determine whether the target area is a flat area:
[0049] First, according to each pixel point in the target area, determine the image parameters of the target area, where the image parameters include brightness weight information and / or gradient information;
[0050] Among them, the brightness information of the target area affects the judgment of whether a certain area is a flat area. Exemplarily, when the brightness is low, that is, when the current environment is dark, the contrast of the image is low, and the phase detection performance deteriorates, resulting in a lower accuracy in judging whether the target area is a flat area. The smaller the gradient represented by the gradient information of the target area, the flatter the image corresponding to the target area. Therefore, in the present disclosure, the flatness factor of the target area can be determined based on the brightness weight information and / or gradient information.
[0051] In one implementation, the image parameters include brightness weight information. Correspondingly, the specific implementation of determining the image parameters of the target area according to each pixel point in the target area can be: determine the average gray value of the target area according to each pixel point in the target area.
[0052] Exemplarily, the average gray value of the target area can be determined by the following formula (1):
[0053]
[0054] where I mean represents the average gray value of the target area, M and N respectively represent the number of pixel rows and the number of pixel columns of the target area, i represents the i-th row of the target area, j represents the j-th column of the target area, and I i,j represents the gray value of the pixel point in the i-th row and the j-th column.
[0055] After determining the average gray value of the target area, according to the average gray value of the target area, determine the brightness weight information of the target area through a preset correspondence between the average gray value and the brightness weight information.
[0056] Exemplarily, the preset correspondence between the average gray value and the brightness weight information is shown in the following formula (2). For example, determine the brightness weight information of the target area by the following formula (2):
[0057]
[0058] where S lum represents the brightness weight information of the target area, I mean represents the average gray value of the target area, and ε, δ1, and δ2 respectively represent preset coefficients.
[0059] Calculate the luminance weight information of the target area according to the average gray value of the determined target area. In the formula for determining the luminance weight information of the target area, the value range of ε is 0.35 to 0.7, the value range of δ1 is 20 to 35, and the value range of δ2 is 220 to 235. Preferably, in this embodiment, ε can be 0.4, δ1 can be 25, and δ2 can be 230.
[0060] Exemplarily, Figure 3 is a curve of the luminance weight information of a target area shown according to an exemplary embodiment. As Figure 3 shown, when the average gray value I mean is between 0 and δ1, the luminance weight value represented by the luminance weight information increases as the average gray value increases. When the average gray value is between δ1 and δ2, the luminance weight value represented by the luminance weight information is constantly 1. When the average gray value is between δ2 and 255, the luminance weight value represented by the luminance weight information decreases as the average gray value increases.
[0061] In another embodiment, the image parameter includes gradient information. The specific implementation for determining the image parameter of the target area according to each pixel point in the target area can be: calculate the gradient value of each pixel point according to each pixel point in the target area; determine the gradient information of the target area through the correspondence between the gradient value of the pixel value and the gradient information of the area according to the gradient value of each pixel point.
[0062] Among them, the gradient value of the pixel point can include the gradient value of the pixel point in the horizontal direction and the gradient value in the vertical direction. Exemplarily, the gradient value G i (i, j) of the pixel point I(i, j) in the horizontal direction and the gradient value G j (i, j) in the vertical direction can be determined respectively through the following formulas (3) and (4). Then, according to the gradient value of the pixel point in the horizontal direction and the gradient value in the vertical direction, determine the gradient information of the target area through formula (5):
[0063] G i (i, j) = I(i - 1, j + 1) + I(i, j + 1) + I(i + 1, j + 1) - I(i - 1, j - 1) - I(i, j - 1) - I(i + 1, j - 1) (3)
[0064] G j (i, j) = I(i - 1, j - 1) + I(i - 1, j) + I(i - 1, j + 1) - I(i + 1, j - 1) - I(i + 1, j) - I(i + 1, j + 1) (4)
[0065]
[0066] Among them, F(I) represents the gradient information of the target region, M and N respectively represent the number of pixel rows and pixel columns of the target region, I(x, y) represents the pixel at the x-th row and y-th column, the value range of x is [i - 1, i + 1], the value range of y is [j - 1, j + 1], i represents the i-th row of the target region, and j represents the j-th column of the target region.
[0067] It should be understood that in the present disclosure, the formula for the gradient information of the above target region is obtained by improving the formula of the Prewitt function. Among them, the corresponding expression of the Prewitt function is: P(i, j) represents the convolution of the pixel (i, j) in the target region with the Prewitt operator, and its expression is: Among them, Gi(i, j) and Gj(i, j) can be obtained through the above formulas (3) and (4) respectively. In order to limit the value range of the expression corresponding to the Prewitt function to the range of [0, 1], the expression corresponding to the Prewitt function is improved to obtain the above formula (5), and the gradient information of the target region is determined based on the above formula (5).
[0068] In another embodiment, the image parameters include brightness weight information and gradient information, where the brightness weight information and gradient information can be determined according to the above formulas, which will not be elaborated here.
[0069] Next, according to the image parameters of the target region, the flatness factor of the target region is determined.
[0070] Exemplarily, if the image parameters include brightness weight information and gradient information, according to the brightness weight information and gradient information of the target region, the flatness factor of the target region is determined through a preset fusion relationship.
[0071] Exemplarily, the flatness factor of the target region can be determined by the following formula (6):
[0072] S = 1 - S lum ·F(I) (6)
[0073] Among them, S represents the flatness factor of the target region, S lum represents the brightness weight information of the target region, and F(I) represents the gradient information of the target region.
[0074] In this way, according to the above method, the flatness factor of the target region of the current frame preview image can be determined.
[0075] Finally, according to the flatness factor of the target region of the current frame preview image, it is determined whether the target region is a flat region.
[0076] In one embodiment, it is possible to determine whether the target region is a flat region only based on the flatness factor of the target region of the current frame preview image. Exemplarily, if the flatness factor of the target region of the current frame preview image is greater than or equal to a first preset value, it is determined that the target region is a flat region; otherwise, it is determined that the target region is a non-flat region.
[0077] In another embodiment, the method may further include: obtaining preset frame preview images before the current frame preview image; respectively determining the flatness factors of the target regions of the preset frame preview images; correspondingly, a specific implementation manner of determining whether the target region is a flat region according to the flatness factor of the target region of the current frame preview image may be: determining the average flatness factor of the target region according to the flatness factors of the target regions of the preset number of frame preview images and the flatness factor of the target region of the current frame preview image; if the average flatness factor is greater than or equal to the first preset value, it is determined that the target region is a flat region, and if the average flatness factor is less than the first preset value, it is determined that the target region is a non-flat region.
[0078] In this embodiment, the flatness factors of the target regions of the preset number of frame preview images can be determined by referring to the manner of determining the flatness factor of the target region of the current frame preview image described above. Exemplarily, the preset number of frame preview images may be two frame preview images before the current frame preview image. Exemplarily, the current frame preview image is the z-th frame preview image, the preset number of frame preview images are the (z - 1)-th frame preview image and the (z - 2)-th frame preview image, the flatness factor of the z-th frame preview image is S z , the flatness factor of the (z - 1)-th frame preview image is S z-1 , the flatness factor of the (z - 2)-th frame preview image is S z-2 . And the average flatness factor S of the target region is determined according to the following formula (7) mean :
[0079]
[0080] In the present disclosure, the flatness factor is used to characterize the probability that the region is a flat region. Therefore, the larger the average flatness factor S mean , the flatter the region is characterized. If S mean is less than the first preset value T, it is considered that the target region is a non-flat region. If S mean is greater than the first preset value T, it is considered that the target region is a flat region. Among them, the value range of the first preset value T is 0.45 to 0.75. For example, the first preset value T may be 0.6.
[0081] It should be understood that in the above step S11, it is possible to determine whether the current focus area is a flat area in the above manner. If it is determined that the current focus area is a flat area, then it is further determined whether each first area is a flat area in the above manner, and then it is determined whether there is a non-flat area among the multiple first areas.
[0082] Exemplarily, with reference to Figure 2 , when it is determined that the current focus area is a flat area, the average flatness factor of the 8 first areas of the current focus area is respectively determined to determine whether there is a non-flat area. If it is determined that there is a non-flat area among the 8 first areas, the non-flat area is divided to obtain multiple sub-areas.
[0083] In one embodiment, if there is a non-flat area, dividing the non-flat area to obtain multiple sub-areas may include: if there is a non-flat area, each non-flat area is divided into multiple sub-areas. In this embodiment, the non-flat area is divided without distinction to obtain multiple sub-areas.
[0084] In another embodiment, if there is a non-flat area, dividing the non-flat area to obtain multiple sub-areas may include: if there is a non-flat area, for each non-flat area, the non-flat area is divided according to the flatness factor of the non-flat area to obtain multiple sub-areas. In this embodiment, the non-flat area can be divided differentially according to the flatness factor of the flat area.
[0085] Exemplarily, non-flat areas with different flatness factors can be divided into different numbers of sub-areas. For example, the smaller the flatness factor of the non-flat area, the more sub-areas it is divided into. In this way, the accuracy of the target area to be focused can be further improved.
[0086] Another example is that in order to simplify the division workload, the non-flat area with the smallest flatness factor can be divided into a first preset number of sub-areas, and the other non-flat areas are respectively divided into a second preset number of sub-areas, where the first preset number is greater than the second preset number. For example, the non-flat area with the smallest flatness factor can be divided into 9 sub-areas, and the other non-flat areas are respectively divided into 4 sub-areas. Of course, the first preset number and the second preset number can also be other values, and the present disclosure does not make specific limitations on this.
[0087] Figure 4 is a schematic diagram showing the division of a non-flat area according to an exemplary embodiment. As Figure 4As shown in the figure, assume that the first area on the right side, the first area above, and the first area in the lower left of the current focus area are non-flat areas, and the flatness factor of the first area on the right side is the smallest. Then, the first area on the right side is divided into 9 sub-areas, which are respectively denoted as sub-area 1 to sub-area 9, and the first area above and the first area in the lower left are respectively divided into 4 sub-areas, which are respectively denoted as sub-area 10 to sub-area 17.
[0088] It should be noted that if the number of non-flat areas is one, the non-flat area can also be directly determined as the target area to be focused. However, considering that the non-flat area is relatively large, when the main target is a small object, if the non-flat area is directly determined as the target area to be focused, the determined target area will include not only the main target but also the foreground and background of the main target, that is, the target area to be focused cannot be accurately determined. Therefore, in the present disclosure, if the number of non-flat areas is one, the non-flat area can be divided into a first preset number of sub-areas, and then, based on the first preset number of sub-areas, the target area to be focused is determined, which improves the accuracy of the determined target area to be focused.
[0089] In this way, by adopting the above division method, the non-flat area with the smallest flatness factor is divided into the most sub-areas, that is, the non-flat area with the smallest flatness factor is divided by a finer-grained division method, which improves the accuracy of the determined target area to be focused.
[0090] Next, the specific implementation manner of determining the target area to be focused according to multiple sub-areas will be described.
[0091] In the present disclosure, determining the target area to be focused according to multiple sub-areas may include:
[0092] First, determine the flatness factor of each sub-area, and determine the sub-areas with a flatness factor less than the first preset value as candidate sub-areas, where the flatness factor is used to characterize the probability that the area is a flat area;
[0093] Among them, the flatness factor of each sub-area can be determined by referring to the method of determining the flatness factor of the target area in the above embodiment of determining whether the target area is a flat area, and the present disclosure will not elaborate on this. It should be understood that the flatness factor of each sub-area here can also be the average flatness factor, and the present disclosure does not limit this.
[0094] After that, determine the target area to be focused according to the number and candidate sub-areas of the candidate sub-areas.
[0095] As described above, the region where the flatness factor is less than the first preset value can be considered as a non-flat region. Therefore, in the present disclosure, a sub-region with a flatness factor less than the first preset value is determined as a candidate sub-region, and then a target region to be focused is determined in the candidate sub-region. Among them, the number of candidate sub-regions can be denoted as Num fine 。
[0096] In one embodiment, if the number of candidate sub-regions is one, that is, Num fine = 1, the candidate sub-region is directly determined as the target region to be focused.
[0097] In another embodiment, if the number of candidate sub-regions is multiple, that is, Num fine > 1, the extreme difference value of the flatness factor is determined in the candidate sub-regions, and the target region to be focused is determined according to the extreme difference value. Among them, the extreme difference value of the flatness factor refers to the difference between the maximum flatness factor and the minimum flatness factor in the candidate sub-regions. In this embodiment, when there are multiple candidate sub-regions, in order to further improve the accuracy of the determined target region to be focused, the target region to be focused can be determined according to the extreme difference value of the flatness factor.
[0098] In the first implementation manner of this embodiment, determining the target region to be focused according to the extreme difference value can be: obtaining a range factor, where the range factor is determined by the extreme difference value and the maximum flatness factor in the candidate sub-regions; if the range factor is less than the second preset value, the candidate sub-regions with a range factor less than the second preset value are determined as the target regions to be focused.
[0099] Exemplarily, after determining the extreme difference value, the extreme difference value is normalized to obtain the normalized range factor, that is, the ratio of the extreme difference value to the maximum flatness factor in the candidate sub-regions is determined as the range factor S fine-ratio 。After that, according to the range factor S fine-ratio and the second preset value T ratio to determine the target region to be focused. If S fine-ratio < T ratio , the candidate sub-regions with a range factor less than the second preset value are determined as the target regions to be focused. Among them, the second preset value T ratio The value range of can be 0 to 0.25. Preferably, the second preset value T ratio can be 0.15.
[0100] Exemplarily, in Figure 4Among them, it is assumed that the candidate sub-regions are sub-region 1, sub-region 2, sub-region 8, sub-region 12, and sub-region 15 respectively. If the flatness factor of sub-region 1 is the smallest and the flatness factor of sub-region 15 is the largest, then the ratio of the difference between the flatness factors of sub-region 15 and sub-region 1 to the flatness factor of sub-region 15 is determined as the range factor. If this range factor is less than the second preset value, then sub-region 1 and sub-region 15 are determined as the target regions to be focused on.
[0101] In the second implementation manner of this embodiment, determining the target region to be focused on according to the range value can also be: if the range factor is greater than or equal to the second preset value, then the candidate sub-region with the smallest flatness factor is determined as the target region to be focused on. However, considering that if the flatness factors of multiple candidate sub-regions are relatively close, if only the candidate sub-region with the smallest flatness factor is determined as the target region to be focused on, the determined target region to be focused on is not necessarily the most suitable, resulting in a lower accuracy of the determined target region to be focused on.
[0102] Therefore, in the third implementation manner of this embodiment, determining the target region to be focused on according to the range value can also be: if the range factor is greater than or equal to the second preset value and the number of candidate sub-regions is less than the first preset number, then the candidate sub-region with the smallest flatness factor is determined as the target region to be focused on, where the first preset number is an integer greater than or equal to 3.
[0103] If the range factor is greater than or equal to the second preset value and the number of candidate sub-regions is greater than or equal to the first preset number, then according to the flatness factor of each candidate sub-region, the distance between each candidate sub-region and the current focus region, and a preset clustering algorithm, the candidate sub-regions are clustered to obtain K clustering centers, and the candidate sub-region belonging to the smallest clustering center is determined as the target region to be focused on, where K is an integer less than or equal to the first preset number.
[0104] Exemplarily, the range factor is greater than or equal to the second preset value and the number of candidate sub-regions is multiple and less than the first preset number. Assume that the first preset number is 3, then the number Num of candidate sub-regions fine = 2. That is, in this implementation manner, Num fine = 2 and S fine-ratio ≥ T ratio , then the candidate sub-region with the smallest flatness factor is determined as the target region to be focused on.
[0105] Also exemplarily, the range factor is greater than or equal to the second preset value and the number of candidate sub-regions is multiple and greater than or equal to the first preset number. Assume that the first preset number is 3, then the number Num of candidate sub-regions fine ≥ 3. That is, in this implementation manner, Num fine ≥ 3 and Sfine-ratio ≥T ratio , for each candidate sub-region, the flatness factor of the candidate sub-region and the distance between the candidate region and the current focus region are fused to obtain a distance measure. For example, the distance measure of the candidate sub-region can be obtained through the formula to obtain the distance measure of the candidate sub-region. Wherein, LS k represents the distance measure of the k-th candidate sub-region, represents the flatness factor or average flatness factor of the k-th candidate sub-region, and L k represents the distance between the k-th candidate sub-region and the current focus region. Wherein, the distance between the candidate sub-region and the current focus region can be the distance between the center point of the candidate sub-region and the center point of the current focus region. After obtaining the distance measure of each candidate sub-region, the candidate sub-regions are clustered through a preset clustering algorithm to obtain K clustering centers. For example, the preset clustering algorithm can be the FCM clustering algorithm, set the number of clustering categories to K, the maximum number of iterations to 10, the fuzzy index to 2, the convergence threshold to 0.01, randomly initialize the membership degree and the sum of the membership degrees of all classes of each sample is 1, use the distance measure of the candidate sub-region as the sample data, and cluster it using the FCM clustering algorithm to obtain the clustering centers and the candidate sub-regions belonging to each clustering center. Finally, the candidate sub-region belonging to the smallest clustering center is determined as the target region to be focused.
[0106] In the present disclosure, determining the target region to be focused according to multiple sub-regions may further include:
[0107] If the flatness factor of each of the sub-regions is greater than or equal to a first preset value, then determine the number of non-flat regions in the multiple first regions;
[0108] If the number of the non-flat regions is multiple, then determine the first region to which the candidate sub-region with the smallest flatness factor belongs as the target region to be focused;
[0109] If the number of the non-flat regions is one, then determine the non-flat region as the target region to be focused.
[0110] In the present disclosure, if the flatness factor of each sub-region is greater than or equal to a first preset value, that is, the number of candidate sub-regions Num fine =0, then determine the number of non-flat regions in the multiple first regions. Among them, the average flatness factor of each first region can be determined in the above manner, and the first region with an average flatness factor less than the first preset value is determined as the non-flat region, and then the number of non-flat regions Num coarse can be counted. Exemplarily, if the number of non-flat regions Num coarse =1, then determine the non-flat region as the target region to be focused. That is, if Numcoarse = 1 and Num fine = 0, then determine the non - flat area as the target area to be focused. Also, for example, if the number Num of non - flat areas coarse > 1, then determine the first area to which the candidate sub - area with the smallest flatness factor belongs as the target area to be focused. That is, if Num coarse > 1 and Num fine = 0, then determine the first area to which the candidate sub - area with the smallest flatness factor belongs as the target area to be focused.
[0111] In addition, the method may further include:
[0112] If there is no non - flat area among multiple first areas, then determine the area of the current frame preview image as the target area to be focused. That is to say, if the average flatness factor or the flatness factor of each first area is greater than or equal to the first preset value, then it is determined that there is no non - flat area among the multiple first areas. At this time, determine the entire area of the current frame preview image as the target area to be focused.
[0113] Next, a complete example is used to describe the focusing method provided by the present disclosure.
[0114] Figure 5 is a flowchart of another focusing method shown according to an exemplary embodiment. As Figure 5 shown, the focusing method may include the following steps.
[0115] In step S51, obtain the current frame preview image and filter it using the Gaussian filtering algorithm.
[0116] In step S52, determine the average flatness factor of the current focusing area.
[0117] In step S53, determine whether the average flatness factor of the current focusing area is greater than or equal to the first preset value. If the average flatness factor of the current focusing area is less than the first preset value, then execute step S54; otherwise, execute step S55.
[0118] In step S54, determine the current focusing area as the target area to be focused.
[0119] In step S55, determine the respective average flatness factors of multiple first areas in the current frame preview image except the current focusing area, and determine the first areas with an average flatness factor less than the first preset value as non - flat areas.
[0120] In step S56, count the number of non - flat areas.
[0121] In step S57, it is determined whether the number of non-flat regions is greater than or equal to 1. If it is less than 1, step S58 is executed; otherwise, step S59 is executed.
[0122] In step S58, the region of the current frame preview image is determined as the target region to be focused.
[0123] In step S59, the non-flat regions are divided into multiple sub-regions with different density sizes.
[0124] In step S510, the average flatness factor of each sub-region is determined, the sub-regions with a flatness factor less than the first preset value are determined as candidate sub-regions, and the number of candidate sub-regions is counted.
[0125] In step S511, it is determined whether the number of candidate sub-regions is greater than or equal to 2. If it is less than 2, step S512 is executed.
[0126] In step S512, it is determined whether the number of candidate sub-regions is 1. If it is 1, step S513 is executed; if the number of candidate sub-regions is not 1, that is, 0, step S514 is executed.
[0127] In step S513, the candidate sub-region is determined as the target region to be focused.
[0128] In step S514, it is determined whether the number of non-flat regions is greater than 1. If it is greater than 1, step S515 is executed; if it is not greater than 1, that is, the number of non-flat regions is 1, step S516 is executed.
[0129] In step S515, the first region to which the candidate sub-region with the smallest flatness factor belongs is determined as the target region to be focused.
[0130] In step S516, the non-flat region is determined as the target region to be focused.
[0131] In addition, in step S511, if the number of candidate sub-regions is greater than or equal to 2, step S517 is executed.
[0132] In step S517, the ratio of the extreme difference value of the determined average flatness factor to the maximum average flatness factor among the candidate sub-regions is determined as the extreme difference factor.
[0133] In step S518, it is determined whether the extreme difference factor is greater than or equal to the second preset value. If it is less than the second preset value, step S519 is executed; if it is greater than or equal to the second preset value, step S520 is executed.
[0134] In step S519, the candidate sub-regions with an extreme difference factor less than the second preset value are determined as the target regions to be focused.
[0135] In step S520, it is determined whether the number of candidate sub-regions is greater than or equal to 3. If it is less than 3, step S521 is executed; if it is greater than or equal to 3, step S522 is executed.
[0136] In step S521, the candidate sub-region with the smallest flatness factor is determined as the target region to be focused.
[0137] In step S522, distances are calculated for the candidate sub-regions according to the FCM algorithm to obtain K clustering centers.
[0138] In step S523, the candidate sub-regions belonging to the smallest clustering center are determined as the target regions to be focused.
[0139] Thus, by adopting the above technical solution, the target region to be focused can be determined for different situations, which can reduce the probability of focusing on the foreground and background outside the main target, and thus effectively improve the focusing accuracy in the flat region scene and enhance the user's photo-taking experience.
[0140] Based on the same inventive concept, the present disclosure also provides a focusing device. Figure 6 It is a block diagram of a focusing device shown according to an exemplary embodiment. As Figure 6 shown, the focusing device 600 may include:
[0141] A first determination module 601, configured to determine whether the current focusing region in the current frame preview image is a flat region;
[0142] A second determination module 602, configured to determine whether there is a non-flat region among a plurality of first regions other than the current focusing region in the current frame preview image when it is determined that the current focusing region is a flat region, and the current frame preview image is divided into the current focusing region and the plurality of first regions;
[0143] A division module 603, configured to divide the non-flat region into a plurality of sub-regions if there is the non-flat region;
[0144] A third determination module 604, configured to determine the target region to be focused according to the plurality of sub-regions.
[0145] Optionally, the third determination module 604 may include:
[0146] A first determination sub-module, configured to determine the flatness factor of each of the sub-regions, and determine the sub-regions with the flatness factor less than a first preset value as candidate sub-regions, where the flatness factor is used to characterize the probability that the region is a flat region;
[0147] The second determination sub-module is configured to determine a target area to be focused on according to the number of the candidate sub-areas and the candidate sub-areas.
[0148] Optionally, the second determination sub-module is configured to:
[0149] If the number of the candidate sub-areas is one, determine the candidate sub-area as the target area to be focused on;
[0150] If the number of the candidate sub-areas is multiple, determine the extreme difference value of the flatness factors in the candidate sub-areas, and determine the target area to be focused on according to the extreme difference value.
[0151] Optionally, the second determination sub-module is configured to: obtain an extreme difference factor, where the extreme difference factor is determined by the extreme difference value and the maximum flatness factor in the candidate sub-areas;
[0152] If the extreme difference factor is less than a second preset value, determine the candidate sub-areas with the extreme difference factor less than the second preset value as the target areas to be focused on.
[0153] Optionally, the second determination sub-module is configured to: if the extreme difference factor is greater than or equal to the second preset value, and the number of the candidate sub-areas is less than a first preset number, determine the candidate sub-area with the minimum flatness factor as the target area to be focused on, where the first preset number is an integer greater than or equal to 3; or
[0154] If the extreme difference factor is greater than or equal to the second preset value, and the number of the candidate sub-areas is greater than or equal to the first preset number, perform clustering on the candidate sub-areas according to the flatness factor of each candidate sub-area, the distance between each candidate sub-area and the current focused area, and a preset clustering algorithm to obtain K clustering centers, and determine the candidate sub-area belonging to the minimum clustering center as the target area to be focused on, where K is an integer less than or equal to the first preset number.
[0155] Optionally, the second determination sub-module is configured to: if the extreme difference factor is greater than the second preset value, determine the candidate sub-area with the minimum flatness factor as the target area to be focused on.
[0156] Optionally, the third determination module 604 may further include:
[0157] The third determination sub-module is configured to determine the number of non-flat areas in the multiple first areas if the flatness factor of each sub-area is greater than or equal to the first preset value;
[0158] The fourth determination sub-module is configured to, if the number of the non-flat regions is multiple, determine the first region to which the candidate sub-region with the smallest flatness factor belongs as the target region to be focused on;
[0159] The fifth determination sub-module is configured to, if the number of the non-flat regions is one, determine the non-flat region as the target region to be focused on.
[0160] Optionally, the focusing device 600 may further include:
[0161] The fourth determination module is configured to, if there is no non-flat region among the multiple first regions, determine the region of the current frame preview image as the target region to be focused on.
[0162] Optionally, the target region is the current focusing region and / or the first region, and the focusing device 600 may further include:
[0163] The fifth determination module is configured to determine the image parameters of the target region according to each pixel point in the target region, where the image parameters include brightness weight information and / or gradient information;
[0164] The sixth determination module is configured to determine the flatness factor of the target region according to the image parameters of the target region;
[0165] The seventh determination module is configured to determine whether the target region is a flat region according to the flatness factor of the target region of the current frame preview image.
[0166] Optionally, the focusing device 600 may further include:
[0167] The acquisition module is configured to acquire a preset number of frame preview images before the current frame preview image;
[0168] The eighth determination module is configured to respectively determine the flatness factors of the target regions of the preset number of frame preview images;
[0169] The seventh determination module is configured to: if the average flatness factor is greater than or equal to a first preset value, determine that the target region is a flat region, and if the average flatness factor is less than the first preset value, determine that the target region is a non-flat region.
[0170] Optionally, the image parameters include brightness weight information, and the fifth determination module is configured to: determine the average gray value of the target region according to each pixel point in the target region;
[0171] Determine the brightness weight information of the target area according to the corresponding relationship between the preset average gray value and the brightness weight information based on the average gray value of the target area.
[0172] Optionally, the image parameter includes gradient information, and the fifth determination module is configured to:
[0173] Calculate the gradient value of each pixel point in the target area respectively according to each pixel point in the target area;
[0174] Determine the gradient information of the target area according to the gradient value of each pixel point based on the corresponding relationship between the gradient value of the pixel value and the gradient information of the area.
[0175] Optionally, the image parameter includes brightness weight information and gradient information; the sixth determination module is configured to: determine the flatness factor of the target area according to the brightness weight information and the gradient information of the target area based on a preset fusion relationship.
[0176] Optionally, the partitioning module 603 is configured to: if there is such a non-flat area, for each non-flat area, partition the non-flat area according to the flatness factor of the non-flat area to obtain a plurality of sub-areas.
[0177] Optionally, the partitioning module 603 is configured to: partition the non-flat area with the smallest flatness factor into a first preset number of sub-areas, and partition the other non-flat areas into a second preset number of sub-areas respectively, where the first preset number is greater than the second preset number.
[0178] Regarding the device in the above embodiments, the specific manners in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated herein.
[0179] The present disclosure also provides a computer-readable storage medium, on which computer program instructions are stored, and when the program instructions are executed by a processor, the steps of the focusing method provided by the present disclosure are implemented.
[0180] Figure 7 It is a block diagram of an electronic device shown according to an exemplary embodiment. For example, the electronic device 800 may be a digital camera or a device equipped with a camera. Among them, the device equipped with a camera may include, but is not limited to, a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0181] Refer to Figure 7, the electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output interface 812, a sensor component 814, and a communication component 816.
[0182] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-described methods. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0183] The memory 804 is configured to store various types of data to support the operation of the electronic device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, and the like. The memory 804 may 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, a magnetic disk, or an optical disk.
[0184] The power component 806 provides power to the various components of the electronic device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.
[0185] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 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 can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the electronic device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0186] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker for outputting audio signals.
[0187] The input / output interface 812 provides an interface between the processing component 802 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a power button, and a lock button.
[0188] The sensor component 814 includes one or more sensors for providing an assessment of the status of various aspects of the electronic device 800. For example, the sensor component 814 can detect the on / off state of the electronic device 800, the relative positioning of components, such as the display and keypad of the electronic device 800. The sensor component 814 can also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor component 814 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 814 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 814 can further include an acceleration sensor, a gyro sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0189] The communication component 816 is configured to facilitate communication between the electronic device 800 and other devices in a wired or wireless manner. The electronic device 800 can access a communication standard-based wireless network, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 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 816 further 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.
[0190] In an exemplary embodiment, the electronic device 800 can 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 for performing the above method.
[0191] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the above instructions can be executed by a processor 820 of the electronic device 800 to complete the above focusing method. For example, the non-transitory computer-readable storage medium can be a ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0192] In another exemplary embodiment, a computer program product is also provided, and the computer program product includes a computer program capable of being executed by a programmable device, and the computer program has a code portion for performing the above focusing method when executed by the programmable device.
[0193] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the present disclosure. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and embodiments are only considered exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
[0194] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.
Claims
1. A focusing method, characterized in that, Including: Determine whether the current focus area in the current frame preview image is a flat area; When it is determined that the current focus area is a flat area, determine whether there is a non-flat area in a plurality of first areas other than the current focus area in the current frame preview image, and the current frame preview image is divided into the current focus area and the plurality of first areas; If there is the non-flat area, divide the non-flat area to obtain a plurality of sub-areas; Determine the target area to be focused according to the plurality of sub-areas.
2. The method according to claim 1, characterized in that, The determining the target area to be focused according to the plurality of sub-areas includes: Determine the flatness factor of each sub-area, and determine the sub-areas with the flatness factor less than a first preset value as candidate sub-areas, where the flatness factor is used to characterize the probability that the area is a flat area; Determine the target area to be focused according to the number of the candidate sub-areas and the candidate sub-areas.
3. The method according to claim 2, characterized in that, The determining the target area to be focused according to the number of the candidate sub-areas and the candidate sub-areas includes: If the number of the candidate sub-areas is one, determine the candidate sub-area as the target area to be focused; If the number of the candidate sub-areas is multiple, determine the extreme difference value of the flatness factor among the candidate sub-areas, and determine the target area to be focused according to the extreme difference value.
4. The method according to claim 3, characterized in that, The determining the target area to be focused according to the extreme difference value includes: Obtain an extreme difference factor, where the extreme difference factor is determined by the extreme difference value and the maximum flatness factor in the candidate sub-areas; If the extreme difference factor is less than a second preset value, determine the candidate sub-areas with the extreme difference factor less than the second preset value as the target area to be focused.
5. The method according to claim 4, characterized in that, The determining the target area to be focused according to the extreme difference value further includes: If the extreme difference factor is greater than or equal to the second preset value, and the number of the candidate sub-areas is less than a first preset number, determine the candidate sub-area with the smallest flatness factor as the target area to be focused, where the first preset number is an integer greater than or equal to 3; or If the extreme difference factor is greater than or equal to the second preset value, and the number of the candidate sub-areas is greater than or equal to the first preset number, cluster the candidate sub-areas according to the flatness factor of each candidate sub-area, the distance between each candidate sub-area and the current focus area, and a preset clustering algorithm to obtain K clustering centers, and determine the candidate sub-area belonging to the smallest clustering center as the target area to be focused, where K is an integer less than or equal to the first preset number.
6. The method according to claim 4, characterized in that, The determining the target area to be focused according to the extreme difference value further includes: If the extreme difference factor is greater than the second preset value, determine the candidate sub-area with the smallest flatness factor as the target area to be focused.
7. The method according to claim 2, characterized in that, The determining the target area to be focused according to the plurality of sub-areas further includes: If the flatness factor of each sub-area is greater than or equal to the first preset value, determine the number of non-flat areas in the plurality of first areas; If the number of the non-flat regions is multiple, determine the first region to which the candidate sub-region with the smallest flatness factor belongs as the target region to be focused; If the number of the non-flat regions is one, determine the non-flat region as the target region to be focused.
8. The method according to claim 1, characterized in that, The method further includes: If there is no non-flat region among the multiple first regions, determine the region of the current frame preview image as the target region to be focused.
9. The method according to any one of claims 1-8, characterized in that, The target region is the current focusing region and / or the first region. The method for determining whether the target region is a flat region is as follows: According to each pixel point in the target region, determine the image parameters of the target region, where the image parameters include brightness weight information and / or gradient information; According to the image parameters of the target region, determine the flatness factor of the target region; Determine whether the target region is a flat region according to the flatness factor of the target region in the current frame preview image.
10. The method according to claim 9, characterized in that, The method further includes: Obtain a preset number of preview images before the current frame preview image; Respectively determine the flatness factors of the target regions of the preset number of preview images; The step of determining whether the target region is a flat region according to the flatness factor of the target region in the current frame preview image includes: According to the flatness factors of the target regions of the preset number of preview images and the flatness factor of the target region in the current frame preview image, determine the average flatness factor of the target region; If the average flatness factor is greater than or equal to a first preset value, determine that the target region is a flat region; and if the average flatness factor is less than the first preset value, determine that the target region is a non-flat region.
11. The method according to claim 9, wherein, The image parameters include brightness weight information. The step of determining the image parameters of the target region according to each pixel point in the target region includes: According to each pixel point in the target region, determine the average gray value of the target region; According to the average gray value of the target region, determine the brightness weight information of the target region through a preset correspondence between the average gray value and the brightness weight information.
12. The method according to claim 9, wherein, The image parameters include gradient information. The step of determining the image parameters of the target region according to each pixel point in the target region includes: According to each pixel point in the target region, calculate the gradient value of each pixel point; According to the gradient values of each pixel point, determine the gradient information of the target region through a correspondence between the gradient value of the pixel value and the gradient information of the region.
13. The method according to claim 9, wherein, The image parameters include brightness weight information and gradient information. The step of determining the flatness factor of the target region according to the image parameters of the target region includes: According to the brightness weight information and gradient information of the target region, determine the flatness factor of the target region through a preset fusion relationship.
14. The method according to any one of claims 1-8, wherein, The step of, if there is the non-flat region, dividing the non-flat region into multiple sub-regions includes: If there is the non-flat region, for each non-flat region, divide the non-flat region according to the flatness factor of the non-flat region to obtain multiple sub-regions.
15. The method according to claim 14, wherein, Dividing the non-flat area according to the flatness factor of the non-flat area includes: Dividing the non-flat area with the smallest flatness factor into a first preset number of sub-areas, and dividing each of the other non-flat areas into a second preset number of sub-areas, where the first preset number is greater than the second preset number.
16. A focusing device, wherein, Including: A first determination module configured to determine whether the current focus area in the current frame preview image is a flat area; A second determination module configured to, when it is determined that the current focus area is a flat area, determine whether there is a non-flat area among a plurality of first areas other than the current focus area in the current frame preview image, where the current frame preview image is divided into the current focus area and the plurality of first areas; A division module configured to, if there is the non-flat area, divide the non-flat area to obtain a plurality of sub-areas; A third determination module configured to determine a target area to be focused according to the plurality of sub-areas.
17. An electronic device, wherein, Including: A processor; A memory for storing processor-executable instructions; Wherein, the processor is configured to implement the steps of the focusing method according to any one of claims 1-15 when executing the executable instructions.
18. A computer-readable storage medium having computer program instructions stored thereon, wherein, When the program instructions are executed by the processor, the steps of the focusing method according to any one of claims 1-15 are implemented.