An image defocus detection method, device, electronic device and storage medium

By comparing the sharpness values ​​of the same area in the field of view of the telephoto image and the short-focus image collected at the same time, the problem that image out-of-focus detection in the prior art is affected by the scene complexity, and more accurate image out-of-focus detection is achieved.

CN114913171BActive Publication Date: 2025-07-01HANGZHOU EZVIZ SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210712219.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-22
Publication Date
2025-07-01
Estimated Expiration
2042-06-22

AI Technical Summary

Technical Problem

The prior art has a great influence on the scene complexity in image out-of-focus detection, resulting in inaccurate evaluation of image clarity and misjudgment of image blur or out-of-focus.

Method used

By acquiring the telephoto images and short-focus images collected at the same time, the areas with the same field of view are grid-divided, the sharpness values ​​of each sub-block are calculated, the sharpness difference between the telephoto image sub-block and the short-focus image sub-block are compared, and whether it is a target telephoto image sub-block is determined, so as to determine whether the image is out of focus.

Benefits of technology

It effectively avoids the influence of scene complexity factors in image out-of-focus detection, improves the accuracy of telephoto image out-of-focus detection, and reduces the misjudgment rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114913171B_ABST
    Figure CN114913171B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides an image defocus detection method, apparatus, electronic device, and storage medium. Among them, the method includes: obtaining a first long-focus image and a first short-focus image collected at the same time, performing grid division on regions with the same field of view range in the first long-focus image and the first short-focus image to obtain each long-focus image sub-block of the first long-focus image and each short-focus image sub-block of the first short-focus image; respectively calculating the clarity values of each long-focus image sub-block; selecting the long-focus image sub-blocks with clarity values greater than a first preset threshold to obtain preliminarily screened long-focus image sub-blocks; for each preliminarily screened long-focus image sub-block, calculating the difference between the clarity value of the preliminarily screened long-focus image sub-block and the clarity value of the corresponding short-focus image sub-block to obtain a target difference; determining whether the first long-focus image is defocused according to the ratio of the number of preliminarily screened long-focus image sub-blocks with the target difference greater than a second preset threshold to the total number of each long-focus image sub-block, which improves the accuracy of image defocus detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image defocus detection method, device, electronic device and storage medium. Background Art

[0002] Image clarity refers to the clarity of the details and their boundaries on the image. Image clarity is an important indicator for measuring image quality. For cameras, they usually work in a mode without a reference image. When taking pictures, they need to control the focus. If the focus is not accurate, the image will become blurry and unclear.

[0003] In the related art, in order to realize the evaluation of image clarity, the method adopted is: for the grayscale image matrix of the image to be evaluated for clarity, the vector gradient matrix of the grayscale image matrix is ​​calculated, the vector gradient of each pixel in the grayscale image matrix is ​​calculated, and the average value of the vector gradient of the grayscale image matrix is ​​calculated based on the vector gradient of each pixel, and the clarity of the image is determined by using the average value.

[0004] In the above-mentioned method for evaluating image clarity, the clarity of the image is evaluated by the vector gradient of the image pixels. When the gradient function is used to calculate the vector gradient, it is usually greatly affected by the complexity of the scene. When the size is fixed, the edge texture is rich and the score obtained by the gradient calculation is high. However, the clarity value of the image is affected by the complex scene. When the scene is single, the sharp contour edge may not have a high clarity value. When the scene is complex, the image may be blurred or out of focus. This is because the gradient changes dramatically but the clarity value is very high, causing the image to be misjudged as out of focus. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide an image defocus detection method, device, electronic device and storage medium to improve the accuracy of image defocus detection. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present application provides an image defocus detection method, the method comprising:

[0007] Acquire a first telephoto image and a first short-focus image captured at the same time, wherein the field of view of the first short-focus image includes the field of view of the first telephoto image;

[0008] Performing grid division on regions with the same field of view in the first telephoto image and the first short-focus image to obtain telephoto image sub-blocks of the first telephoto image and short-focus image sub-blocks of the first short-focus image;

[0009] Calculating the clarity value of each of the telephoto image sub-blocks respectively;

[0010] Select image sub - blocks with sharpness values greater than the first preset threshold from each of the long - focal - length image sub - blocks to obtain the initially screened long - focal - length image sub - blocks;

[0011] For each initially screened long - focal - length image sub - block, calculate the difference between the sharpness value of the initially screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block to obtain the target difference of the initially screened long - focal - length image sub - block;

[0012] Determine the initially screened long - focal - length image sub - blocks with the target difference greater than the second preset threshold as the target long - focal - length image sub - blocks;

[0013] Determine whether the first long - focal - length image is out of focus according to the ratio of the number of the target long - focal - length image sub - blocks to the total number of all the long - focal - length image sub - blocks.

[0014] Optionally, the step of performing grid division on the regions with the same field - of - view range in the first long - focal - length image and the first short - focal - length image to obtain each long - focal - length image sub - block of the first long - focal - length image and each short - focal - length image sub - block of the first short - focal - length image includes:

[0015] Scale the first long - focal - length image and crop the first short - focal - length image to obtain a second long - focal - length image and a second short - focal - length image with the same field - of - view range and the same size;

[0016] Perform grayscale processing on the second long - focal - length image to obtain a long - focal - length grayscale image, and perform grayscale processing on the second short - focal - length image to obtain a short - focal - length grayscale image;

[0017] Perform grid division on the long - focal - length grayscale image to obtain a preset number of long - focal - length image sub - blocks;

[0018] Perform grid division on the short - focal - length grayscale image to obtain a preset number of short - focal - length image sub - blocks, where the grid division method of the long - focal - length grayscale image is the same as that of the short - focal - length grayscale image.

[0019] Optionally, the step of calculating the sharpness value of each long - focal - length image sub - block respectively includes:

[0020] For each long - focal - length image sub - block, calculate the first gradient value of each pixel in the horizontal direction and the second gradient value in the vertical direction in the long - focal - length image sub - block;

[0021] For each pixel, calculate the gradient value of the pixel according to the first gradient value of the pixel in the horizontal direction and the second gradient value in the vertical direction;

[0022] Calculate the sharpness value of the long - focal - length image sub - block according to the gradient value of each pixel in the long - focal - length image sub - block.

