CN114500859B - Automatic focusing method, photographing apparatus, and storage medium - Google Patents

Automatic focusing method, photographing apparatus, and storage medium Download PDF

Info

Publication number
CN114500859B
CN114500859B CN202210382852.6A CN202210382852A CN114500859B CN 114500859 B CN114500859 B CN 114500859B CN 202210382852 A CN202210382852 A CN 202210382852A CN 114500859 B CN114500859 B CN 114500859B
Authority
CN
China
Prior art keywords
focal length
image
current
focusing
focus
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210382852.6A
Other languages
Chinese (zh)
Other versions
CN114500859A (en
Inventor
雷静
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guoyi Quantum Technology Hefei Co ltd
Original Assignee
Chinainstru and Quantumtech Hefei Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chinainstru and Quantumtech Hefei Co Ltd filed Critical Chinainstru and Quantumtech Hefei Co Ltd
Priority to CN202210382852.6A priority Critical patent/CN114500859B/en
Publication of CN114500859A publication Critical patent/CN114500859A/en
Application granted granted Critical
Publication of CN114500859B publication Critical patent/CN114500859B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • H04N23/675Focus control based on electronic image sensor signals comprising setting of focusing regions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing
    • G06T1/0007Image acquisition
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/70Denoising; Smoothing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/73Deblurring; Sharpening
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Automatic Focus Adjustment (AREA)
  • Studio Devices (AREA)

Abstract

The invention discloses an automatic focusing method, a shooting device and a storage medium. The method comprises the following steps: acquiring a shot image based on the current focal length, calculating the image definition to obtain the initial image definition, and judging whether the shot image is a full-noise image; determining an initial focusing search position focal length, a focusing current stepping direction and a focal length stepping value according to the initial image definition and the judgment result, and calculating a focusing current stepping value according to the determination result; determining the focal length of the current focus searching position according to the focal length of the initial focus searching position, the focus current stepping direction and the focus current stepping value, acquiring a shot image based on the focal length of the current focus searching position, calculating the image definition to acquire the current image definition, judging whether the image is a full-noise image or not, and if not, determining the optimal focal length according to the relation between the i-th image definition and the i-1-th image definition, wherein i =2, 3, … and N is an integer greater than or equal to 2. The method can realize accurate search.

Description

Automatic focusing method, photographing apparatus, and storage medium
Technical Field
The present invention relates to the field of autofocus technologies, and in particular, to an autofocus method, a photographing apparatus, and a storage medium.
Background
In the related art, the automatic focusing method of the scanning electron microscope is to apply a 'hill climbing method' to continuously change the focal length in a certain step, acquire an image and calculate the definition of the image, and guide the focal length to approach the optimal value according to the definition change trend.
However, because the signal-to-noise ratio of the scanning electron microscope image is low, the conventional definition evaluation method is sensitive to noise in a high-noise image, and it is difficult to accurately reflect the change trend of the definition of the image. In addition, in the searching process, the step setting of the iterative search of the hill climbing method determines the searching efficiency, and the related technology adopts a fixed step or a variable step method according to the definition change rule, which has the defects of efficiency and accuracy. Meanwhile, in the searching process, the larger the image magnification and the larger the focal length are, the smaller the depth of field of the image is, the higher the probability of the occurrence of the full-noise image in the searching process is, and the definition of the full-noise image is in a fluctuation state, so that a local optimal value is easy to occur.
Disclosure of Invention
The present invention is directed to solving, at least in part, one of the technical problems in the related art. To this end, a first objective of the present invention is to provide an auto-focusing method to improve the accuracy of the search result.
A second object of the invention is to propose a photographing apparatus.
A third object of the invention is to propose a computer-readable storage medium.
In order to achieve the above object, an embodiment of a first aspect of the present invention provides an auto-focusing method, including: acquiring a shot image based on a current focal length, calculating the image definition of the shot image based on the current focal length to obtain initial image definition, and judging whether the shot image based on the current focal length is a full-noise image; determining an initial focusing search position focal length, a focusing current stepping direction and a focal length stepping value according to the initial image definition and the full-noise image judgment result, and calculating a focusing current stepping value according to the initial focusing search position focal length, the focusing current stepping direction and the focal length stepping value; determining the focal length of the current focusing searching position according to the focal length of the initial focusing searching position, the focusing current stepping direction and the focusing current stepping value, and acquiring a shot image based on the focal length of the current focusing searching position; calculating the image definition of the shot image based on the focal length of the current focusing searching position to obtain the current image definition, and judging whether the shot image based on the focal length of the current focusing searching position is a full noise image; when the photographed image based on the focal length of the current focus search position is not a full-noise image, determining an optimum focal length according to a relationship between an ith image resolution and an ith-1 image resolution, wherein i =2, 3, …, N being an integer of 2 or more.
In order to achieve the above object, a second embodiment of the present invention provides a shooting device, including a memory, a processor, and an auto-focusing program stored in the memory and executable on the processor, wherein the auto-focusing program, when executed by the processor, implements the auto-focusing method described above.
To achieve the above object, a third aspect of the present invention provides a computer-readable storage medium having an auto-focusing program stored thereon, the auto-focusing program implementing the above auto-focusing method when executed by a processor.
The automatic focusing method, the shooting device and the storage medium of the embodiment of the invention firstly acquire the shot image based on the current focal length, and carry out image definition calculation and judgment on whether the shot image based on the current focal length is a full-noise image; determining an initial focusing search position focal length, a focusing current stepping direction and a focal length stepping value according to the initial image definition and the full noise image judgment result, and calculating a focusing current stepping value according to the initial focusing search position focal length, the focusing current stepping direction and the focal length stepping value; determining the focal length of the current focusing searching position according to the focal length of the initial focusing searching position, the focusing current stepping direction and the focusing current stepping value, and acquiring a shot image based on the focal length of the current focusing searching position; calculating the image definition of the shot image based on the focal length of the current focusing searching position to obtain the current image definition, and judging whether the shot image based on the focal length of the current focusing searching position is a full-noise image; when the shot image based on the focal length of the current focusing search position is not a full-noise image, the optimal focal length is determined according to the relation between the definition of the ith image and the definition of the (i-1) th image, so that the situation that the shot image is trapped in local optimization in the search process can be avoided, and the accuracy of the search result is improved.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
FIG. 1 is a flow chart of an auto-focus method of one embodiment of the present invention;
fig. 2 is a flow chart of an auto-focusing method according to another embodiment of the present invention.
Detailed Description
An auto-focusing method, a photographing apparatus, and a storage medium according to embodiments of the present invention are described below with reference to the accompanying drawings, in which the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described with reference to the drawings are illustrative and should not be construed as limiting the invention.
FIG. 1 is a flow chart of an auto-focus method of one embodiment of the present invention.
As shown in fig. 1, the auto-focusing method includes:
and S11, acquiring the shot image based on the current focal length, calculating the image definition of the shot image based on the current focal length, acquiring the initial image definition, and judging whether the shot image based on the current focal length is a full-noise image.
Specifically, when auto-focusing is required, the current focal length WD is acquired first c . Obtaining the current focal length WD c Then, based on the current focal length WD c Shooting to obtain an image, and then utilizing a preset image definition evaluation method to evaluate the WD based on the current focal length c The shot image is subjected to image definition calculation to obtain initial image definition, and the judgment is carried out by utilizing a preset full-noise image judgment method based on the current focal length WD c Whether or not the captured image of (1) is a full-noise image. The preset image definition evaluation method may be a preset definition evaluation function, for example, a function for evaluating image definition such as an energy gradient function and a Brenner function may be used, and of course, other possible methods may also be used.
Alternatively, referring to fig. 2, the parameter N may be set in advance c Using the parameter N c The display is based on the current focal length WD c If it is based on the current focal length WD, the result of the determination of the full-noise image of the captured image c Is a full-noise image, then N c =1。
And S12, determining the focal length of the initial focusing searching position, the focusing current stepping direction and the focal length stepping value according to the initial image definition and the judgment result of the full noise image, and calculating the focusing current stepping value according to the focal length of the initial focusing searching position, the focusing current stepping direction and the focal length stepping value.
Specifically, the determination based on the current focal length WD is made based on the full-noise image determination result c When the shot image is a full-noise image, the recommended focal length is used as the initial focus search position focal length, the direction value corresponding to the focus current stepping direction is determined to be-1, and the formula [ delta ] WD = [ delta ] WD d /((M+M d )/M d ) Calculating a focus step value, where Δ WD is the focus step value and Δ WD d Is the default maximum focus step value, M is the current magnification, M d To influence the magnification scale parameter of the stepping. The focus current step value is calculated according to the following formula:
△I=Func W2I (WD 0 +dire*△WD)-Func W2I (WD 0 ),
wherein WD 0 For initial focus search position focus, Δ WD is focus step value, dire is focus current step direction, Δ I is focus current step value, Func W2I () As a function of focus-to-focus current.
Based on the current focal length WD determined from the full-noise image judgment result c When the shot image is not a full-noise image, obtaining the shot image based on the recommended focal length, and performing image definition calculation according to the shot image based on the recommended focal length to obtain the definition of the reference image; and determining the focal length of the initial focusing searching position, the focusing current stepping direction and the focal length stepping value according to the relation between the initial image definition and the reference image definition.
Specifically, after image capturing is performed based on the recommended focal length, image sharpness calculation is performed on the captured image based on the recommended focal length using a preset image sharpness evaluation method, and whether the captured image based on the recommended focal length is a full noise image is determined using a preset full noise image determination method. Referring to fig. 2, the recommended focal distance can be obtained by software according to the height of the electron gun collector shoe minus the height of the sample stage plus an error value, for example, to take an imageOf the device of (1) a recommended focal length WD d
After the judgment result of the reference image and the definition of the reference image are obtained, a method for determining the focal length of the initial focusing search position, the focusing current stepping direction and the focal length stepping value can be obtained according to whether the following formula is satisfied:
C c *thresh_ratio<C d
wherein, C c For initial image definition, the thresh _ ratio is a preset ratio, C d Is the reference image sharpness.
When the product of the initial image definition and the preset ratio is smaller than the reference image definition, taking the recommended focal distance as the initial focusing search position focal distance, determining a direction value corresponding to the focusing current stepping direction as-1, and determining that the formula is delta WD =deltaWD d /((M+M d )/M d ) Calculating a focus step value, where Δ WD is the focus step value and Δ WD d Is the default maximum focus step value, M is the current magnification, M d To influence the magnification scale parameter of the stepping. The focus current step value is calculated according to the following formula:
△I=Func W2I (WD 0 +dire*△WD)-Func W2I (WD 0 )。
when the product of the initial image definition and the preset ratio is more than or equal to the reference image definition, the current focal length WD is set c As the initial focus search position focal length, determining the direction value corresponding to the focus current stepping direction as-1, and according to the current focal length WD c A first depth of field is calculated and a focus step value is determined based on the first depth of field. At this time, the first depth of field is calculated according to the following formula:
Figure 425972DEST_PATH_IMAGE001
wherein df is a first depth of field, a is a first fixed coefficient, and B is a second fixed coefficient;
calculating a focus step value according to the following formula:
△WD=wd_p*df,
wherein wd _ p is a first empirical coefficient, which may be, for example, 1/2;
the focus current step value is calculated according to the following formula:
△I=Func W2I (WD 0 +dire*△WD)-Func W2I (WD 0 )。
and S13, determining the focal distance of the current focus searching position according to the initial focus searching position focal distance, the focus current stepping direction and the focus current stepping value, and acquiring a shot image based on the focal distance of the current focus searching position.
Specifically, the current focus search position focal length is determined according to the following formula:
WD i+1 =Func I2W (Func w2I (WD i )+dire*△I),
wherein WD i+1 For the current focus search position focal distance, i =0, 1, 2, …, N, WD 0 Searching for the position focal length for initial focus, dire the focus current step direction, Δ I the focus current step value, Func W2I () As a function of focus-to-focus current, Func I2W () As a function of current focus.
And S14, calculating the image definition of the shot image based on the focal distance of the current focusing searching position, obtaining the current image definition, and judging whether the shot image based on the focal distance of the current focusing searching position is a full-noise image.
Specifically, after a photographed image based on the focal length of the current focus search position is acquired, image sharpness calculation is performed on the photographed image based on the focal length of the current focus search position using a preset image sharpness evaluation method, and whether the photographed image based on the focal length of the current focus search position is a full-noise image is determined using a preset full-noise image determination method.
If the captured image based on the focal length of the current focus search position is a full-noise image, the process returns to step S13, and the focal length of the current focus search position is set as the new WD i And re-determining the focal distance of the current focusing search position, and acquiring a shot image based on the focal distance of the current focusing search position.
Alternatively, referring to fig. 2, the parameter N may be set in advance i Using the parameter N i Displaying the full-noise image determination result of the photographed image based on the focal length of the current focus search position, i.e., if the photographed image based on the focal length of the current focus search position is a full-noise image, N i =1。
And S15, when the shot image based on the focal distance of the current focus search position is not a full-noise image, determining an optimal focal distance according to the relationship between the ith image definition and the (i-1) th image definition, wherein i =2, 3, …, N, and N is an integer greater than or equal to 2.
Specifically, if the captured image based on the focal length of the current focus search position is not a full-noise image but the image sharpness obtained by performing the image sharpness calculation on the captured image based on the focal length of the current focus search position is the 1 st image sharpness, the process returns to step S13, and the focal length of the current focus search position is set as the new WD i And re-determining the focal distance of the current focusing search position, and acquiring a shot image based on the focal distance of the current focusing search position.
And if the shot image based on the focal distance of the current focusing searching position is not a full-noise image, and the image definition obtained by calculating the image definition of the shot image based on the focal distance of the current focusing searching position is the ith image definition, wherein i =2, 3, … and N, and N is an integer greater than or equal to 2, judging the size relationship between the ith image definition and the ith-1 image definition. Wherein, the ith image is the shot image based on the focal distance of the current focusing search position.
When the ith image definition is greater than or equal to the (i-1) th image definition, the process returns to step S13 to set the current focus search position focal length as the new WD i And re-determining the focal distance of the current focusing search position, and acquiring a shot image based on the focal distance of the current focusing search position.
And when the ith image definition is smaller than the ith-1 image definition, judging whether the following scenes (1), (2) and (3) are satisfied, and when any one of the following scenes (1), (2) and (3) is satisfied, taking the focal length corresponding to the ith-1 image definition as the optimal focal length.
(1) And calculating a second depth of field according to the focal length of the current focus searching position, and taking the focal length of the current focus searching position as the optimal focal length when the focal length stepping value and the second depth of field meet a first preset relation.
Specifically, the second depth of field is first calculated according to the following formula:
Figure 143392DEST_PATH_IMAGE002
wherein df1 is the second depth of field;
secondly, whether the focal length stepping value and the second depth of field satisfy a first preset relation as follows is judged:
△WD<=df1/2,
and when the focus stepping value and the second depth of field meet the first preset relation, taking the focus corresponding to the i-1 th image definition as the optimal focus.
(2) And when the ith image definition is smaller than the (i-1) th image definition, if i is larger than 2, determining the larger value of the ith image definition and the (i-2) th image definition, and when the ratio of the larger value to the (i-1) th image definition is smaller than or equal to a preset threshold, taking the focal distance corresponding to the (i-1) th image definition as the optimal focal distance. The preset threshold may be, for example, 0.005.
(3) And when the ith image definition is smaller than the (i-1) th image definition, if i is equal to 2, when the 2 nd image definition and the 1 st image definition meet a second preset relation, taking the focal length corresponding to the (i-1) th image definition as the optimal focal length.
Alternatively, referring to fig. 2, for the scenarios (2) and (3), the following formula can be adopted to determine whether the scenario is satisfied:
max(C i-2 ,C i )/C i-1 <=thresh_C,
wherein, C i-2 The i-2 image definition, C i-1 The i-1 image definition, C i As the ith imageDefinition, thresh _ C is a preset threshold. And if i is larger than 2, acquiring the ratio of the larger value of the ith image definition and the ith-2 image definition to the ith-1 image definition, and judging the size relation between the ratio and a preset threshold value. If i is equal to 2, directly judging C i /C i-1 And thresh _ C.
It should be noted that, when the ith image resolution is smaller than the (i-1) th image resolution, if the first preset relationship is not satisfied between the focus stepping value and the second depth of field, the ratio between the larger value and the (i-1) th image resolution is greater than the preset threshold when i is greater than 2, and the second preset relationship is not satisfied between the 2 nd image resolution and the 1 st image resolution when i is equal to 2, the focus stepping direction is inverted, the focus stepping value is halved, the focus stepping value is recalculated according to the halved focus stepping value, and then the current focus search position focus is re-determined according to the recalculated focus stepping value.
Specifically, if none of the above (1), (2), and (3) is satisfied, the focus current stepping direction, the focus stepping value, and the focus current stepping value are updated according to the following equations:
dire=dire*-1,
△WD=△WD/2,
△I=Func W2I (WD i +dire*△WD)-Func W2I (WD i );
next, returning to step S13, the current focus search position focal length is made the new WD i And re-determining the focal distance of the current focusing search position, and acquiring a shot image based on the focal distance of the current focusing search position.
In an embodiment of the present invention, the method for evaluating image sharpness includes:
and acquiring an image to be evaluated, and dividing the image to be evaluated into a plurality of image sub-blocks, for example, the image to be evaluated can be divided into 16 × 16 image sub-blocks.
After the image to be evaluated is divided into a plurality of image sub-blocks, the pixel gray value variance of each image sub-block is calculated, and then the mean value and the variance of the pixel gray value variance of each image sub-block are calculated, so that the definition of the image to be evaluated is calculated according to the following formula:
Figure 725552DEST_PATH_IMAGE003
wherein, M is the mean value of the variance of the pixel gray value of each image sub-block, and sigma is the variance of the pixel gray value of each image sub-block.
Therefore, the definition evaluation method which has good anti-noise performance and can accurately measure definition is provided, and the method is wider in application range and higher in accuracy.
In an embodiment of the present invention, the above-mentioned full-noise image determination method includes:
obtaining an image to be judged, estimating to obtain the image noise variance of the image to be judged, performing Gaussian blur on the image to be judged according to the noise variance, and obtaining a smoothed image.
The smoothed image is divided into a plurality of sub-block images, for example, 16 × 16 sub-block images may be divided. After the sub-block images are obtained through division, the pixel gray value variance of each sub-block image is calculated, and then the variance of the pixel gray value variance of each sub-block image is calculated.
And comparing the variance of the pixel gray value variance of each sub-block image with a variance threshold Thresh _ allNoise, and if the variance of the pixel gray value variance of each sub-block image is smaller than the variance threshold, determining that the image to be judged is a full-noise image.
Therefore, the method for identifying the full noise image under the condition of different signal-to-noise ratios is provided, because when the image is the full noise image, more local peak values appear on the definition evaluation function curve, if the image is judged to be at the full noise position, the current peak value is a false peak, the position is rapidly jumped out, and the probability of trapping in the local optimum in the searching process is reduced.
To sum up, the auto-focusing method of the embodiment of the present invention first obtains the current focal length WD c The image sharpness calculation is performed on the captured image based on the current focal length WDcAnd whether it is a full-noise image; determining an initial focusing search position focal length, a focusing current stepping direction and a focal length stepping value according to the initial image definition and the full noise image judgment result, and calculating a focusing current stepping value according to the initial focusing search position focal length, the focusing current stepping direction and the focal length stepping value; determining the focal length of the current focusing searching position according to the focal length of the initial focusing searching position, the focusing current stepping direction and the focusing current stepping value, and acquiring a shot image based on the focal length of the current focusing searching position; calculating the image definition of the shot image based on the focal length of the current focusing searching position to obtain the current image definition, and judging whether the shot image based on the focal length of the current focusing searching position is a full-noise image; when the shot image based on the focal length of the current focusing search position is not a full-noise image, the optimal focal length is determined according to the relation between the definition of the ith image and the definition of the (i-1) th image, so that the situation that the shot image is trapped in local optimization in the search process can be avoided, and the accuracy of the search result is improved. Moreover, the automatic focusing method of the invention steps based on the imaging depth of field, and can quickly and accurately approach the in-focus position. In addition, the invention also provides a total noise image judgment method, which can identify the total noise image under the condition of different signal-to-noise ratios and further reduce the probability of falling into local optimum. Moreover, the invention also provides an image definition evaluation method which has the advantages of good noise resistance, wide application range and higher accuracy.
Further, the invention provides a shooting device.
In an embodiment of the present invention, a photographing apparatus includes a memory, a processor, and an auto-focusing program stored on the memory and executable on the processor, and when the auto-focusing program is executed by the processor, the auto-focusing method described above is implemented.
The shooting device of the embodiment of the invention can firstly obtain the WD based on the current focal length by realizing the automatic focusing method c For the current focal distance WD c The shot image is subjected to image definition calculation and judgment on whether the shot image is a full-noise image or not; according to initial image definitionDetermining an initial focusing search position focal length, a focusing current stepping direction and a focal length stepping value according to the full-noise image judgment result, and calculating a focusing current stepping value according to the initial focusing search position focal length, the focusing current stepping direction and the focal length stepping value; determining the focal length of the current focusing searching position according to the focal length of the initial focusing searching position, the focusing current stepping direction and the focusing current stepping value, and acquiring a shot image based on the focal length of the current focusing searching position; calculating the image definition of the shot image based on the focal length of the current focusing searching position to obtain the current image definition, and judging whether the shot image based on the focal length of the current focusing searching position is a full-noise image; when the shot image based on the focal length of the current focusing search position is not a full-noise image, the optimal focal length is determined according to the relation between the definition of the ith image and the definition of the (i-1) th image, so that the situation that the shot image is trapped in local optimization in the search process can be avoided, and the accuracy of the search result is improved. Moreover, the automatic focusing method of the invention steps based on the imaging depth of field, and can quickly and accurately approach the in-focus position. In addition, the invention also provides a total noise image judgment method, which can identify the total noise image under the condition of different signal-to-noise ratios and further reduce the probability of falling into local optimum. Moreover, the invention also provides an image definition evaluation method which has the advantages of good noise resistance, wide application range and higher accuracy.
The invention also provides a computer readable storage medium.
In an embodiment of the present invention, an autofocus program is stored on a computer-readable storage medium, and when executed by a processor, implements the autofocus method described above.
The computer readable storage medium of the embodiment of the present invention, when the computer program is executed by the processor, may first obtain the current focal length WD c For the current focal length WD based on c The shot image is subjected to image definition calculation and judgment on whether the shot image is a full-noise image or not; determining the focal length of the initial focusing search position, the stepping direction of the focusing current and the sum of the initial focusing search position and the focusing current according to the initial image definition and the judgment result of the full noise imageA focus stepping value, and calculating a focus current stepping value according to the focus of the initial focus search position, the focus current stepping direction and the focus stepping value; determining the focal length of the current focusing searching position according to the focal length of the initial focusing searching position, the focusing current stepping direction and the focusing current stepping value, and acquiring a shot image based on the focal length of the current focusing searching position; calculating the image definition of the shot image based on the focal length of the current focusing searching position to obtain the current image definition, and judging whether the shot image based on the focal length of the current focusing searching position is a full-noise image; when the shot image based on the focal length of the current focusing search position is not a full-noise image, the optimal focal length is determined according to the relation between the definition of the ith image and the definition of the (i-1) th image, so that the situation that the shot image is trapped in local optimization in the search process can be avoided, and the accuracy of the search result is improved. Moreover, the automatic focusing method of the invention steps based on the imaging depth of field, and can quickly and accurately approach the in-focus position. In addition, the invention also provides a total noise image judgment method, which can identify the total noise image under the condition of different signal-to-noise ratios and further reduce the probability of falling into local optimum. Moreover, the invention also provides an image definition evaluation method which has the advantages of good noise resistance, wide application range and higher accuracy.
It should be noted that the logic and/or steps represented in the flowcharts or otherwise described herein may be considered as a sequential list of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
In the description herein, the terms "central," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," "circumferential," and the like refer to orientations and positional relationships based on the orientation shown in the drawings, and do not indicate or imply that the referenced device or element must have a particular orientation, be constructed and operated in a particular orientation, and are not to be construed as limiting the present invention.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
In the description of the present specification, unless otherwise specified, the terms "mounted," "connected," "fixed," and the like are to be construed broadly, e.g., as meaning fixedly connected, detachably connected, or integrally formed; can be mechanically or electrically connected; they may be directly connected or indirectly connected through intervening media, or they may be connected internally or in any other suitable relationship, unless expressly stated otherwise. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
In the present invention, unless otherwise expressly stated or limited, the first feature "on" or "under" the second feature may be directly contacting the first and second features or indirectly contacting the first and second features through an intermediate. Also, a first feature "on," "over," and "above" a second feature may be directly or diagonally above the second feature, or may simply indicate that the first feature is at a higher level than the second feature. A first feature being "under," "below," and "beneath" a second feature may be directly under or obliquely under the first feature, or may simply mean that the first feature is at a lesser elevation than the second feature.
Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.

Claims (10)

1. An auto-focusing method, the method comprising:
acquiring a shot image based on a current focal length, calculating the image definition of the shot image based on the current focal length to obtain initial image definition, and judging whether the shot image based on the current focal length is a full-noise image;
determining an initial focusing search position focal length, a focusing current stepping direction and a focal length stepping value according to the initial image definition and the full-noise image judgment result, and calculating a focusing current stepping value according to the initial focusing search position focal length, the focusing current stepping direction and the focal length stepping value;
determining the focal length of the current focusing searching position according to the focal length of the initial focusing searching position, the focusing current stepping direction and the focusing current stepping value, and acquiring a shot image based on the focal length of the current focusing searching position;
calculating the image definition of the shot image based on the focal length of the current focusing searching position to obtain the current image definition, and judging whether the shot image based on the focal length of the current focusing searching position is a full noise image;
when the photographed image based on the focal length of the current focus search position is not a full-noise image, determining an optimum focal length according to a relationship between an ith image resolution and an ith-1 image resolution, wherein i =2, 3, …, N being an integer of 2 or more.
2. The method of claim 1, wherein determining an initial focus search position focal length, a focus current step direction, and a focal length step value based on the initial image sharpness and full noise image determination comprises:
when the shot image based on the current focal length is determined to be not the full-noise image according to the full-noise image judgment result, obtaining a shot image based on a recommended focal length, and performing image definition calculation according to the shot image based on the recommended focal length to obtain reference image definition;
and determining the focal length of the initial focusing searching position, the focusing current stepping direction and the focal length stepping value according to the relation between the initial image definition and the reference image definition.
3. The method of claim 2, wherein determining the initial focus search position focal length, the focus current step direction, and the focal length step value from a relationship between the initial image sharpness and the reference image sharpness comprises:
when the product of the initial image definition and a preset ratio is smaller than the reference image definition, the recommended focal distance is used as the initial focusing search position focal distance, the direction value corresponding to the focusing current stepping direction is determined to be-1, and the formula delta WD =deltaWD is used d /((M+M d )/M d ) Calculating the focus step value, wherein Δ WD is the focus step value, Δ WD d Is the default maximum focus step value, M is the current magnification, M d A magnification scale parameter that affects stepping;
and when the product of the initial image definition and a preset ratio is greater than or equal to the reference image definition, taking the current focal length as the initial focusing search position focal length, determining a direction value corresponding to the focusing current stepping direction as-1, calculating a first depth of field according to the current focal length, and determining the focal length stepping value according to the first depth of field.
4. The method of claim 2, wherein determining an initial focus search position focal length, a focus current step direction, and a focal length step value based on the initial image sharpness and full noise image determination, further comprises:
when the shot image based on the focal distance of the current focus search position is determined to be the full noise image according to the full noise image judgment result, the recommended focal distance is used as the focal distance of the initial focus search position, the direction value corresponding to the focus current stepping direction is determined to be-1, and the formula delta WD =deltaWD is used d /((M+M d )/M d ) Calculating the focus step value, wherein Δ WD is the focus step value, Δ WD d Is the default maximum focus step value, M is the current magnification, M d To influence the magnification scale parameter of the stepping.
5. The method according to any of claims 1-4, wherein the focus current step value is calculated according to the following formula:
△I=Func W2I (WD 0 +dire*△WD)-Func W2I (WD 0 ),
wherein WD 0 For the initial focus search position focal length, Δ WD is the focal length step value, dire is the focus current step direction, Δ I is the focus current step value, Func W2I () As a function of focus-to-focus current.
6. The method according to any of claims 1-4, wherein the current focus search location focal distance is determined according to the following formula:
WD i+1 =Func I2W (Func w2I (WD i )+dire*△I),
wherein WD i+1 I =0, 1, 2, …, N, WD for the current focus search position focal distance 0 For the initial focus search position focal length, dire is the focus current step direction, Δ I is the focus current step value, Func W2I () As a function of focus-to-focus current, Func I2W () As a function of current focus.
7. The method of any of claims 1-4, wherein determining the optimal focal distance from the relationship between the ith image resolution and the ith-1 image resolution comprises:
when the definition of the ith image is smaller than the definition of the (i-1) th image, calculating a second depth of field according to the focal length of the current focusing search position, and when the focal length stepping value and the second depth of field meet a first preset relation, taking the focal length corresponding to the definition of the (i-1) th image as the optimal focal length; or
When the ith image definition is smaller than the (i-1) th image definition, if i is larger than 2, determining the larger value of the ith image definition and the (i-2) th image definition, and when the ratio of the larger value to the (i-1) th image definition is smaller than or equal to a preset threshold, taking the focal distance corresponding to the (i-1) th image definition as the optimal focal distance; or
And when the ith image definition is smaller than the (i-1) th image definition, if i is equal to 2, when the second preset relation is met between the 2 nd image definition and the 1 st image definition, taking the focal length corresponding to the (i-1) th image definition as the optimal focal length.
8. The method of claim 7, wherein when the ith image resolution is less than the (i-1) th image resolution, the method further comprises:
and if the focal length stepping value and the second depth of field do not satisfy a first preset relationship, the ratio of the larger value to the i-1 st image definition is larger than a preset threshold when i is larger than 2, and the second preset relationship is not satisfied between the 2 nd image definition and the 1 st image definition when i is equal to 2, inverting the focusing current stepping direction, halving the focal length stepping value, recalculating the focusing current stepping value according to the halved focal length stepping value, and returning to redetermine the focal length of the current focusing search position according to the recalculated focusing current stepping value.
9. A camera device comprising a memory, a processor, and an autofocus program stored on the memory and executable on the processor, the autofocus program when executed by the processor implementing the autofocus method of any of claims 1-8.
10. A computer-readable storage medium, having stored thereon an auto-focusing program which, when executed by a processor, implements the auto-focusing method of any one of claims 1 to 8.
CN202210382852.6A 2022-04-13 2022-04-13 Automatic focusing method, photographing apparatus, and storage medium Active CN114500859B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210382852.6A CN114500859B (en) 2022-04-13 2022-04-13 Automatic focusing method, photographing apparatus, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210382852.6A CN114500859B (en) 2022-04-13 2022-04-13 Automatic focusing method, photographing apparatus, and storage medium

Publications (2)

Publication Number Publication Date
CN114500859A CN114500859A (en) 2022-05-13
CN114500859B true CN114500859B (en) 2022-08-02

Family

ID=81487752

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210382852.6A Active CN114500859B (en) 2022-04-13 2022-04-13 Automatic focusing method, photographing apparatus, and storage medium

Country Status (1)

Country Link
CN (1) CN114500859B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115278072B (en) * 2022-07-25 2024-05-24 武汉精立电子技术有限公司 Automatic focusing method and system for Micro LED detection
CN116600201B (en) * 2023-07-17 2023-11-03 北京中科科仪股份有限公司 Automatic focusing method and device based on scanning electron microscope
CN117835058B (en) * 2024-03-06 2024-05-14 深圳市翔飞科技股份有限公司 High-definition analog camera control system and method of automatic focusing mechanism

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2621161A2 (en) * 2012-01-30 2013-07-31 Broadcom Corporation Method and system for an adaptive auto-focus algorithm
CN104284095A (en) * 2014-10-28 2015-01-14 福建福光数码科技有限公司 Quick and automatic focusing method and system for long-focus visible-light industrial lens
CN106534676A (en) * 2016-11-02 2017-03-22 西安电子科技大学 Automatic focus adjustment method for zoom camera systems
CN108780209A (en) * 2016-03-18 2018-11-09 富士胶片株式会社 Focusing position detection device and method for detecting state of focusing

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9398205B2 (en) * 2010-09-01 2016-07-19 Apple Inc. Auto-focus control using image statistics data with coarse and fine auto-focus scores
US8922704B2 (en) * 2010-09-01 2014-12-30 Apple Inc. Techniques for collection of auto-focus statistics
US9648261B2 (en) * 2015-08-26 2017-05-09 Apple Inc. Account for clipped pixels in auto-focus statistics collection

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2621161A2 (en) * 2012-01-30 2013-07-31 Broadcom Corporation Method and system for an adaptive auto-focus algorithm
CN104284095A (en) * 2014-10-28 2015-01-14 福建福光数码科技有限公司 Quick and automatic focusing method and system for long-focus visible-light industrial lens
CN108780209A (en) * 2016-03-18 2018-11-09 富士胶片株式会社 Focusing position detection device and method for detecting state of focusing
CN106534676A (en) * 2016-11-02 2017-03-22 西安电子科技大学 Automatic focus adjustment method for zoom camera systems

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Multi-focus image fusion based on block matching in3D transform domain;YANG Dongsheng等;《Journal of Systems Engineering and Electronics》;20180415(第02期);全文 *
一种基于图像处理的舌象采集自动调焦算法;韦玉科等;《山东大学学报(工学版)》;20110816(第04期);全文 *
基于图像清晰度的自动聚焦算法;王蔚等;《计算机应用与软件》;20031212(第12期);全文 *

Also Published As

Publication number Publication date
CN114500859A (en) 2022-05-13

Similar Documents

Publication Publication Date Title
CN114500859B (en) Automatic focusing method, photographing apparatus, and storage medium
CN103155537B (en) Based on face detection and the continuous autofocus of tracking
TWI324015B (en) Autofocus searching method
EP2448246B1 (en) Method for focusing
EP3236648B1 (en) Focusing for point light source scene
KR101891364B1 (en) Fast auto-focus in microscopic imaging
CN112099217B (en) Automatic focusing method for microscope
JP4364078B2 (en) Imaging method and imaging apparatus
US8570432B2 (en) Focus adjustment apparatus and image capturing apparatus
JP2011039460A (en) Automatic focusing device
WO2010028224A1 (en) Apparatus, method, and manufacture for iterative auto-focus using depth-from-defocus
CN110824689B (en) Full-automatic microscopic image depth of field expanding system and method thereof
CN108710192B (en) Automatic focusing system and method based on statistical data
JP6900161B2 (en) Focus adjustment device and imaging device
US8049813B1 (en) System for topology based automatic focus
CN114040067B (en) Automatic focusing method and device based on electron beam measuring equipment, equipment and storage medium
JP3226861B2 (en) Automatic focusing method
US7844172B1 (en) Adaptive autofocus lens positioning
CN116600201B (en) Automatic focusing method and device based on scanning electron microscope
CN112904548B (en) Endoscope focusing method and device
CN116980757A (en) Quick focusing method, focusing map updating method, device and storage medium
CN106210551A (en) Picture pick-up device and control method thereof
JP5369729B2 (en) Image processing apparatus, imaging apparatus, and program
CN116567412A (en) Zoom tracking curve determination method, apparatus, computer device and storage medium
US20160086335A1 (en) Image processing apparatus, image processing method, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: 230088 floor 1-4, zone a, building E2, phase II, innovation industrial park, No. 2800, innovation Avenue, high tech Zone, Hefei, Anhui Province

Patentee after: Guoyi Quantum Technology (Hefei) Co.,Ltd.

Address before: 230088 floor 1-4, zone a, building E2, phase II, innovation industrial park, No. 2800, innovation Avenue, high tech Zone, Hefei, Anhui Province

Patentee before: Guoyi Quantum (Hefei) Technology Co.,Ltd.

CP01 Change in the name or title of a patent holder