CN117452617A - Focusing method, focusing device, electronic equipment and storage medium - Google Patents

Focusing method, focusing device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117452617A
CN117452617A CN202311261612.1A CN202311261612A CN117452617A CN 117452617 A CN117452617 A CN 117452617A CN 202311261612 A CN202311261612 A CN 202311261612A CN 117452617 A CN117452617 A CN 117452617A
Authority
CN
China
Prior art keywords
image
images
lens
definition
focusing
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.)
Pending
Application number
CN202311261612.1A
Other languages
Chinese (zh)
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.)
Shanghai Lichuang Technology Co ltd
Original Assignee
Shanghai Lichuang Technology 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 Shanghai Lichuang Technology Co ltd filed Critical Shanghai Lichuang Technology Co ltd
Priority to CN202311261612.1A priority Critical patent/CN117452617A/en
Publication of CN117452617A publication Critical patent/CN117452617A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G02OPTICS
    • G02BOPTICAL ELEMENTS, SYSTEMS OR APPARATUS
    • G02B21/00Microscopes
    • G02B21/24Base structure
    • G02B21/241Devices for focusing
    • G02B21/244Devices for focusing using image analysis techniques
    • GPHYSICS
    • G02OPTICS
    • G02BOPTICAL ELEMENTS, SYSTEMS OR APPARATUS
    • G02B7/00Mountings, adjusting means, or light-tight connections, for optical elements
    • G02B7/28Systems for automatic generation of focusing signals
    • G02B7/36Systems for automatic generation of focusing signals using image sharpness techniques, e.g. image processing techniques for generating autofocus signals

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • General Physics & Mathematics (AREA)
  • Optics & Photonics (AREA)
  • Chemical & Material Sciences (AREA)
  • Analytical Chemistry (AREA)
  • Automatic Focus Adjustment (AREA)

Abstract

The invention relates to a focusing method, a focusing device, electronic equipment and a storage medium, wherein the method comprises the following steps: controlling the lens to move from a first distance away from the target object to the target object and collecting a plurality of images; selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value; carrying out noise reduction treatment on the plurality of first images, and calculating definition by using a Laplacian function; the adjusting lens is moved to a position corresponding to the first image with the highest definition. According to the focusing method, the lens is controlled to move towards the target object, a plurality of images are collected, a plurality of first images with gray non-zero value statistics function values larger than a first threshold value are selected, the definition is calculated by using a Laplacian function after noise reduction treatment, the lens is moved to a position corresponding to the first image with the highest definition, and the position is an ideal focusing position.

Description