[0023] Optionally, determining whether the first telephoto image is out of focus according to the ratio of the number of target telephoto image sub - blocks to the total number of all telephoto image sub - blocks includes:

[0024] Determine the number of target telephoto image sub - blocks to obtain a first quantity;

[0025] Obtain the total number of all telephoto image sub - blocks to obtain a second quantity;

[0026] Calculate the ratio of the first quantity to the second quantity to obtain a target ratio;

[0027] If the target ratio is greater than a third preset threshold, determine that the first telephoto image is not out of focus;

[0028] If the target ratio is not greater than the third preset threshold, determine that the first telephoto image is out of focus.

[0029] In a second aspect, an embodiment of the present application provides an image acquisition device, and the device includes:

[0030] A first image acquisition module, configured to acquire a first telephoto image;

[0031] A second image acquisition module, configured to acquire a first short - focus image;

[0032] A processor, configured to obtain the first telephoto image and the first short - focus image acquired at the same time, where the field - of - view range of the first short - focus image includes the field - of - view range of the first telephoto image; perform grid division on the regions with the same field - of - view range in the first telephoto image and the first short - focus image to obtain each telephoto image sub - block of the first telephoto image and each short - focus image sub - block of the first short - focus image; calculate the sharpness values of each telephoto image sub - block respectively; select the image sub - blocks with sharpness values greater than a first preset threshold from each telephoto image sub - block to obtain preliminarily screened telephoto image sub - blocks; for each preliminarily screened telephoto image sub - block, calculate the difference between the sharpness value of the preliminarily screened telephoto image sub - block and the sharpness value of the corresponding short - focus image sub - block to obtain the target difference of the preliminarily screened telephoto image sub - block; determine the preliminarily screened telephoto image sub - blocks with the target difference greater than a second preset threshold as target telephoto image sub - blocks; and determine whether the first telephoto image is out of focus according to the ratio of the number of target telephoto image sub - blocks to the total number of all telephoto image sub - blocks.

[0033] Optionally, the processor is specifically configured to: scale the first telephoto image, and crop the first short - focus image to obtain a second telephoto image and a second short - focus image with the same field of view range and the same size; perform grayscale processing on the second telephoto image to obtain a telephoto grayscale image, and perform grayscale processing on the second short - focus image to obtain a short - focus grayscale image; perform grid division on the telephoto grayscale image to obtain a preset number of telephoto image sub - blocks; perform grid division on the short - focus grayscale image to obtain a preset number of short - focus image sub - blocks, where the grid division method of the telephoto grayscale image is the same as that of the short - focus grayscale image.

[0034] Optionally, the processor is specifically configured to: for each of the telephoto image sub - blocks, calculate a first gradient value of each pixel in the horizontal direction and a second gradient value of each pixel in the vertical direction in the telephoto image sub - block; for each pixel, calculate the gradient value of the pixel according to the first gradient value of the pixel in the horizontal direction and the second gradient value of the pixel in the vertical direction; calculate the clarity value of the telephoto image sub - block according to the gradient values of each pixel in the telephoto image sub - block.

[0035] Optionally, the processor is specifically configured to: determine the number of the target telephoto image sub - blocks to obtain a first number; obtain the total number of all the telephoto image sub - blocks to obtain a second number; calculate the ratio of the first number to the second number to obtain a target ratio; determine that the first telephoto image is not out of focus when the target ratio is greater than a third preset threshold; determine that the first telephoto image is out of focus when the target ratio is not greater than the third preset threshold.

[0036] In a third aspect, an image out - of - focus detection device provided by an embodiment of the present application includes:

[0037] An image acquisition module, configured to acquire a first telephoto image and a first short - focus image collected at the same time, where the field of view range of the first short - focus image includes the field of view range of the first telephoto image;

[0038] An image division module, configured to perform grid division on the regions with the same field of view range in the first telephoto image and the first short - focus image to obtain each telephoto image sub - block of the first telephoto image and each short - focus image sub - block of the first short - focus image;

[0039] A first calculation module, configured to calculate the clarity value of each of the telephoto image sub - blocks respectively;

[0040] An image screening module, configured to select the image sub - blocks with the clarity value greater than a first preset threshold from each of the telephoto image sub - blocks to obtain the initially screened telephoto image sub - blocks;

[0041] A second calculation module, configured to calculate, for each preliminarily screened long-focus image sub-block, the difference between the clarity value of the preliminarily screened long-focus image sub-block and the clarity value of the corresponding short-focus image sub-block, so as to obtain the target difference of the preliminarily screened long-focus image sub-block;

[0042] An image determination module, configured to determine, as target long-focus image sub-blocks, the preliminarily screened long-focus image sub-blocks whose target differences are greater than a second preset threshold;

[0043] A defocus detection module, configured to determine whether the first long-focus image is defocused according to the ratio of the number of the target long-focus image sub-blocks to the total number of all the long-focus image sub-blocks.

[0044] Optionally, the image division module includes:

[0045] A first processing sub-module, configured to scale the first long-focus image and crop the first short-focus image, so as to obtain a second long-focus image and a second short-focus image with the same field of view range and the same size;

[0046] A second processing sub-module, configured to perform grayscale processing on the second long-focus image to obtain a long-focus grayscale image, and perform grayscale processing on the second short-focus image to obtain a short-focus grayscale image;

[0047] A first division sub-module, configured to perform grid division on the long-focus grayscale image to obtain a preset number of long-focus image sub-blocks;

[0048] A second division sub-module, configured to perform grid division on the short-focus grayscale image to obtain a preset number of short-focus image sub-blocks, where the grid division method of the long-focus grayscale image is the same as that of the short-focus grayscale image.

[0049] Optionally, the first calculation module includes:

[0050] A first calculation sub-module, configured to calculate, for each long-focus image sub-block, a first gradient value of each pixel in the horizontal direction and a second gradient value of each pixel in the vertical direction in the long-focus image sub-block;

[0051] A second calculation sub-module, configured to calculate, for each pixel, the gradient value of the pixel according to the first gradient value of the pixel in the horizontal direction and the second gradient value of the pixel in the vertical direction;

[0052] A third calculation sub-module, configured to calculate the clarity value of the long-focus image sub-block according to the gradient values of each pixel in the long-focus image sub-block.

[0053] Optionally, the defocus detection module includes:

[0054] Determination sub-module, configured to determine the number of the target telephoto image sub-blocks, and obtain a first quantity;

[0055] Obtaining sub-module, configured to obtain the total number of all the telephoto image sub-blocks, and obtain a second quantity;

[0056] Fourth calculation sub-module, configured to calculate the ratio of the first quantity to the second quantity, and obtain a target ratio;

[0057] First determination sub-module, configured to determine that the first telephoto image is not out of focus when the target ratio is greater than a third preset threshold;

[0058] Second determination sub-module, configured to determine that the first telephoto image is out of focus when the target ratio is not greater than the third preset threshold.

[0059] Fourth aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0060] Memory, configured to store a computer program;

[0061] Processor, configured to implement the method steps described in any one of the above when executing the program stored in the memory.

[0062] Fifth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method steps described in any one of the above are implemented.

[0063] Sixth aspect, an embodiment of the present application provides a computer program product containing instructions, which when running on a computer, causes the computer to execute the method steps described in any one of the above.

[0064] Beneficial effects of the embodiments of the present application:

[0065] An image out-of-focus detection method, device, electronic device, and storage medium provided by the embodiments of the present application. Since, in the case of the same scene, the greater the difference between the clarity value of the telephoto image and the clarity value of the short-focus image, the clearer the contour of the telephoto image. Furthermore, in the long-short focus fusion scene, it is possible to effectively avoid the influence of the scene complexity factor during the image out-of-focus detection process, exclude the interference of the scene complexity or simplicity factor, and improve the accuracy of the telephoto image out-of-focus detection.

[0066] Of course, implementing any product or method of the present application does not necessarily require achieving all the above advantages at the same time. Brief Description of the Drawings

[0067] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other embodiments can also be obtained based on these drawings.

[0068] Figure 1 It is a schematic flowchart of a method for detecting image defocus in an embodiment of the present application;

[0069] Figure 2a It is a schematic diagram showing the field of view of a short-focus image in an embodiment of the present application;

[0070] Figure 2b It is a schematic diagram showing the field of view of a long-focus image in an embodiment of the present application;

[0071] Figure 3 It is a schematic flowchart of a method for dividing an image in an embodiment of the present application;

[0072] Figure 4 It is a schematic diagram showing the result of image division in an embodiment of the present application;

[0073] Figure 5 It is a schematic flowchart of a method for calculating the clarity value of an image in an embodiment of the present application;

[0074] Figure 6 It is a schematic flowchart of a method for determining image defocus in an embodiment of the present application;

[0075] Figure 7 It is a schematic structural diagram of an image acquisition device in an embodiment of the present application;

[0076] Figure 8 It is a schematic structural diagram of an image defocus detection device in an embodiment of the present application;

[0077] Figure 9 It is a schematic structural diagram of an electronic device in an embodiment of the present application. Detailed Embodiments

[0078] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art based on the present application belong to the scope of protection of the present application.

[0079] First, the relevant terms in the present application are explained:

[0080] Long - short - focus fusion: The short - focus image and the long - focus image collected by the short - focus sensor and the long - focus sensor at the same time are scaled and cropped to the same perspective and the same - sized area according to the camera internal parameters for feature fusion, so as to improve the clarity on the short - focus image with a larger field of view.

[0081] Defocus: It means that the focus is not aligned, that is, the place that should be clear becomes blurred. A clear image corresponds to a fixed focal length. Beyond this focal length, the image of the object will be blurred, resulting in the phenomenon of defocus.

[0082] Defocus detection: The long - focus image becomes blurred beyond a certain focal length and is not suitable for performing fusion operations, and a judgment is made on the blurred situation caused by the focal length problem.

[0083] Tenengrad gradient function: It is a commonly used image sharpness evaluation function and is a gradient - based function. The Sobel operator is used to extract the gradient values in the horizontal and vertical directions respectively. The larger the average gray value of the image processed by the Sobel operator, the clearer the image.

[0084] Sobel operator: It is a classic image gradient extraction operator. Its essence is based on image spatial - domain convolution. The idea is supported by the theory of the first - order derivative operator of the image and is mainly used to obtain the first - order gradient of the digital image. The common application and physical meaning are edge detection.

[0085] Brenner gradient function: Also known as the gradient filter method, it is the simplest gradient evaluation function. It only needs to calculate the gradient in one direction. By calculating the difference between the gray values of pixels separated by two units (second - order gradient), and then squaring this difference to calculate the gradient value.

[0086] Laplacian gradient function: It is an image sharpness evaluation function that uses the Laplac operator to calculate the gradient values of the pixels in the image.

[0087] To improve the accuracy of image defocus detection, the embodiments of the present application provide an image defocus detection method, device, electronic device and storage medium. Among them, an image defocus detection method provided by the embodiments of the present application can be applied to an electronic device and implemented through this electronic device. In practical applications, this electronic device can be, for example, a camera, a video camera, a terminal or a server, etc. An image defocus detection method provided by the embodiments of the present application can be applied to the image sharpness evaluation scenario of long - short - focus fusion.

[0088] See Figure 1 , an image defocus detection method provided by the embodiments of the present application includes:

[0089] S101, Obtain a first long - focus image and a first short - focus image collected at the same time.

[0090] The first long - focus image can be a long - focus image collected by a long - focus sensor for a target scene at a target time, and the first short - focus image can be a short - focus image collected by a short - focus sensor for the target scene at the target time. That is, the obtained first long - focus image and first short - focus image are respectively collected by the long - focus sensor and the short - focus sensor for the same scene at the same time.

[0091] At the same resolution, the viewing angle of the short - focus image is larger than that of the long - focus image, and the field - of - view range of the above - mentioned first short - focus image includes the field - of - view range of the first long - focus image. Exemplarily, as Figure 2a and Figure 2b shown, Figure 2a is the field - of - view range of the short - focus image, Figure 2b is the field - of - view range of the long - focus image, and the field - of - view range of the long - focus image is included in the field - of - view range of the short - focus image.

[0092] S102, Perform grid division on the regions with the same field - of - view range in the first long - focus image and the first short - focus image to obtain each long - focus image sub - block of the first long - focus image and each short - focus image sub - block of the first short - focus image.

