Focusing method and device, image acquisition equipment and storage medium
By performing preliminary focus and field of view position determination on the lens of the image acquisition device, combined with the method of gradual movement and image acquisition, the problem of low efficiency of traditional focusing methods is solved, and efficient and accurate focusing effect is achieved.
Patent Information
- Application Number
- CN202311706059.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-11
- Publication Date
- 2025-06-13
AI Technical Summary
Traditional focusing methods are inefficient and it is difficult to ensure high focusing efficiency while meeting a certain focus accuracy.
The initial focus is achieved by moving the lens of the image acquisition device, and then the initial focus plane is moved on the initial focus plane to change the field of view position and determine the target field of view position. Next, the lens is gradually moved in a preset range around the initial focus plane according to the preset step size, and image acquisition is performed after each movement, and the target focus plane is determined based on the image clarity data.
This method can efficiently determine the target focus plane, improve focus efficiency, and by gradually moving the lens and image acquisition, it can search the focus plane in a refined manner, thereby improving the accuracy of focus.
Smart Images

Figure CN120151649A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of imaging technologies, and particularly to a focusing method, apparatus, image acquisition device, and storage medium. Background Art
[0002] Automatic focusing technology plays a crucial role in high-precision optical systems, such as microscopes, industrial vision systems, and remote sensing systems. Automatic focusing adjusts the distance between the lens and the object to be measured by moving the lens, thereby achieving clear imaging of the object to be measured. Traditional focusing methods are often very inefficient and it is difficult to ensure a high focusing efficiency while meeting a certain focusing accuracy. Therefore, improving the efficiency of automatic focusing has become a very important issue. Summary of the Invention
[0003] Based on this, in view of the above technical problems, it is necessary to provide a focusing method, apparatus, image acquisition device, computer-readable storage medium, and computer program product that can improve the focusing efficiency.
[0004] In a first aspect, the present application provides a focusing method. The method includes:
[0005] Moving the lens of the image acquisition device for preliminary focusing to obtain an initial focusing plane of the lens;
[0006] Moving the lens on the initial focusing plane to change the field of view position to determine a target field of view position;
[0007] Fixing the field of view of the lens at the target field of view position, gradually moving the lens step by step within a first preset range around the initial focusing plane according to a first preset step size, and performing image acquisition after each movement to obtain a plurality of first images;
[0008] Determining a target focusing plane according to the sharpness data of each of the first images.
[0009] In one embodiment, the determining a target focusing plane according to the sharpness data of each of the first images includes:
[0010] Determining a quasi-focusing plane according to the sharpness data of each of the first images;
[0011] In a case where the quasi-focusing plane does not meet the focusing accuracy, gradually moving the lens step by step within a second preset range around the quasi-focusing plane according to a second preset step size, and performing image acquisition after each movement to obtain a plurality of second images; the second preset range is smaller than the first preset range; the second preset step size is smaller than the first preset step size;
[0012] Determine a target focus plane according to the sharpness data of each of the second images.
[0013] In one embodiment, moving the lens on the initial focus plane to change the field of view position to determine the target field of view position includes:
[0014] Gradually move the lens within a preset area range on the initial focus plane to change the field of view position, and perform image acquisition after each movement to obtain multiple third images under different fields of view;
[0015] Determine the target field of view position according to the sharpness data of each of the third images.
[0016] In one embodiment, the sharpness data is a sharpness score; before determining the target focus plane according to the sharpness data of each of the first images, the method further includes:
[0017] For each first image, select multiple first regions that meet the first preset size from the first image;
[0018] Determine the variance of the pixel values of each pixel point in each of the first regions respectively;
[0019] Determine the sharpness score of the first image according to the variances of the first regions in the first image.
[0020] In one embodiment, the method further includes:
[0021] Determine the first mean of the pixel values of each pixel point in the first image and the second mean of the pixel values of each pixel point in each of the first regions in the first image;
[0022] Determine the weights corresponding to each of the first regions respectively according to the differences between the second means and the first mean;
[0023] The determining the sharpness score of the first image according to the variances of the first regions in the first image includes:
[0024] Weight the variances of the first regions according to the weights corresponding to each of the first regions, and determine the sharpness score of the first image according to the weighted result.
[0025] In one embodiment, the determining the weights corresponding to each of the first regions respectively according to the differences between the second means and the first mean includes:
[0026] Determine the differences between the second means and the first mean respectively;
[0027] Determine the ratio between the difference corresponding to each of the first regions and the first mean value respectively;
[0028] If the ratio corresponding to the first region is greater than or equal to a preset threshold, determine the first preset weight as the weight corresponding to the first region;
[0029] If the ratio corresponding to the first region is less than the preset threshold, determine the second preset weight as the weight corresponding to the first region;
[0030] Wherein, the first preset weight is less than the second preset weight.
[0031] In a second aspect, the present application further provides a focusing device. The device includes:
[0032] A preliminary focusing module, configured to move the lens of the image acquisition device for preliminary focusing to obtain an initial focusing plane of the lens;
[0033] A target field of view determination module, configured to move the lens on the initial focusing plane to change the field of view position so as to determine the target field of view position;
[0034] An advanced focusing module, configured to fix the field of view of the lens at the target field of view position, gradually move the lens within a first preset range around the initial focusing plane according to a first preset step size, and perform image acquisition after each movement to obtain a plurality of first images; determine the target focusing plane according to the sharpness data of each of the first images.
[0035] In a third aspect, the present application further provides an image acquisition device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0036] Move the lens of the image acquisition device for preliminary focusing to obtain an initial focusing plane of the lens;
[0037] Move the lens on the initial focusing plane to change the field of view position so as to determine the target field of view position;
[0038] Fix the field of view of the lens at the target field of view position, gradually move the lens within a first preset range around the initial focusing plane according to a first preset step size, and perform image acquisition after each movement to obtain a plurality of first images;
[0039] Determine the target focusing plane according to the sharpness data of each of the first images.
[0040] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0041] Move the lens of the image acquisition device for initial focusing to obtain the initial focus plane of the lens;
[0042] Move the lens on the initial focus plane to change the field of view position to determine the target field of view position;
[0043] Fix the field of view of the lens at the target field of view position, gradually move the lens within a first preset range around the initial focus plane according to a first preset step size, and perform image acquisition after each movement to obtain multiple first images;
[0044] Determine the target focus plane according to the sharpness data of each of the first images.
[0045] In a fifth aspect, the present application also provides a computer program product, including a computer program, which when executed by a processor implements the following steps:
[0046] Move the lens of the image acquisition device for initial focusing to obtain the initial focus plane of the lens;
[0047] Move the lens on the initial focus plane to change the field of view position to determine the target field of view position;
[0048] Fix the field of view of the lens at the target field of view position, gradually move the lens within a first preset range around the initial focus plane according to a first preset step size, and perform image acquisition after each movement to obtain multiple first images;
[0049] Determine the target focus plane according to the sharpness data of each of the first images.
[0050] The above focus method, device, image acquisition device, storage medium, and computer program product first move the lens of the image acquisition device for initial focusing to obtain the initial focus plane of the lens, then move the lens on the initial focus plane to change the field of view position to determine the target field of view position, which can lock the search range of the focus plane within a certain range. Then, fix the field of view of the lens at the target field of view position, gradually move the lens within a first preset range around the initial focus plane according to a first preset step size, and perform image acquisition after each movement to obtain multiple first images. Finally, determine the target focus plane according to the sharpness data of each of the first images, which can efficiently determine the target focus plane and improve the focus efficiency. Description of the Drawings
[0051] Figure 1 It is an application environment diagram of the focus method in an embodiment;
[0052] Figure 2Schematic flowchart of the focusing method in an embodiment;
[0053] Figure 3 Schematic overall flowchart of the focusing method in an embodiment;
[0054] Figure 4 Schematic diagram of the imaging effect after focusing in an embodiment;
[0055] Figures 5 to 8 Curves showing the variation of sharpness scores corresponding to images captured at the same location by different image acquisition devices under their respective lighting conditions;
[0056] Figure 9 Block diagram of the focusing device in an embodiment;
[0057] Figure 10 Block diagram of the focusing device in another embodiment;
[0058] Figure 11 Internal structure diagram of the image acquisition device in an embodiment. Detailed implementation manners
[0059] In order to make the objectives, technical solutions, and advantages of the present application clearer and more understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0060] The focusing method provided in the embodiments of the present application can be applied to an application environment as shown in Figure 1 . The image acquisition device 102 can move the lens 1022 for preliminary focusing to obtain the initial focusing plane of the lens 1022, and then move the lens 1022 on the initial focusing plane to change the field of view position to determine the target field of view position. Fix the field of view of the lens 1022 at the target field of view position, and gradually move the lens 1022 step by step within a first preset range around the initial focusing plane according to a first preset step size, and perform image acquisition after each movement to obtain multiple first images. Determine the target focusing plane according to the sharpness data of each first image. Among them, the image acquisition device 102 can be various devices with image acquisition functions. The image acquisition device 102 can be, but is not limited to, a camera, a microscope, a sequencer, or an industrial defect detection device, etc.
[0061] In some embodiments, as shown in Figure 2 , a focusing method is provided. Taking the method applied to the image acquisition device 102 in Figure 1 as an example, the method includes the following steps:
[0062] Step 202, move the lens of the image acquisition device for preliminary focusing to obtain the initial focusing plane of the lens.
[0063] Among them, the initial focus plane is the plane where the lens is located after preliminary focusing.
[0064] In some embodiments, the image acquisition device can perform preliminary focusing by moving the lens of the image acquisition device through an auto focus (AF) hardware unit, and obtain the initial focus plane of the lens. That is, the preliminary focusing is automatically completed through the auto focus hardware unit.
[0065] In some embodiments, the image acquisition device can turn on the auto focus hardware unit, obtain the numerical feedback (AFSum) of the auto focus hardware unit, and then execute the program flow of the auto focus hardware unit to perform preliminary focusing, so as to obtain the initial focus plane of the lens.
[0066] In other embodiments, the image acquisition device can respond to an input manual focusing instruction, move the lens to the position indicated by the manual focusing instruction, and obtain the initial focus plane of the lens. Among them, the manual focusing instruction is an instruction for manually controlling the image acquisition device to perform preliminary focusing. When there is no auto focus hardware unit in the image acquisition device or the auto focus hardware unit is not applicable by pre-setting, preliminary manual focusing can be performed.
[0067] In some embodiments, after the preliminary focusing is completed, the image acquisition device can obtain the coordinate position of the initial focus plane of the lens. For example: assuming that the coordinate axis perpendicular to the lens is the z-axis, the corresponding z coordinate value z of the initial focus plane on the z-axis can be obtained after the preliminary focusing is completed. 0 。
[0068] Step 204, move the lens on the initial focus plane to change the field of view position to determine the target field of view position.
[0069] Among them, the field of view (FOV) is the area of the acquisition object that the image acquisition device can capture. The field of view position is the position where the area of the acquisition object that the image acquisition device can capture is located. The acquisition object is the object targeted by the image acquisition device for image acquisition.
[0070] In some embodiments, the image acquisition device can move the lens within a preset range on the initial focus plane to change the field of view position to determine the target field of view position. That is, the lens is fixed on the initial focus plane and moved on the initial focus plane. For example: assuming that the coordinate axis perpendicular to the lens is the z-axis, in this embodiment, the z coordinate value corresponding to the lens on the z-axis can be maintained, and the x coordinate value and y coordinate value of the lens can be changed to change the field of view position.
[0071] In some embodiments, the preset range may be the entire range corresponding to the acquisition object. In other embodiments, the preset range may be a partial range of the acquisition object. For example, the preset range may be the range corresponding to the central region of the acquisition object.
[0072] Step 206, fix the field of view of the lens at the target field of view position, gradually move the lens within a first preset range around the initial focus plane according to a first preset step size, and perform image acquisition after each movement to obtain multiple first images.
[0073] In some embodiments, the first preset range and the first preset step size can be set according to the actual device situation. For example, for a gene sequencer, the first preset range may be within 20 microns around the initial focus plane, and the first preset step size may be 2 microns.
[0074] For example, assume that the coordinate axis perpendicular to the lens is the z-axis, and the z-coordinate value corresponding to the initial focus plane is z 0 , the first preset range may be within 20 microns around the initial focus plane, and the first preset step size may be 2 microns. Then, the x-coordinate value and y-coordinate value of the lens can be fixed to the x-coordinate value and y-coordinate value corresponding to the target field of view position, and the z-coordinate value of the lens is changed. The z-coordinate value of the lens is changed in steps of 2 microns within the range of z 0 ±20 microns.
[0075] In some embodiments, the image acquisition device may perform image acquisition on the acquisition object after each movement within the first preset range around the initial focus plane to obtain multiple first images.
[0076] Step 208, determine the target focus plane according to the clarity data of each first image.
[0077] Among them, the clarity data is the data used to reflect the clarity of the image. The target focus plane is the plane where the lens should be in the case of clear imaging after focusing is completed. When the lens is in the target focus plane, the acquisition object can be on the focal plane of the lens, so as to achieve clear imaging of the acquisition object.
[0078] In some embodiments, the image acquisition device may determine the target first image from each first image according to the clarity data of each first image, and then determine the plane where the lens is when the target first image is acquired as the target focus plane. In some embodiments, after determining the target focus plane, the image acquisition device may move the lens to the target focus plane to complete the focusing.
[0079] In some embodiments, the image acquisition device may determine the first image with the highest clarity as the target first image according to the clarity data of each first image.
[0080] In some embodiments, the image acquisition device may determine the z - coordinate value of the lens when capturing the first image of the acquisition target as the z - coordinate value of the target focus plane. The image acquisition device may move the lens to the position corresponding to the z - coordinate value of the target focus plane to complete focusing.
[0081] In some embodiments, the sharpness data may be the sharpness score of the image. The image acquisition device may determine the sharpness score of the image according to the pixel values of each pixel point in the image. The image acquisition device may determine the first image with the highest sharpness score as the target first image.
[0082] In some embodiments, the image acquisition device may determine the edge points in the image, and then determine the sharpness score of the image according to the clarity of the edge points. In other embodiments, the image acquisition device may select multiple regions that meet a preset size from the image, and determine the sharpness score of the image according to the variance of the pixel values of the pixel points in each region.
[0083] In some embodiments, the focus plane determined according to the sharpness data of each first image is the quasi - focus plane. When the quasi - focus plane meets the focusing accuracy, the quasi - focus plane is used as the target focus plane. In some embodiments, when the quasi - focus plane does not meet the focusing accuracy, the target focus plane is searched within a second preset range around the quasi - focus plane. The second preset range is smaller than the first preset range.
[0084] In some embodiments, after the focus plane determined according to the sharpness data of each first image is the quasi - focus plane, when the moving accuracy of the lens of the image acquisition device along the z - axis (i.e., the minimum step size supported by the lens) cannot support moving step by step within the second preset range according to the second preset step size, or when the change range of the sharpness score of the image captured after the lens moves is less than or equal to a preset transformation threshold, the focusing accuracy is met, and the quasi - focus plane is used as the target focus plane.
[0085] In the above - mentioned focusing method, first, the lens of the image acquisition device is moved for preliminary focusing to obtain the initial focus plane of the lens. Then, the lens is moved on the initial focus plane to change the field - of - view position to determine the target field - of - view position, which can lock the search range of the focus plane within a certain range. Then, the field of view of the lens is fixed at the target field - of - view position, and the lens is gradually moved within the first preset range around the initial focus plane according to the first preset step size, and images are captured each time after the movement to obtain multiple first images. Finally, according to the sharpness data of each first image, the target focus plane is determined, which can efficiently determine the target focus plane and improve the focusing efficiency.
[0086] In some embodiments, determining a target focus plane based on the sharpness data of each first image includes: determining a quasi-focus plane based on the sharpness data of each first image; in the case where the quasi-focus plane does not meet the focusing accuracy, gradually moving the lens within a second preset range around the quasi-focus plane in a second preset step, and performing image acquisition after each movement to obtain multiple second images; the second preset range is smaller than the first preset range; the second preset step is smaller than the first preset step; determining the target focus plane based on the sharpness data of each second image.
[0087] In some embodiments, the second preset range is smaller than the first preset range; the second preset step is smaller than the first preset step. For example, for a gene sequencer, it is assumed that the first preset range can be within 20 microns around the initial focus plane, the first preset step can be 2 microns, the second preset range can be within 2 microns around the quasi-focus plane, and the second preset step can be 0.5 microns.
[0088] For example, it is assumed that the coordinate axis perpendicular to the lens is the z-axis, and the z coordinate value corresponding to the quasi-focus plane is z 1 , the second preset range can be within 2 microns around the initial focus plane, the second preset step can be 0.5 microns, then the x coordinate value and y coordinate value of the lens can be fixed to the x coordinate value and y coordinate value corresponding to the target field of view position, change the z coordinate value of the lens, and change the z coordinate value of the lens in steps of 0.5 microns within the range of z 1 ±2 microns.
[0089] In some embodiments, the image acquisition device can perform image acquisition on the acquisition object after each movement within the second preset range around the quasi-focus plane to obtain multiple second images.
[0090] In some embodiments, the image acquisition device can determine a target second image from each second image according to the sharpness data of each second image, and then determine the plane where the lens is located when the target second image is acquired as the target focus plane.
[0091] In some embodiments, the image acquisition device can determine the second image with the highest sharpness as the target second image according to the sharpness data of each second image.
[0092] In some embodiments, the sharpness data can be a sharpness score. The image acquisition device can determine the second image with the highest sharpness score as the target second image.
[0093] In some embodiments, the method for determining the sharpness score of the second image can adopt the method for determining the sharpness score in each embodiment of the present application to further improve the focusing accuracy.
[0094] Such asFigure 3 As shown, it is a schematic diagram of the overall process of the focusing method in the above embodiments, including the following steps:
[0095] Step 302, move the lens of the image acquisition device for preliminary focusing to obtain the initial focusing plane of the lens.
[0096] Step 304, move the lens on the initial focusing plane to change the field of view position to determine the target field of view position.
[0097] Step 306, fix the field of view of the lens at the target field of view position, gradually move the lens in the first preset range around the initial focusing plane according to the first preset step size, and perform image acquisition after each movement to obtain multiple first images. Determine the quasi-focusing plane according to the clarity data of each first image.
[0098] Step 308, gradually move the lens in the second preset range around the quasi-focusing plane according to the second preset step size, and perform image acquisition after each movement to obtain multiple second images. Determine the target focusing plane according to the clarity data of each second image.
[0099] As Figure 4 shown, (a) is a tissue cell image collected without focusing, (b) is a cell tissue image collected when the lens is below the quasi-focusing plane, and (c) is a cell tissue image collected when the lens is below the target focusing plane. It can be seen that the cell tissue image collected after rough focusing to obtain the quasi-focusing plane is clearer than the image collected before focusing, and then the cell tissue image collected after fine focusing to obtain the target focusing plane is clearer than the cell tissue image collected under the quasi-focusing plane, and more details and fine characteristic structures can be recognized.
[0100] In the above embodiments, when the quasi-focusing plane does not meet the focusing accuracy, gradually move the lens in the second preset range around the quasi-focusing plane according to the second preset step size, and perform image acquisition after each movement to obtain multiple second images, so as to be able to search for the focusing plane more precisely. Then, determine the target focusing plane according to the clarity data of each second image, so as to be able to obtain a more accurate target focusing plane, improve the accuracy of focusing, and also improve the focusing efficiency because the search range is small.
[0101] In some embodiments, moving the lens on the initial focusing plane to change the field of view position to determine the target field of view position includes: gradually moving the lens within the preset area range on the initial focusing plane to change the field of view position, and performing image acquisition after each movement to obtain multiple third images under different fields of view; determining the target field of view position according to the clarity data of each third image.
[0102] In some embodiments, the image acquisition device may determine a target third image from each third image according to the clarity data of each third image, and then determine the visual field position where the lens is located when the target third image is acquired as the target visual field position.
[0103] In some embodiments, the image acquisition device may determine the third image with the highest clarity as the target third image according to the clarity data of each third image.
[0104] In some embodiments, the clarity data may be a clarity score. The image acquisition device may determine the third image with the highest clarity score as the target third image.
[0105] In some embodiments, the method for determining the clarity score of the third image may adopt the method for determining the clarity score in each embodiment of the present application to improve the accuracy of determining the target visual field position.
[0106] In the above embodiments, within the preset area range on the initial focus plane, the lens is gradually moved to change the visual field position, and image acquisition is performed after each movement to obtain multiple third images under different visual fields. According to the clarity data of each third image, the target visual field position is determined, so that the target visual field position can be determined efficiently.
[0107] In some embodiments, the clarity data is a clarity score. Before determining the target focus plane according to the clarity data of each first image, the method further includes: for each first image, selecting multiple first regions that meet the first preset size from the first image; respectively determining the variance of the pixel values of each pixel point in each first region; and determining the clarity score of the first image according to the variances of the first regions in the first image.
[0108] The first preset size is the size that needs to be satisfied set in advance for the selected first region.
[0109] In some embodiments, the first regions selected from the first image may overlap or not overlap. The accuracy of the clarity score obtained when the first regions overlap is higher.
[0110] In some embodiments, the first preset size may support adjustment by the user according to actual needs. Different first preset sizes have differences in the sensitivity and calculation amount of the clarity score.
[0111] In some embodiments, the image acquisition device may determine the clarity score of the first image according to the mean value of the variances of the first regions in the first image.
[0112] In some embodiments, the mean value may be any one of the arithmetic mean, weighted mean, etc.
[0113] In some embodiments, when the mean value is a weighted average value, the image acquisition device may weight the variances of the first regions according to the weights corresponding to the first regions respectively, and determine the sharpness score of the first image according to the weighted result.
[0114] In the above embodiments, multiple first regions are selected from the first image, and the sharpness score of the first image is determined according to the variances of the respective first regions, which can take into account the variances of the respective first regions, improve the accuracy of the sharpness score, and thus improve the accuracy of focusing. In addition, the calculation amount for determining the image sharpness score by calculating the variance is relatively low.
[0115] In some embodiments, the method further includes: determining a first mean value of the pixel values of each pixel point in the first image, and a second mean value of the pixel values of each pixel point in each first region in the first image; respectively determining the weights corresponding to the first regions according to the differences between the second mean values and the first mean value; determining the sharpness score of the first image according to the variances of the first regions in the first image, including: weighting the variances of the first regions according to the weights corresponding to the first regions respectively, and determining the sharpness score of the first image according to the weighted result.
[0116] Wherein, the first mean value refers to the mean value of the pixel values of each pixel point in the first image. The second mean value refers to the mean value of the pixel values of each pixel point in the first region.
[0117] In some embodiments, the weight corresponding to the first region is negatively correlated with the difference corresponding to the first region, that is, the larger the difference, the smaller the weight; the smaller the difference, the larger the weight.
[0118] In some embodiments, the image acquisition device may determine whether a preset condition is satisfied according to the difference corresponding to the first region. If the preset condition is not satisfied, the first preset weight is determined as the weight corresponding to the first region; if the preset condition is satisfied, the second preset weight is determined as the weight corresponding to the first region. Wherein, the first preset weight is less than the second preset weight.
[0119] In some embodiments, the preset condition may be that the difference corresponding to the first region is less than a preset difference threshold. That is, if the difference corresponding to the first region is greater than or equal to the preset difference threshold, the first preset weight is determined as the weight corresponding to the first region; if the difference corresponding to the first region is less than the preset difference threshold, the second preset weight is determined as the weight corresponding to the first region.
[0120] In some other embodiments, the preset condition may be that the ratio between the difference corresponding to the first region and the first mean value is less than a preset threshold. That is, if the ratio corresponding to the first region is greater than or equal to the preset threshold, the first preset weight is determined as the weight corresponding to the first region; if the ratio corresponding to the first region is less than the preset threshold, the second preset weight is determined as the weight corresponding to the first region.
[0121] In some embodiments, the first preset weight may be a value greater than 0 and less than 1, and the second preset weight may be a value greater than the first preset weight and less than or equal to 1. For example: the first preset weight is 0.2 and the second preset weight is 1.
[0122] In some embodiments, the image acquisition device may determine the clarity score of the first image as the mean value of the weighted results of the variances of each first region. That is, the weighted results of the variances of each first region are summed, and then the sum result is divided by the number of first regions to obtain the clarity score of the first image.
[0123] In the above embodiments, the weights corresponding to each first region are determined respectively according to the differences between the second mean values of each first region and the first mean value of the first image, and then the variances of each first region are weighted according to the weights corresponding to each first region respectively, and the clarity score of the first image is determined according to the weighted results, so as to avoid the variance of the first region with a large difference from the overall mean value of the first image having a great impact on the overall clarity score, improve the accuracy of the clarity score, and further improve the accuracy of focusing. In addition, the calculation amount of determining the image clarity score by calculating the variance is relatively low.
[0124] In some embodiments, determining the weights corresponding to each first region respectively according to the differences between each second mean value and the first mean value includes: respectively determining the differences between each second mean value and the first mean value; respectively determining the ratios between the differences corresponding to each first region and the first mean value; if the ratio corresponding to the first region is greater than or equal to the preset threshold, determining the first preset weight as the weight corresponding to the first region; if the ratio corresponding to the first region is less than the preset threshold, determining the second preset weight as the weight corresponding to the first region; wherein, the first preset weight is less than the second preset weight.
[0125] In some embodiments, the preset threshold can be set according to the actual situation. For example: the preset threshold can be taken as 0.2.
[0126] In the above embodiments, if the ratio corresponding to the first region is greater than or equal to the preset threshold, the first preset weight is determined as the weight corresponding to the first region; if the ratio corresponding to the first region is less than the preset threshold, the second preset weight is determined as the weight corresponding to the first region, where the first preset weight is less than the second preset weight. This can avoid the variance of the first region with a large difference from the overall mean of the first image having a great impact on the overall clarity score, improve the accuracy of the clarity score, and thus improve the accuracy of focusing. In addition, calculating the variance to determine the image clarity score has a relatively low computational cost. The curve corresponding to the image clarity score obtained by using the method in this embodiment is unimodal and relatively stable, which can improve the accuracy of focusing.
[0127] Figure 5 , Figure 6 , Figure 7 and Figure 8The clarity evaluation results of several common algorithms for calculating the clarity score of an image and the method for determining the clarity score in the above embodiments of the present application on a set of real images are shown respectively (the output clarity scores have been unified to a similar scale). Among them, Channel A / C / G / T refers to images collected at the same position by different image acquisition devices under their respective lighting conditions. The responses of the acquisition object in different channels may vary, which will be reflected in the image grayscale. Near the abscissa value of 20 is the best focus plane confirmed manually. The direction of decreasing or increasing the abscissa value corresponds to the movement of the lens in different directions (zooming in or out). The ideal output result is that the image clarity score presents a unimodal shape on the curve graph, and the peak position appears near the abscissa value of 20. As can be seen from the figure, common centralized algorithms: Brenner (gray difference between adjacent pixels), Tenengrad (based on the Sobel operator, first-order gradient), Laplacian (based on the Laplacian operator, second-order gradient), SMD (gray variance), SMD2 (product of gray variances), EnergyGradient (energy gradient), EAV (edge sharpness), NRSS (gradient structural similarity), and BlurNoise (secondary blur contrast) all have limitations to varying degrees. Some curves are not sensitive to changes, and some curve results are unstable. ArcLaplacian is a method obtained by improving the classical Laplacian algorithm with reference to the method for determining the clarity score in the present application (ArcFYH algorithm). It can be seen that the ArcLaplacian algorithm also performs poorly, indicating that the design pattern of the ArcFYH algorithm of the present application cannot be applied to existing algorithms. In other words, the ArcFYH algorithm of the present application is unique. The curve corresponding to the ArcFYH algorithm of the present application is more stable, more sensitive to changes, and the peak appears near the abscissa value of 20, presenting a unimodal shape. Since the focusing method of the present application needs to move the lens step by step within a preset range according to a preset step size, it is more appropriate to use the unimodal ArcFYH algorithm to cooperate and execute, which improves the accuracy of the focusing result.
[0128] It can be understood that the clarity scores of the second image and the third image can also be determined in the same way as the clarity score of the first image in the above embodiments, and the specific process will not be elaborated.
[0129] In some embodiments, during the process of determining the clarity score of the second image, multiple second regions that meet the second preset size are selected from the second image, and then the clarity score of the second image is determined according to the variances of the respective second regions. Wherein, the second preset size is smaller than the first preset size.
[0130] It should be understood that although the steps in the flowcharts involved in the above embodiments are sequentially shown according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0131] Based on the same inventive concept, an embodiment of the present application also provides a focusing device for implementing the focusing method involved above. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the following focusing devices can refer to the limitations on the focusing method in the above text, and will not be repeated here.
[0132] In one embodiment, as Figure 9 shown, a focusing device 900 is provided, including: a preliminary focusing module 902, a target field of view determination module 904, and an advanced focusing module 906, where:
[0133] The preliminary focusing module 902 is configured to move the lens of the image acquisition device for preliminary focusing to obtain the initial focusing plane of the lens.
[0134] The target field of view determination module 904 is configured to move the lens on the initial focusing plane to change the field of view position to determine the target field of view position.
[0135] The advanced focusing module 906 is configured to fix the field of view of the lens at the target field of view position, gradually move the lens around the initial focusing plane within a first preset range according to a first preset step size, and perform image acquisition after each movement to obtain multiple first images; determine the target focusing plane according to the clarity data of each first image.
[0136] In some embodiments, the advanced focusing module 906 is further configured to determine a quasi-focusing plane according to the clarity data of each first image; in the case where the quasi-focusing plane does not meet the focusing accuracy, gradually move the lens around the quasi-focusing plane within a second preset range according to a second preset step size, and perform image acquisition after each movement to obtain multiple second images; the second preset range is smaller than the first preset range; the second preset step size is smaller than the first preset step size; determine the target focusing plane according to the clarity data of each second image.
[0137] In some embodiments, the target field of view determination module 904 is further configured to gradually move the lens within a preset area range on the initial focus plane to change the field of view position, and perform image acquisition after each movement to obtain multiple third images under different fields of view; and determine the target field of view position according to the sharpness data of each third image.
[0138] In some embodiments, the sharpness data is a sharpness score. As Figure 10 shown, the apparatus 900 further includes:
[0139] A sharpness determination module 908, configured to, for each first image, select multiple first regions that meet a first preset size from the first image; respectively determine the variance of the pixel values of each pixel point in each first region; and determine the sharpness score of the first image according to the variances of the first regions in the first image.
[0140] In some embodiments, the sharpness determination module 908 is further configured to determine the first mean value of the pixel values of each pixel point in the first image and the second mean value of the pixel values of each pixel point in each first region in the first image; respectively determine the weight corresponding to each first region according to the difference between each second mean value and the first mean value; weight the variances of the first regions according to the weights corresponding to the first regions respectively, and determine the sharpness score of the first image according to the weighted result.
[0141] In some embodiments, the sharpness determination module 908 is further configured to respectively determine the difference between each second mean value and the first mean value; respectively determine the ratio between the difference corresponding to each first region and the first mean value; if the ratio corresponding to the first region is greater than or equal to a preset threshold, determine the first preset weight as the weight corresponding to the first region; if the ratio corresponding to the first region is less than the preset threshold, determine the second preset weight as the weight corresponding to the first region; wherein, the first preset weight is less than the second preset weight.
[0142] In the above focus device, first move the lens of the image acquisition device for initial focusing to obtain the initial focus plane of the lens, then move the lens on the initial focus plane to change the field of view position to determine the target field of view position, which can lock the search range of the focus plane within a certain range, then fix the field of view of the lens at the target field of view position, gradually move the lens within a first preset range around the initial focus plane according to a first preset step length, and perform image acquisition after each movement to obtain multiple first images, and finally determine the target focus plane according to the sharpness data of each first image, which can efficiently determine the target focus plane and improve the focusing efficiency.
[0143] Each module in the above focusing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above modules can be embedded in the processor of the image acquisition device in hardware form or be independent of it, or can be stored in the memory of the image acquisition device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.
[0144] In one embodiment, an image acquisition device is provided, and its internal structure diagram can be as Figure 11 shown. The image acquisition device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the image acquisition device is used to provide computing and control capabilities. The memory of the image acquisition device includes a non-volatile 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 the computer program in the non-volatile storage medium. The network interface of the image acquisition device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, it implements a focusing method.
[0145] Those skilled in the art can understand that Figure 11 the structure shown in
[0146] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the image acquisition device to which the solution of this application is applied. The specific image acquisition device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0147] In one embodiment, an image acquisition device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0148] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, the steps in the above method embodiments are implemented.
[0149] It should be noted that the data involved in this application (including but not limited to data for analysis, stored data, displayed data, etc.) are all information and data authorized by users or fully authorized by all parties.
[0150] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memory can include Read-Only Memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0151] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0152] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A focusing method, characterized in that, the method includes: Moving the lens of the image acquisition device for preliminary focusing to obtain the initial focusing plane of the lens; Moving the lens on the initial focusing plane to change the field of view position to determine the target field of view position; Fixing the field of view of the lens at the target field of view position, gradually moving the lens step by step within a first preset range around the initial focusing plane according to a first preset step size, and performing image acquisition after each movement to obtain multiple first images; Determining the target focusing plane according to the sharpness data of each of the first images.
2. The method according to claim 1, characterized in that, the determining the target focusing plane according to the sharpness data of each of the first images includes: Determining a quasi-focusing plane according to the sharpness data of each of the first images; In the case that the quasi-focusing plane does not meet the focusing accuracy, gradually moving the lens step by step within a second preset range around the quasi-focusing plane according to a second preset step size, and performing image acquisition after each movement to obtain multiple second images; the second preset range is smaller than the first preset range; the second preset step size is smaller than the first preset step size; Determining the target focusing plane according to the sharpness data of each of the second images.
3. The method according to claim 1, characterized in that, the moving the lens on the initial focusing plane to change the field of view position to determine the target field of view position includes: Within a preset area range on the initial focusing plane, gradually moving the lens to change the field of view position, and performing image acquisition after each movement to obtain multiple third images under different fields of view; Determining the target field of view position according to the sharpness data of each of the third images.
4. The method according to any one of claims 1 to 3, characterized in that, the sharpness data is a sharpness score; Before the determining the target focusing plane according to the sharpness data of each of the first images, the method further includes: For each of the first images, selecting multiple first regions that meet a first preset size from the first image; Respectively determining the variance of the pixel values of each pixel point in each of the first regions; Determining the sharpness score of the first image according to the variances of each of the first regions in the first image.
5. The method according to claim 4, characterized in that, the method further includes: Determining the first mean value of the pixel values of each pixel point in the first image and the second mean value of the pixel values of each pixel point in each of the first regions in the first image; Respectively determining the weights corresponding to each of the first regions according to the differences between each of the second mean values and the first mean value; the determining the sharpness score of the first image according to the variances of each of the first regions in the first image includes: Weighting the variances of each of the first regions according to the weights corresponding to each of the first regions, and determining the sharpness score of the first image according to the weighting result.
6. The method according to claim 5, characterized in that, Determining the weights corresponding to the first regions respectively according to the differences between the respective second means and the first mean includes: Determining the differences between the respective second means and the first mean respectively; Determining the ratios between the differences corresponding to the first regions respectively and the first mean; If the ratio corresponding to the first region is greater than or equal to a preset threshold, determining the first preset weight as the weight corresponding to the first region; If the ratio corresponding to the first region is less than the preset threshold, determining the second preset weight as the weight corresponding to the first region; wherein, the first preset weight is less than the second preset weight.
7. A focusing device, characterized in that, the device includes: A preliminary focusing module, configured to move the lens of the image acquisition device for preliminary focusing to obtain the initial focusing plane of the lens; A target field of view determination module, configured to move the lens on the initial focusing plane to change the field of view position to determine the target field of view position; An advanced focusing module, configured to fix the field of view of the lens at the target field of view position, move the lens step by step in a first preset range around the initial focusing plane according to a first preset step size, and perform image acquisition after each movement to obtain a plurality of first images; determine the target focusing plane according to the sharpness data of the first images.
8. An image acquisition device, including a memory and a processor, the memory stores a computer program, characterized in that, when the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium, on which a computer program is stored, characterized in that, when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, including a computer program, characterized in that, when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Automatic focusing method, equipment and medium
CN121276777A
An auto focus method, apparatus and medium
CN121276777B