Focusing method, focusing device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of focusing technologies, and in particular, to a focusing method, a focusing device, an electronic device, and a storage medium.
Background
In automated film reading technology, the focusing process of the microscope is a critical step. There are two main focusing methods at present: active focusing and passive focusing. The active focusing method realizes automatic focusing by measuring the distance between the lens and the shot object and moving the lens to the focus position. And the passive focusing method compares the change trend of the image definition at different positions according to the feedback of the image signal, thereby automatically adjusting the focus position. Due to the continuous progress of image processing technology, passive focusing technology is widely used in automatic microscopes.
Two important factors affecting the microscope focusing algorithm are the sharpness evaluation function and the focus position search method. However, in the case of processing high resolution pictures and acquiring a large number of pictures, the conventional algorithm has some drawbacks. First, active focusing methods typically rely on complex ranging techniques, which are costly and difficult to implement. And secondly, the calculated amount of the evaluation function is large, particularly when a high-resolution camera is used, the focusing speed is low, and the practical application requirement cannot be met.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a focusing method, apparatus, computer device, and readable storage medium that have low cost, low calculation amount, and high focusing speed.
The invention provides a focusing method, which comprises the following steps:
controlling a lens to move from a first distance away from a target object to the target object and collecting a plurality of images;
selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value from the plurality of images;
carrying out noise reduction treatment on the plurality of first images, and calculating definition by using a Laplacian function;
the adjusting lens is moved to a position corresponding to the first image with the highest definition.
In one embodiment, the controlling the lens to move from a first distance from the target object to the target object and acquire a plurality of images includes:
controlling the lens to move to an initial position, wherein the initial position is a position which is a first distance away from the target object;
gradually moving the lens towards the target object with a preset first step length, and collecting images when the preset first step length is moved each time.
In one embodiment, the selecting the plurality of first images with gray non-zero value statistical function values greater than the first threshold value includes:
respectively calculating gray non-zero value statistical function values of the plurality of images;
and selecting a plurality of images with gray non-zero value statistical function values larger than a first threshold value as a plurality of first images.
In one embodiment, the denoising the plurality of first images, and calculating the sharpness using a laplace function includes:
carrying out noise reduction processing on the plurality of first images by adopting Gaussian filtering;
and calculating the definition of the plurality of first images after the noise reduction processing by using the Laplace function.
In one embodiment, the adjusting the lens to a position corresponding to the first image with the highest definition includes:
gradually approaching or separating from the target object with a preset second step length, and collecting a second image when each preset second step length is moved;
calculating the definition of the second image by using a Laplace function;
and in response to the highest definition of the second image being greater than the highest definition of the first image, adjusting the lens to move to a position corresponding to the second image with the highest definition.
In one embodiment, the computing the sharpness of the second image using a laplacian function includes:
filtering the second image by Gaussian filtering;
and calculating definition of the filtered second image by using a Laplacian function.
In one embodiment, the adjusting lens moves to a position corresponding to the first image with the highest definition, and then further includes:
responding to the fact that the highest definition of the second image is smaller than that of the first image, adjusting the lens to gradually move to the other side of the position of the first image with the highest definition according to the preset second step length, and collecting a third image when the preset second step length is moved each time;
calculating the definition of a third image subjected to Gaussian filtering by adopting a Laplacian function;
and in response to the highest definition of the third image being greater than the highest definition of the first image, adjusting the lens to move to a position corresponding to the third image with the highest definition.
The invention also provides a focusing device, comprising:
the control module is used for controlling the lens to move from a first distance away from a target object to the target object and collecting a plurality of images;
the selecting module is used for selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value from the plurality of images;
the computing module is used for carrying out noise reduction processing on the plurality of first images and computing definition by adopting a Laplace function;
and the adjusting module is used for adjusting the lens to move to the position corresponding to the first image with the highest definition.
The invention also provides an electronic device comprising a memory and a processor, the memory storing a computer program, the processor implementing a focusing method as described in any of the above when executing the computer program.
The invention also provides a computer readable storage medium storing a computer program which, when executed by a processor, implements a focusing method as described in any one of the above.
According to the focusing method, the focusing device, the electronic equipment and the storage medium, the lens is controlled to move towards the target object, the images are collected, the first images with gray non-zero value statistics function values larger than the first threshold value are selected, the Laplacian function is adopted to calculate the definition after noise reduction treatment, the lens is moved to the position corresponding to the first image with the highest definition, and the position is the ideal focusing position.
Drawings
In order to more clearly illustrate the invention or the technical solutions of the prior art, a brief description will be given below of the drawings used in the embodiments or the description of the prior art, it being obvious that the drawings in the following description are some embodiments of the invention and that other drawings can be obtained from them without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a focusing method according to an embodiment of the present invention;
FIG. 2 is a flow chart of a focusing method according to another embodiment of the present invention;
FIG. 3 is a flow chart of a focusing method according to yet another embodiment of the present invention;
FIG. 4 is a graph of gray scale non-zero value statistical function of an image according to an embodiment of the present invention;
FIG. 5 is one of the images with highest gray non-zero value statistical function values according to an embodiment of the present invention;
FIG. 6 is a second image with highest gray non-zero value statistics function value according to an embodiment of the present invention;
FIG. 7 is a graph of sampled image versus sharpness for an embodiment of the present invention;
FIG. 8 is a graph showing the relationship between an image and Laplace function sharpness evaluation values according to an embodiment of the present invention;
FIG. 9 is a schematic view of a focusing apparatus according to an embodiment of the present invention;
fig. 10 is an internal structural view of a computer device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In recent years, with rapid development of instrument automation and intelligence, automatic film reading technology has become an important field. The technology automatically scans and shoots the cell images through a computer-controlled microscope, and analyzes and identifies abnormal cells by using a machine learning algorithm, thereby assisting doctors in diagnosis. The automatic film reading technology obviously reduces the workload of doctors and improves the accuracy of diagnosis.
In automated film reading technology, the focusing process of the microscope is a critical step. There are two main focusing methods at present: active focusing and passive focusing. The active focusing method realizes automatic focusing by measuring the distance between the lens and the shot object and moving the lens to the focus position. And the passive focusing method compares the change trend of the image definition at different positions according to the feedback of the image signal, thereby automatically adjusting the focus position. Due to the continuous progress of image processing technology, passive focusing technology is widely used in automatic microscopes.
Two important factors affecting the microscope focusing algorithm are the sharpness evaluation function and the focus position search method. The definition evaluation function is used for measuring the definition of the image, and general evaluation functions comprise an absolute variance function, a sum operator of gray level difference absolute values, a Laplacian operator, an energy spectrum method and the like. The focus position searching method mainly comprises a mountain climbing searching method and a global searching method. The hill climbing method is used for searching the optimal focus position by comparing the changes of the image definition in continuous movement, and the global searching rule is used for searching gradually in a certain focusing range to find the focus position with the maximum image definition.
However, in the case of processing high resolution pictures and acquiring a large number of pictures, the conventional algorithm has some drawbacks. First, active focusing methods typically rely on complex ranging techniques, which are costly and difficult to implement. And secondly, the calculated amount of the evaluation function is large, particularly when a high-resolution camera is used, the focusing speed is low, and the practical application requirement cannot be met.
Based on the technical problems, a focusing method, a focusing device, electronic equipment and a storage medium are provided.
The focusing method, apparatus, electronic device, and storage medium of the present invention are described below with reference to fig. 1 to 10.
As shown in fig. 1, in one embodiment, a focusing method includes the steps of:
in step S110, the lens is controlled to move from a first distance from the target object to the target object and collect a plurality of images.
Specifically, the lens is controlled to move to an initial position, wherein the initial position is a position at a first distance from the target object; gradually moving the lens towards the target object with a preset first step length, and collecting images when the preset first step length is moved each time.
Step S120, selecting a plurality of first images with gray non-zero value statistical function values greater than a first threshold value from the plurality of images.
Specifically, respectively calculating gray non-zero value statistical function values of a plurality of images; and selecting a plurality of images with gray non-zero value statistical function values larger than a first threshold value as a plurality of first images.
The gray value of each pixel point in a photo is between 0 and 255, and the gray histogram of the photo is calculated first. Due to the bright field operation of the microscope, the gray level histogram of contrast blurred and sharp images can be concluded: the gray values of the blurred picture are mainly distributed between 150 and 220, and the number of pixels of other gray values is zero, which indicates that the gray values of cells in the image are very close to the background, the gray values of the clear picture are mainly distributed between 50 and 220, and the number of pixels of other gray values is zero, and because the sample blocks light, the color of the place with the sample is darker, and the gray value of the place with the darker color in the displayed image is lower.
A gray value in which the number of pixels appearing in the gray histogram is not zero is referred to as a gray non-zero value. The change from the blurred image to the corresponding gray histogram value zero value of the sharp image can intuitively see that the gray non-zero value is more than the gray non-zero value of the blurred image in the sharp image. This variation can be used as a criterion for evaluating focus sharpness, i.e., a gray scale non-zero value statistical function, whose formula is:
in the formula, H (i) represents the number of pixels with a gray value of i, and sgn (x) is a step function.
Step S130, performing noise reduction processing on the plurality of first images, and calculating sharpness by using a laplace function.
Specifically, gaussian filtering is adopted to perform noise reduction treatment on a plurality of first images; and calculating the definition of the plurality of first images after the noise reduction processing by using the Laplace function.
The laplace operator (Laplacian Operator) is a commonly used method of image sharpness evaluation that can be used to detect edges and textures in images. The Laplace operator's calculation principle is based on the second derivative of the image, which measures the rate of change of the image by calculating the second spatial derivative of the gray values of the pixels of the image. In the two-dimensional case, the laplace operator can be expressed as:
where f (x, y) represents the gray value of the image,and->Representing the image in x and y, respectivelySecond derivative in direction. For discrete images, the laplacian operator may be implemented by convolution.
Common laplace convolution kernels are as follows:
the laplace operation of the image is to perform convolution operation on the laplace convolution kernel and the image. The laplace operator emphasizes edge and texture information, and the pixel gray values at edge locations vary widely, so that brighter or darker areas may appear in the laplace image. The pixel gradation value of the flat region or the noise region changes little, and appears as a darker region in the laplace image.
In the process of processing an image shot by a camera, the Laplacian is utilized for image definition evaluation, edge detection, image sharpening and the like. For image definition evaluation, the method adopted by the invention is to calculate the variance of the image after Laplacian transformation, and the larger the variance is, the clearer the image is.
Note, however, that the laplacian operator is very sensitive to noise, and therefore requires denoising or enhancement in combination with gaussian filter processing techniques in the application to obtain more accurate image sharpness assessment results.
Gaussian filtering is a common denoising method when processing images, which can effectively smooth the image and remove noise. The Gaussian filter convolves the image by using a Gaussian function to realize the smoothing operation.
When applying gaussian filtering on an image, we are actually convolving the image with a gaussian function. The gaussian function is a bell-shaped curve with the following mathematical expression:
where G (x, y) represents the value of the Gaussian function at point (x, y), and σ is the standard deviation of the Gaussian function.
The standard deviation of the gaussian function determines the smoothness of the filter, and the larger the standard deviation is, the stronger the smoothing effect of the filter is.
In image processing, we convolve the image with a gaussian filter to smooth the image and remove noise. The mathematical expression of the convolution operation is as follows:
where I (x, y) represents the value of the filtered image at point (x, y), I (x+i, y+i) represents the value of the original image at point (x+i, y+j), and G (x, y) represents the value of the gaussian function at point (I, j). The image can be smoothed and noise removed by applying a gaussian function to each pixel of the image.
In step S140, the adjustment lens is moved to a position corresponding to the first image with the highest definition.
The position corresponding to the first image with the highest definition is a relatively ideal position.
According to the focusing method, the lens is controlled to move towards the target object, a plurality of images are collected, a plurality of first images with gray non-zero value statistics function values larger than a first threshold value are selected, the resolution is calculated by using a Laplacian function after noise reduction treatment, the lens is moved to a position corresponding to the first image with the highest resolution, and the position is an ideal focusing position.
As shown in fig. 2, in one embodiment, the adjustment lens is moved to a position corresponding to the first image with the highest definition, and then includes the following steps:
step S210, gradually approaching or separating the target object with a preset second step length, and collecting a second image when the second step length is preset every time the target object moves.
And step S220, calculating the definition of the second image by using a Laplace function.
Specifically, gaussian filtering is adopted to carry out filtering treatment on the second image; and calculating definition of the filtered second image by using a Laplacian function.
In step S230, in response to the highest resolution of the second image being greater than the highest resolution of the first image, the adjustment lens is moved to a position corresponding to the second image with the highest resolution.
As shown in fig. 3, in one embodiment, the adjustment lens is moved to a position corresponding to the first image with the highest definition, and then further includes the following steps:
in step S310, in response to the highest resolution of the second image being smaller than the highest resolution of the first image, the adjusting lens gradually moves to the other side of the position of the first image with the highest resolution according to a preset second step length and acquires a third image when each preset second step length is moved.
In step S320, the sharpness of the third image is calculated by using a laplace function on the third image after the gaussian filtering process.
In step S330, in response to the highest resolution of the third image being greater than the highest resolution of the first image, the adjustment lens is moved to a position corresponding to the third image with the highest resolution.
The present invention will be illustrated by the following specific examples.
(1) First, the microscope objective is moved to an initial position 150 μm above the slide.
(2) The samples were uniformly downsampled (photographed) 20 times in 10 μm steps, and GZV function values corresponding to each image were calculated, see fig. 4, with the abscissa being the sampled image and the ordinate being the GZV function value corresponding to the sampled image.
(3) The two images with the highest GZV function values are found, see fig. 5 and 6, and the corresponding positions z1 and z2 are recorded respectively.
(4) The images captured at the z1, z2 positions are gaussian filtered.
(5) After filtering, the sharpness L1, L2 is calculated using a laplace function, see fig. 7 (the abscissa is the sampled image, and the ordinate is the sharpness corresponding to the sampled image), and moved to a position with higher sharpness, and the sharpness value at this position is recorded as L.
(6) Moving up from this moment position by 5 μm, recording position z3, referring to fig. 8, capturing an image and performing gaussian filtering, calculating sharpness using a laplace function, recording as L3, if L3> =l, performing a hill-climbing algorithm with a step size of 3 μm uniformly moving up to a position of maximum sharpness, stopping at this time position Zmax, that is, a quasi-focus position, if L3< L, performing a hill-climbing algorithm with a step size of 3 μm uniformly moving down to a position of maximum sharpness.
The hill climbing algorithm is a local search algorithm for finding local maxima or minima of a function. The basic principle can be briefly described as follows:
initial solution: a random initial solution, which in the present invention is the value of L, is first selected as the starting point.
Adjacent solution: adjacent solutions are generated in the vicinity of the current solution, which are obtained by making a minute change to the current solution. For example, in a continuous space, small steps may be taken in a certain direction. The proximity solution is a value L3 obtained by photographing and filtering after a motor drives a microscope to move and calculating by using a Laplace function.
Evaluation function: for each adjacent solution, its objective function value in the problem is calculated. The objective function value is a laplace function in the present invention, and a maximum value is found.
And (3) moving decision: the objective function values of the current solution and the adjacent solution are compared, if the value of the adjacent solution is better (larger), the adjacent solution is moved to be used as a new current solution, otherwise, the current solution is kept unchanged.
And (3) convergence judgment: repeating the steps until the termination condition is met. The termination condition is that the neighbor solution becomes smaller, i.e., stops, and returns to the last obtained position.
According to the invention, by using two methods, namely the gray non-zero value statistical function and the Laplace function, the gray non-zero value statistical function can roughly calculate the image edge, and whether the image is clear or not is calculated, but the peak change of the definition curve is not sharp, and impurities and samples are difficult to distinguish, for example, impurities possibly exist on the surface of a glass slide in the focusing process, and the impurities possibly influence the accuracy of a hill climbing algorithm, so that focusing failure or focusing position errors are caused. Therefore, in the improvement of the focusing algorithm, it is necessary to consider how to treat the foreign matters on the surface of the slide to ensure the stability and accuracy of the focusing process. The Laplace function has a sharp peak shape at the near focus position, and the difference between the Laplace function and the Laplace function can be distinguished obviously. In addition, the gray scale non-zero value statistical function can distinguish which layer of the acquired multi-layer image is sharp, while the laplace function has a sharp peak shape at the near focus position. The time complexity of both functions is low. On the basis, a new focus searching method is provided. The method utilizes the advantages of the two proposed evaluation functions, and on the basis, the focal depth is searched while rough traversing is performed by utilizing the advantages of the two proposed evaluation functions, so that the influence caused by image acquisition is avoided. The focal position is finely searched for using a laplace function in combination with a small step size of gaussian filtering at the near focal position.
The focusing device provided by the invention is described below, and the focusing device described below and the focusing method described above can be referred to correspondingly.
As shown in fig. 9, in one embodiment, a focusing apparatus, the apparatus includes:
a control module 910, configured to control the lens to move from a first distance from a target object to the target object and collect a plurality of images;
a selecting module 920, configured to select a plurality of first images with gray non-zero value statistical function values greater than a first threshold value from the plurality of images;
a calculating module 930, configured to perform noise reduction processing on the plurality of first images, and calculate sharpness by using a laplace function;
the adjusting module 940 is configured to adjust the lens to a position corresponding to the first image with the highest definition.
Fig. 10 illustrates a physical structure diagram of an electronic device, which may be an intelligent terminal, and an internal structure diagram thereof may be as shown in fig. 10. The electronic device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic device includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the electronic device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a focusing method, the method comprising:
controlling a lens to move from a first distance away from a target object to the target object and collecting a plurality of images;
selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value from the plurality of images;
carrying out noise reduction treatment on the plurality of first images, and calculating definition by using a Laplacian function;
the adjusting lens is moved to a position corresponding to the first image with the highest definition.
It will be appreciated by those skilled in the art that the structure shown in fig. 10 is merely a block diagram of a portion of the structure associated with the present inventive arrangements and is not limiting of the electronic device to which the present inventive arrangements are applied, and that a particular electronic device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In another aspect, the present invention also provides a computer storage medium storing a computer program which when executed by a processor implements a focusing method, the method comprising:
controlling a lens to move from a first distance away from a target object to the target object and collecting a plurality of images;
selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value from the plurality of images;
carrying out noise reduction treatment on the plurality of first images, and calculating definition by using a Laplacian function;
the adjusting lens is moved to a position corresponding to the first image with the highest definition.
In yet another aspect, a computer program product or computer program is provided, the computer program product or computer program comprising computer instructions stored in a computer readable storage medium. A processor of an electronic device reads the computer instructions from a computer readable storage medium, the processor executing the computer instructions to implement a focusing method, the method comprising:
controlling a lens to move from a first distance away from a target object to the target object and collecting a plurality of images;
selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value from the plurality of images;
carrying out noise reduction treatment on the plurality of first images, and calculating definition by using a Laplacian function;
the adjusting lens is moved to a position corresponding to the first image with the highest definition.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory.
By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the invention and are described in detail herein without thereby limiting the scope of the invention. It should be noted that it will be apparent to those skilled in the art that various modifications and improvements can be made without departing from the spirit of the invention, which are within the scope of the invention. Accordingly, the scope of protection of the present invention is to be determined by the appended claims.