[0093] At the same resolution, compared with the long - focus image, the short - focus image has a larger viewing angle and a wider field of view. The first long - focus image and the first short - focus image can be scaled and cropped to regions with the same viewing angle and the same size according to the camera's internal parameters, and then the regions corresponding to the first long - focus image and the regions corresponding to the first short - focus image are respectively subjected to grid division to obtain each long - focus image sub - block of the first long - focus image and each short - focus image sub - block of the first short - focus image. Specifically, the implementation method of scaling and cropping the first long - focus image and the first short - focus image to regions with the same viewing angle and the same size according to the camera's internal parameters can be the same as the prior art, and will not be elaborated again in this embodiment of the present application.

[0094] Exemplarily, a grid division of M*M can be performed on the region corresponding to the first long - focus image to obtain each long - focus image sub - block of the first long - focus image, and a grid division of M*M can be performed on the region corresponding to the first short - focus image to obtain each short - focus image sub - block of the first short - focus image, where M is a positive integer greater than 1 and can be set according to actual needs.

[0095] S103, Calculate the clarity values of each long - focus image sub - block respectively.

[0096] In one example, the Tenengrad gradient function, Brenner gradient function, or Laplacian gradient function, etc. can be used to calculate the clarity value of each long - focus image sub - block respectively.

[0097] S104. Select the image sub - blocks with sharpness values greater than the first preset threshold from each long - focal - length image sub - block to obtain the preliminarily screened long - focal - length image sub - blocks.

[0098] The first preset threshold can be set according to actual requirements. When the sharpness values of each long - focal - length image sub - block are calculated, in each long - focal - length image sub - block, according to the first preset threshold, screen the image sub - blocks with sharpness values greater than the first preset threshold, and conduct the first sharpness evaluation on the first long - focal - length image to obtain the high - quality image sub - blocks with higher sharpness values (i.e., the preliminarily screened long - focal - length image sub - blocks).

[0099] S105. For each preliminarily screened long - focal - length image sub - block, calculate the difference between the sharpness value of this preliminarily screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block to obtain the target difference of this preliminarily screened long - focal - length image sub - block.

[0100] A high sharpness value indicates that the texture of the image is rich or the contour is clear. However, a high sharpness value caused by rich texture does not necessarily mean that the contour of the image is clear, and there may still be a situation of blurred edges. Based on this, in the embodiments of the present application, for each preliminarily screened long - focal - length image sub - block obtained by screening, calculate the difference between the sharpness value of this preliminarily screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block, and compare the sharpness values of the long - focal - length image sub - block and the short - focal - length image sub - block with the same viewing angle to exclude the interference of complex or single - scene factors.

[0101] In the embodiments of the present application, the sharpness values of all short - focal - length image sub - blocks can be calculated, or only the sharpness values of the short - focal - length image sub - blocks corresponding to the preliminarily screened long - focal - length image sub - blocks can be calculated to reduce the calculation amount. Among them, the calculation method of the sharpness value of the short - focal - length image sub - block is the same as the above - mentioned calculation method of the sharpness value of the long - focal - length image sub - block.

[0102] The short - focal - length image sub - block corresponding to the preliminarily screened long - focal - length image sub - block can specifically be the short - focal - length image sub - block corresponding to the position of the preliminarily screened long - focal - length image sub - block among each short - focal - length image sub - block.

[0103] S106. Determine the preliminarily screened long - focal - length image sub - blocks with target differences greater than the second preset threshold as the target long - focal - length image sub - blocks.

[0104] In the case of the same viewing angle (or the same field - of - view scene), the greater the difference in sharpness values between the long - focal - length image sub - block and the corresponding short - focal - length image sub - block, the clearer the contour of the long - focal - length image sub - block. Select the preliminarily screened long - focal - length image sub - blocks with the difference between the sharpness value of the preliminarily screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block greater than the second preset threshold as the target long - focal - length image sub - blocks, and conduct the second sharpness evaluation on the first long - focal - length image. Among them, the second preset threshold can be set according to actual requirements.

[0105] S107. Determine whether the first telephoto image is out of focus according to the ratio of the number of target telephoto image sub-blocks to the total number of all telephoto image sub-blocks.

[0106] Calculate the ratio of the number of target telephoto image sub-blocks to the total number of all telephoto image sub-blocks, and further determine whether the first telephoto image is out of focus according to this ratio. In one example, it can be determined whether the calculated ratio meets the out-of-focus determination condition. If it meets, it is determined that the first telephoto image is out of focus; if it does not meet, it is determined that the first telephoto image is not out of focus. Among them, the out-of-focus determination condition can be set according to actual needs.

[0107] For an image out-of-focus detection method provided by an embodiment of the present application, in the case of a consistent scene, the greater the difference between the clarity value of the telephoto image and the clarity value of the short-focus image, the clearer the contour of the telephoto image. Furthermore, in a long-short focus fusion scene, it is possible to effectively avoid the influence of the scene complexity factor in the process of image out-of-focus detection by comparing the clarity values of the image sub-blocks in the same area of the field of view of the telephoto image and the short-focus image collected at the same time, excluding the interference of the scene complexity or simplicity factor, and improving the accuracy of the telephoto image out-of-focus detection. Compared with the previous clarity evaluation method, a long-short image clarity comparison condition is added on this basis, solving the drawback that the clarity rating is affected by the scene complexity and improving the accuracy of the image out-of-focus detection.

[0108] In a possible implementation manner, referring to Figure 3 , the implementation manner of step S102 above, which divides the areas with the same field of view in the first telephoto image and the first short-focus image into grids to obtain each telephoto image sub-block of the first telephoto image and each short-focus image sub-block of the first short-focus image, may include:

[0109] S301. Scale the first telephoto image and crop the first short-focus image to obtain a second telephoto image and a second short-focus image with the same field of view and the same size.

[0110] Within the specified focal length range, the resolution and clarity of a telephoto image are superior to those of a short - focal - length image. At the same resolution, compared with the telephoto image, the short - focal - length image has a larger viewing angle and a wider field of view. The first telephoto image and the first short - focal - length image collected at the same time obtained above may have differences in viewing angle and size. To better achieve the fusion of the telephoto image and the short - focal - length image, improve the clarity of the short - focal - length image with a larger field of view, and more accurately detect whether the telephoto image is out of focus. In the embodiments of the present application, the first telephoto image can be scaled according to the internal parameters of the camera, and the first short - focal - length image can be cropped to obtain a second telephoto image and a second short - focal - length image with the same field - of - view range and the same size. Specifically, the implementation method of scaling the first telephoto image according to the internal parameters of the camera and cropping the first short - focal - length image can be the same as that of the prior art, and will not be elaborated again in the embodiments of the present application.

[0111] S302, perform grayscale processing on the second telephoto image to obtain a telephoto grayscale image, and perform grayscale processing on the second short - focal - length image to obtain a short - focal - length grayscale image.

[0112] S303, perform grid division on the telephoto grayscale image to obtain a preset number of telephoto image sub - blocks.

[0113] The telephoto grayscale image can be divided into an M * M grid to obtain M * M telephoto image sub - blocks. Among them, the preset number can be set according to actual needs, and the grid division method of the telephoto grayscale image is the same as that of the short - focal - length grayscale image.

[0114] S304, perform grid division on the short - focal - length grayscale image to obtain a preset number of short - focal - length image sub - blocks.

[0115] Exemplarily, as Figure 4 shown, when M = 4, the telephoto grayscale image and the short - focal - length grayscale image are both divided into grids in the same way, and 4 * 4 telephoto image sub - blocks and 4 * 4 short - focal - length image sub - blocks can be obtained. Among them, the telephoto image sub - block and the short - focal - length image sub - block with the same serial number have the same field of view and correspond to each other.

[0116] Within the specified focal length range, the resolution and clarity of a telephoto image are superior to those of a short - focal - length image. At the same resolution, compared with the telephoto image, the short - focal - length image has a larger viewing angle and a wider field of view. The first telephoto image and the first short - focal - length image collected at the same time obtained above may have differences in viewing angle and size. After scaling the first telephoto image and cropping the first short - focal - length image to obtain a telephoto image and a short - focal - length image with the same field - of - view range and the same size, grid division is performed to facilitate better fusion of the telephoto image and the short - focal - length image, improve the clarity of the short - focal - length image with a larger field of view, and more accurately detect whether the telephoto image is out of focus.

[0117] In the embodiments of the present application, the Tenengrad gradient function is used as an example to calculate the sharpness value of an image sub-block, but it does not constitute a specific limitation on the embodiments of the present application.

[0118] In a possible implementation manner, referring to Figure 5 , the implementation manner of step S103 of calculating the sharpness values of each telephoto image sub-block respectively may include:

[0119] S501. For each telephoto image sub-block, calculate the first gradient value of each pixel in the horizontal direction and the second gradient value in the vertical direction in this telephoto image sub-block.

[0120] In one example, for each telephoto image sub-block, based on the Tenengrad gradient function, the Sobel operator can be used to calculate the first gradient value of each pixel in the horizontal direction and the second gradient value in the vertical direction in this telephoto image sub-block.

[0121] Exemplarily, the convolution kernels of the Sobel operator can be expressed as G x and G y . G x represents the convolution kernel of the Sobel operator in the horizontal direction, and G y represents the convolution kernel of the Sobel operator in the vertical direction. The first gradient value of the pixel point (x, y) in the horizontal direction in the telephoto image sub-block I can be expressed as G x * I(x, y), and the second gradient value in the vertical direction can be expressed as G y * I(x, y), where x represents the abscissa of the pixel point (x, y), and t represents the ordinate of the pixel point (x, y).

[0122]

[0123]

[0123] S502. For each pixel, calculate the gradient value of this pixel according to the first gradient value of this pixel in the horizontal direction and the second gradient value in the vertical direction.

[0124] After calculating the first gradient value G x * I(x, y) of the pixel point in the horizontal direction and the second gradient value G y * I(x, y) in the vertical direction in the telephoto image sub-block, the average value or weighted average value, etc. of G x * I(x, y) and G y * I(x, y) can be determined as the gradient value of the pixel point (x, y).

[0125] Exemplarily, the following expression can be used to calculate the gradient value of the pixel point (x, t):

[0126]

[0127] Among them, S(x, y) represents the gradient value of the pixel point (x, y).

[0128] S503. Calculate the sharpness value of the long - focal - length image sub - block according to the gradient value of each pixel in the long - focal - length image sub - block.

[0129] In one example, for each long - focal - length image sub - block, the average gradient value of the gradient values of each pixel in the long - focal - length image sub - block can be calculated, or the sum of squares can be calculated first and then divided by the total number of pixels in the long - focal - length image sub - block to obtain the sharpness value of the long - focal - length image sub - block.

[0130] Exemplarily, the sharpness value of the long - focal - length image sub - block can be calculated using the following expression:

[0131]

[0132] Among them, Ten represents the sharpness value of the long - focal - length image sub - block, n represents the total number of pixels in the long - focal - length image sub - block, S(x, y) represents the gradient value of the pixel point (x, y) in the long - focal - length image sub - block, X represents the number of pixel points on the abscissa in the long - focal - length image sub - block, and Y represents the number of pixel points on the ordinate in the long - focal - length image sub - block.

[0133] In the embodiments of the present application, the calculation method of the sharpness value of the short - focal - length image sub - block can be the same as that of the sharpness value of the long - focal - length image sub - block described above.

[0134] In a possible implementation manner, referring to Figure 6 , the implementation manner of step S107 of determining whether the first long - focal - length image is out of focus according to the ratio of the number of target long - focal - length image sub - blocks to the total number of all long - focal - length image sub - blocks may include:

[0135] S601. Determine the number of target long - focal - length image sub - blocks to obtain a first number.

[0136] S602. Obtain the total number of all long - focal - length image sub - blocks to obtain a second number.

[0137] S603. Calculate the ratio of the first number to the second number to obtain a target ratio.

[0138] S604. When the target ratio is greater than a third preset threshold, determine that the first long - focal - length image is not out of focus.

[0139] Among them, the third preset threshold can be set according to actual requirements. Determine whether the target ratio is greater than the third preset threshold, and perform a third clarity evaluation on the first telephoto image. When the target ratio is greater than the third preset threshold, it is determined that the first telephoto image is a clear image without defocus. The image quality of this first telephoto image (measured by the clarity value) is better than the corresponding short-focus image and can be used for long-focus and short-focus fusion to improve the quality of the short-focus image.

[0140] S605, when the target ratio is not greater than the third preset threshold, it is determined that the first telephoto image is defocused.