Claims (10)

1. A focusing method, the method comprising:
controlling a lens to move from a first distance away from a target object to the target object and collecting a plurality of images;
selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value from the plurality of images;
carrying out noise reduction treatment on the plurality of first images, and calculating definition by using a Laplacian function;
the adjusting lens is moved to a position corresponding to the first image with the highest definition.
2. The focusing method of claim 1, wherein the controlling the lens to move from a first distance from the target object to the target object and acquire a plurality of images comprises:
controlling the lens to move to an initial position, wherein the initial position is a position which is a first distance away from the target object;
gradually moving the lens towards the target object with a preset first step length, and collecting images when the preset first step length is moved each time.
3. The method of focusing according to claim 1, wherein said selecting a plurality of first images having gray non-zero value statistical function values greater than a first threshold value among said plurality of images comprises:
respectively calculating gray non-zero value statistical function values of the plurality of images;
and selecting a plurality of images with gray non-zero value statistical function values larger than a first threshold value as a plurality of first images.
4. The focusing method according to claim 1, wherein the noise reduction processing is performed on the plurality of first images and the sharpness is calculated using a laplace function, comprising:
carrying out noise reduction processing on the plurality of first images by adopting Gaussian filtering;
and calculating the definition of the plurality of first images after the noise reduction processing by using the Laplace function.
5. The focusing method according to any one of claims 1 to 4, wherein the adjusting lens is moved to a position corresponding to the first image of the highest definition, and then comprises:
gradually approaching or separating from the target object with a preset second step length, and collecting a second image when each preset second step length is moved;
calculating the definition of the second image by using a Laplace function;
and in response to the highest definition of the second image being greater than the highest definition of the first image, adjusting the lens to move to a position corresponding to the second image with the highest definition.
6. The method of focusing according to claim 5, wherein said calculating the sharpness of the second image using a laplace function comprises:
filtering the second image by Gaussian filtering;
and calculating definition of the filtered second image by using a Laplacian function.
7. The focusing method of claim 6, wherein the adjusting lens is moved to a position corresponding to the first image with the highest definition, and further comprising:
responding to the fact that the highest definition of the second image is smaller than that of the first image, adjusting the lens to gradually move to the other side of the position of the first image with the highest definition according to the preset second step length, and collecting a third image when the preset second step length is moved each time;
calculating the definition of a third image subjected to Gaussian filtering by adopting a Laplacian function;
and in response to the highest definition of the third image being greater than the highest definition of the first image, adjusting the lens to move to a position corresponding to the third image with the highest definition.
8. A focusing apparatus, the apparatus comprising:
the control module is used for controlling the lens to move from a first distance away from a target object to the target object and collecting a plurality of images;
the selecting module is used for selecting a plurality of first images with gray non-zero value statistical function values larger than a first threshold value from the plurality of images;
the computing module is used for carrying out noise reduction processing on the plurality of first images and computing definition by adopting a Laplace function;
and the adjusting module is used for adjusting the lens to move to the position corresponding to the first image with the highest definition.
9. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 7 when the computer program is executed.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method of any one of claims 1 to 7.
CN202311261612.1A 2023-09-27 2023-09-27 Focusing method, focusing device, electronic equipment and storage medium Pending CN117452617A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311261612.1A CN117452617A (en) 2023-09-27 2023-09-27 Focusing method, focusing device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311261612.1A CN117452617A (en) 2023-09-27 2023-09-27 Focusing method, focusing device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117452617A true CN117452617A (en) 2024-01-26