[0141] An image defocus detection method provided by an embodiment of the present application effectively avoids the influence of the scene complexity factor in the image defocus detection process and improves the accuracy of long-focus image defocus detection by comparing the clarity values of image sub-blocks in the same area of the field of view of a long-focus image and a short-focus image collected at the same time.

[0142] See Figure 7 , an embodiment of the present application further provides an image acquisition device, and the device includes:

[0143] A first image acquisition module 701, configured to acquire a first telephoto image;

[0144] A second image acquisition module 702, configured to acquire a first short-focus image;

[0145] A processor 703, configured to obtain a first telephoto image and a first short-focus image acquired at the same time, where the field of view of the first short-focus image includes the field of view of the first telephoto image; perform grid division on the areas with the same field of view in the first telephoto image and the first short-focus image to obtain each telephoto image sub-block of the first telephoto image and each short-focus image sub-block of the first short-focus image; calculate the clarity values of each telephoto image sub-block respectively; select the image sub-blocks with clarity values greater than the first preset threshold from each telephoto image sub-block to obtain initially screened telephoto image sub-blocks; for each initially screened telephoto image sub-block, calculate the difference between the clarity value of the initially screened telephoto image sub-block and the clarity value of the corresponding short-focus image sub-block to obtain the target difference of the initially screened telephoto image sub-block; determine the initially screened telephoto image sub-block with the target difference greater than the second preset threshold as the target telephoto image sub-block; and determine whether the first telephoto image is defocused according to the ratio of the number of target telephoto image sub-blocks to the total number of all telephoto image sub-blocks.

[0146] Optionally, the processor is specifically configured to: scale the first telephoto image and crop the first short - focus image to obtain a second telephoto image and a second short - focus image with the same field - of - view range and the same size; perform grayscale processing on the second telephoto image to obtain a telephoto grayscale image, and perform grayscale processing on the second short - focus image to obtain a short - focus grayscale image; perform grid division on the telephoto grayscale image to obtain a preset number of telephoto image sub - blocks; perform grid division on the short - focus grayscale image to obtain a preset number of short - focus image sub - blocks, where the grid division method of the telephoto grayscale image is the same as that of the short - focus grayscale image.

[0147] Optionally, the processor is specifically configured to: for each of the telephoto image sub - blocks, calculate a first gradient value of each pixel in the horizontal direction and a second gradient value of each pixel in the vertical direction in the telephoto image sub - block; for each pixel, calculate the gradient value of the pixel according to the first gradient value of the pixel in the horizontal direction and the second gradient value of the pixel in the vertical direction; calculate the clarity value of the telephoto image sub - block according to the gradient values of each pixel in the telephoto image sub - block.

[0148] Optionally, the processor is specifically configured to: determine the number of the target telephoto image sub - blocks to obtain a first number; obtain the total number of all the telephoto image sub - blocks to obtain a second number; calculate the ratio of the first number to the second number to obtain a target ratio; determine that the first telephoto image is not out of focus when the target ratio is greater than a third preset threshold; determine that the first telephoto image is out of focus when the target ratio is not greater than the third preset threshold.

[0149] In an example of an embodiment of the present application, the image acquisition device is a binocular camera. The binocular camera includes two lenses, one is a telephoto lens and the other is a short - focus lens. Among them, the telephoto lens uses a telephoto sensor to collect a first telephoto image, corresponding to the first image acquisition module 701; the short - focus lens uses a short - focus sensor to collect a first short - focus image, corresponding to the second image acquisition module 702. The processor 703 can be an ISP SOC (Image Signal Processor System on Chip) chip of the binocular camera, which is used to obtain the first telephoto image and the first short - focus image collected at the same time, perform grid division on the regions with the same field - of - view range in the first telephoto image and the first short - focus image, obtain each telephoto image sub - block of the first telephoto image and each short - focus image sub - block of the first short - focus image, calculate the clarity value of each telephoto image sub - block respectively, select the image sub - blocks with clarity values greater than the first preset threshold in each telephoto image sub - block to obtain the preliminarily screened telephoto image sub - blocks. For each preliminarily screened telephoto image sub - block, calculate the difference between the clarity value of the preliminarily screened telephoto image sub - block and the clarity value of the corresponding short - focus image sub - block to obtain the target difference of the preliminarily screened telephoto image sub - block. Determine the preliminarily screened telephoto image sub - blocks with target differences greater than the second preset threshold as the target telephoto image sub - blocks, and then determine whether the first telephoto image is out of focus according to the ratio of the number of target telephoto image sub - blocks to the total number of all telephoto image sub - blocks.

[0150] For an image acquisition device provided by an embodiment of the present application, in the case of a consistent scene, the greater the difference between the clarity value of the telephoto image and the clarity value of the short - focus image, the clearer the contour of the telephoto image. Furthermore, in the long - short - focus fusion scene, it is possible to effectively avoid the influence of the scene complexity factor in the process of detecting image defocus by comparing the clarity values of the image sub - blocks in the regions with the same field - of - view range of the telephoto image and the short - focus image collected at the same time, exclude the interference of the factors of complex or simple scenes, and improve the accuracy of detecting telephoto image defocus.

[0151] See Figure 8 , an embodiment of the present application further provides an image defocus detection device, and the device includes:

[0152] An image acquisition module 801, configured to obtain a first telephoto image and a first short - focus image collected at the same time, where the field - of - view range of the first short - focus image includes the field - of - view range of the first telephoto image;

[0153] An image division module 802, configured to perform grid division on the regions with the same field - of - view range in the first telephoto image and the first short - focus image, to obtain each telephoto image sub - block of the first telephoto image and each short - focus image sub - block of the first short - focus image;

[0154] The first calculation module 803 is configured to calculate the sharpness values of each long - focal - length image sub - block respectively;

[0155] The image screening module 804 is configured to select, from each long - focal - length image sub - block, the image sub - blocks with sharpness values greater than a first preset threshold to obtain the initially screened long - focal - length image sub - blocks;

[0156] The second calculation module 805 is configured to, for each initially screened long - focal - length image sub - block, calculate the difference between the sharpness value of the initially screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block to obtain the target difference of the initially screened long - focal - length image sub - block;