Family

ID=89586389

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311261612.1A Pending CN117452617A (en) 2023-09-27 2023-09-27 Focusing method, focusing device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117452617A (en)

Similar Documents

Publication Publication Date Title
CN106934803B (en) method and device for detecting surface defects of electronic device
CN101416219B (en) Foreground/background segmentation in digital images
Pertuz et al. Generation of all-in-focus images by noise-robust selective fusion of limited depth-of-field images
US8073286B2 (en) Detection and correction of flash artifacts from airborne particulates
CN109632808B (en) Edge defect detection method and device, electronic equipment and storage medium
WO2017100971A1 (en) Deblurring method and device for out-of-focus blurred image
CN111083365B (en) Method and device for rapidly detecting optimal focal plane position
CN111626933A (en) Accurate and rapid microscopic image splicing method and system
KR102582261B1 (en) Method for determining a point spread function of an imaging system
Koik et al. A literature survey on blur detection algorithms for digital imaging
KR20110079654A (en) Methods and apparatus for editing images
US20120249770A1 (en) Method for automatically focusing a microscope on a predetermined object and microscope for automatic focusing
CN111679418B (en) Microscope automatic focusing method and system based on laser image and computer equipment
CN107170002B (en) Automatic image focusing method and device
CN110084818B (en) Dynamic down-sampling image segmentation method
CN113538545B (en) Monocular depth estimation method based on electro-hydraulic adjustable-focus lens and corresponding camera and storage medium
CN105574823A (en) Deblurring method and device for out-of-focus blurred image
CN110992408B (en) Digital section processing method and system based on pathological microscope
CN111968143A (en) Edge image extraction method and system based on correlated imaging
CN116823788A (en) Laser field lens dirt detection method, detection system and dirt recognition device
CN117452617A (en) Focusing method, focusing device, electronic equipment and storage medium
JP3860540B2 (en) Entropy filter and region extraction method using the filter
CN112634298B (en) Image processing method and device, storage medium and terminal
Chabardes et al. Local blur estimation based on toggle mapping
CN115578291A (en) Image brightness correction method, storage medium and electronic device

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