[0157] The image determination module 806 is configured to determine the initially screened long - focal - length image sub - blocks with target differences greater than a second preset threshold as the target long - focal - length image sub - blocks;

[0158] The defocus detection module 807 is configured to determine whether the first long - focal - length image is defocused according to the ratio of the number of target long - focal - length image sub - blocks to the total number of all long - focal - length image sub - blocks.

[0159] In the image defocus detection device provided by the embodiments of the present application, in the case of a consistent scene, the greater the difference between the sharpness value of the long - focal - length image and the sharpness value of the short - focal - length image, the clearer the contour of the long - focal - length image. Furthermore, in the long - and - short - focal - length fusion scenario, by comparing the sharpness values of the image sub - blocks in the same - area of the long - focal - length image and the short - focal - length image collected at the same moment, it is possible to effectively avoid the influence of the scene complexity factor during the image defocus detection process, eliminate the interference of the scene complexity or simplicity factor, and improve the accuracy of the long - focal - length image defocus detection.

[0160] In a possible implementation manner, the above - mentioned image division module 802 includes:

[0161] The first processing sub - module is configured to scale the first long - focal - length image and crop the first short - focal - length image to obtain a second long - focal - length image and a second short - focal - length image with the same field - of - view range and the same size;

[0162] The second processing sub - module is configured to perform grayscale processing on the second long - focal - length image to obtain a long - focal - length grayscale image, and perform grayscale processing on the second short - focal - length image to obtain a short - focal - length grayscale image;

[0163] The first division sub - module is configured to perform grid division on the long - focal - length grayscale image to obtain a preset number of long - focal - length image sub - blocks;

[0164] The second division sub - module is configured to perform grid division on the short - focal - length grayscale image to obtain a preset number of short - focal - length image sub - blocks, where the grid division method of the long - focal - length grayscale image is the same as that of the short - focal - length grayscale image.

[0165] In a possible implementation, the above-mentioned first calculation module 803 includes:

[0166] A first calculation sub-module, configured to calculate, for each long-focus image sub-block, a first gradient value of each pixel in the horizontal direction and a second gradient value of each pixel in the vertical direction in the long-focus image sub-block;

[0167] A second calculation sub-module, configured to calculate, for each pixel, a gradient value of the pixel according to the first gradient value of the pixel in the horizontal direction and the second gradient value of the pixel in the vertical direction;

[0168] A third calculation sub-module, configured to calculate a sharpness value of the long-focus image sub-block according to the gradient values of each pixel in the long-focus image sub-block.

[0169] In a possible implementation, the above-mentioned defocus detection module 807 includes:

[0170] A determination sub-module, configured to determine the number of target long-focus image sub-blocks to obtain a first quantity;

[0171] An acquisition sub-module, configured to acquire the total number of each long-focus image sub-block to obtain a second quantity;

[0172] A fourth calculation sub-module, configured to calculate a ratio of the first quantity to the second quantity to obtain a target ratio;

[0173] A first determination sub-module, configured to determine that the first long-focus image is not defocused when the target ratio is greater than a third preset threshold;

[0174] A second determination sub-module, configured to determine that the first long-focus image is defocused when the target ratio is not greater than the third preset threshold.

[0175] An embodiment of the present application further provides an electronic device, as Figure 9 shown, including a processor 901, a communication interface 902, a memory 903, and a communication bus 904. Among them, the processor 901, the communication interface 902, and the memory 903 complete communication with each other through the communication bus 904.

[0176] The memory 903 is used to store a computer program;

[0177] When the processor 901 executes the program stored in the memory 903, it implements the steps of the above-mentioned image defocus detection method to achieve the same technical effect.

[0178] The communication bus mentioned in the above-mentioned electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0179] The communication interface is used for communication between the above-mentioned electronic device and other devices.

[0180] The memory may include a Random Access Memory (RAM), or may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.

[0181] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0182] In another embodiment provided by this application, a computer-readable storage medium is also provided. A computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the steps of any of the above-mentioned image defocus detection methods are implemented to achieve the same technical effect.

[0183] In another embodiment provided by this application, a computer program product containing instructions is also provided. When it runs on a computer, the computer is made to execute the steps of any of the image defocus detection methods described in the above embodiments to achieve the same technical effect.

[0184] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive (SSD)).

[0185] It should be noted that in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device that includes the element.

[0186] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device / electronic device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and reference can be made to the corresponding parts of the method embodiments for the relevant content.

[0187] The above are only the preferred embodiments of the present application and are not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application are all included in the protection scope of the present application.

Claims

1. An image defocus detection method, characterized in that, The method includes: Obtaining a first long - focal - length image and a first short - focal - length image collected at the same moment, wherein the field - of - view range of the first short - focal - length image includes the field - of - view range of the first long - focal - length image; Scaling the first long - focal - length image and cropping the first short - focal - length image to obtain a second long - focal - length image and a second short - focal - length image with the same field - of - view range and the same size; performing grayscale processing on the second long - focal - length image to obtain a long - focal - length grayscale image, and performing grayscale processing on the second short - focal - length image to obtain a short - focal - length grayscale image; performing grid division on the long - focal - length grayscale image to obtain a preset number of long - focal - length image sub - blocks; performing grid division on the short - focal - length grayscale image to obtain a preset number of short - focal - length image sub - blocks, wherein the grid division method of the long - focal - length grayscale image is the same as that of the short - focal - length grayscale image; Calculating the sharpness value of each of the long - focal - length image sub - blocks respectively; Selecting, from each of the long - focal - length image sub - blocks, the image sub - blocks with sharpness values greater than a first preset threshold to obtain preliminarily screened long - focal - length image sub - blocks; For each preliminarily screened long - focal - length image sub - block, calculating the difference between the sharpness value of the preliminarily screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block to obtain the target difference of the preliminarily screened long - focal - length image sub - block; Determining the preliminarily screened long - focal - length image sub - blocks with target differences greater than a second preset threshold as target long - focal - length image sub - blocks; Determining whether the first long - focal - length image is out of focus according to the ratio of the number of the target long - focal - length image sub - blocks to the total number of all the long - focal - length image sub - blocks.

2. The method according to claim 1, characterized in that, The step of calculating the sharpness value of each of the long - focal - length image sub - blocks respectively includes: For each of the long - focal - length image sub - blocks, calculating a first gradient value of each pixel in the horizontal direction and a second gradient value of each pixel in the vertical direction; For each pixel, calculating the gradient value of the pixel according to the first gradient value of the pixel in the horizontal direction and the second gradient value of the pixel in the vertical direction; Calculating the sharpness value of the long - focal - length image sub - block according to the gradient values of each pixel in the long - focal - length image sub - block.

3. The method according to claim 1, characterized in that The step of determining whether the first long - focal - length image is out of focus according to the ratio of the number of the target long - focal - length image sub - blocks to the total number of all the long - focal - length image sub - blocks includes: Determining the number of the target long - focal - length image sub - blocks to obtain a first quantity; Obtaining the total number of all the long - focal - length image sub - blocks to obtain a second quantity; Calculating the ratio of the first quantity to the second quantity to obtain a target ratio; In the case where the target ratio is greater than a third preset threshold, determining that the first long - focal - length image is not out of focus; In the case where the target ratio is not greater than the third preset threshold, determining that the first long - focal - length image is out of focus.

4. An image acquisition device, characterized in that, The device includes: A first image acquisition module for acquiring a first long - focal - length image; A second image acquisition module for acquiring a first short - focal - length image; A processor is configured to obtain the first long - focal - length image and the first short - focal - length image collected at the same time, wherein the field - of - view range of the first short - focal - length image includes the field - of - view range of the first long - focal - length image; scale the first long - focal - length image and crop the first short - focal - length image to obtain a second long - focal - length image and a second short - focal - length image with the same field - of - view range and the same size; perform grayscale processing on the second long - focal - length image to obtain a long - focal - length grayscale image, and perform grayscale processing on the second short - focal - length image to obtain a short - focal - length grayscale image; perform grid division on the long - focal - length grayscale image to obtain a preset number of long - focal - length image sub - blocks; perform grid division on the short - focal - length grayscale image to obtain a preset number of short - focal - length image sub - blocks, wherein the grid division method of the long - focal - length grayscale image is the same as that of the short - focal - length grayscale image; calculate the sharpness value of each long - focal - length image sub - block respectively; select the image sub - blocks with sharpness values greater than a first preset threshold from each long - focal - length image sub - block to obtain preliminarily screened long - focal - length image sub - blocks; for each preliminarily screened long - focal - length image sub - block, calculate the difference between the sharpness value of the preliminarily screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block to obtain the target difference of the preliminarily screened long - focal - length image sub - block; determine the preliminarily screened long - focal - length image sub - blocks with the target difference greater than a second preset threshold as target long - focal - length image sub - blocks; determine whether the first long - focal - length image is out of focus according to the ratio of the number of target long - focal - length image sub - blocks to the total number of all long - focal - length image sub - blocks.

5. An image defocus detection device, characterized in that, The device includes: An image acquisition module, configured to obtain the first long - focal - length image and the first short - focal - length image collected at the same time, wherein the field - of - view range of the first short - focal - length image includes the field - of - view range of the first long - focal - length image; An image division module, configured to perform grid division on the regions with the same field - of - view range in the first long - focal - length image and the first short - focal - length image to obtain each long - focal - length image sub - block of the first long - focal - length image and each short - focal - length image sub - block of the first short - focal - length image; A first calculation module, configured to calculate the sharpness value of each long - focal - length image sub - block respectively; An image screening module, configured to select the image sub - blocks with sharpness values greater than a first preset threshold from each long - focal - length image sub - block to obtain preliminarily screened long - focal - length image sub - blocks; A second calculation module, configured to calculate, for each preliminarily screened long - focal - length image sub - block, the difference between the sharpness value of the preliminarily screened long - focal - length image sub - block and the sharpness value of the corresponding short - focal - length image sub - block to obtain the target difference of the preliminarily screened long - focal - length image sub - block; An image determination module, configured to determine the preliminarily screened long - focal - length image sub - blocks with the target difference greater than a second preset threshold as target long - focal - length image sub - blocks; An out - of - focus detection module, configured to determine whether the first long - focal - length image is out of focus according to the ratio of the number of target long - focal - length image sub - blocks to the total number of all long - focal - length image sub - blocks; The image division module includes: A first processing sub - module, configured to scale the first long - focal - length image and crop the first short - focal - length image to obtain a second long - focal - length image and a second short - focal - length image with the same field - of - view range and the same size; A second processing sub-module, configured to perform grayscale processing on the second long-focus image to obtain a long-focus grayscale image, and perform grayscale processing on the second short-focus image to obtain a short-focus grayscale image; A first dividing sub-module, configured to perform grid division on the long-focus grayscale image to obtain a preset number of long-focus image sub-blocks; A second dividing sub-module, configured to perform grid division on the short-focus grayscale image to obtain a preset number of short-focus image sub-blocks, wherein the grid division method of the long-focus grayscale image is the same as that of the short-focus grayscale image.

6. The device according to claim 5, characterized in that, The first calculation module includes: A first calculation sub-module, configured to calculate, for each long-focus image sub-block, a first gradient value of each pixel in the horizontal direction and a second gradient value of each pixel in the vertical direction in the long-focus image sub-block; A second calculation sub-module, configured to calculate, for each pixel, a gradient value of the pixel according to the first gradient value of the pixel in the horizontal direction and the second gradient value of the pixel in the vertical direction; A third calculation sub-module, configured to calculate a sharpness value of the long-focus image sub-block according to the gradient values of each pixel in the long-focus image sub-block; The out-of-focus detection module includes: A determination sub-module, configured to determine the number of the target long-focus image sub-blocks to obtain a first number; An acquisition sub-module, configured to acquire the total number of all the long-focus image sub-blocks to obtain a second number; A fourth calculation sub-module, configured to calculate a ratio of the first number to the second number to obtain a target ratio; A first determination sub-module, configured to determine that the first long-focus image is not out of focus when the target ratio is greater than a third preset threshold; A second determination sub-module, configured to determine that the first long-focus image is out of focus when the target ratio is not greater than the third preset threshold.

7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used for storing a computer program; The processor, when executing the program stored on the memory, implements the method according to any one of claims 1-3.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1-3 is implemented.

Citation Information

Patent Citations

  • Image capture apparatus and method for controlling the same

    CN107529019A

  • Method and device for judging whether camera equipment is successfully focused

    CN110662021A