Automatic Focusing Method, Device and Storage Medium Based on Image Information Entropy Power Operation
By using image information entropy power computing and mountain climbing search methods in autofocus technology, the accuracy and efficiency problems of the existing technology under low contrast are solved, and high-precision autofocus is achieved, which is suitable for scenes such as fundus confocal systems.
Patent Information
- Application Number
- CN202510091477.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2045-01-21
AI Technical Summary
The existing autofocus technology has low accuracy and low fitting process efficiency, making it difficult to achieve high-precision autofocus.
The automatic focus method based on image information entropy power operation is adopted to calculate the evaluation function value of the image through information entropy power operation, and combine the mountain climbing search of large and small steps to gradually determine the peak position, and improve the fitting accuracy through polynomial fitting.
The accuracy and efficiency of autofocus are improved in the case of low image contrast, and high-precision autofocus is achieved without the need for additional focus mechanisms, which are low in cost and fast in focus speed.
Smart Images

Figure CN119545177B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of biomedical imaging technology, and particularly to an autofocus method, device, and storage medium based on image information entropy power operation. Background Art
[0002] Camera focusing refers to the process of adjusting the focus distance when using a camera to make the image of the object being photographed clear. There are various focusing methods, including autofocus, manual focus, and multiple focus. Manual focus is to adjust the lens by manually turning the focus ring, which is suitable for scenarios that require precise control. Autofocus is the most commonly used method, which can help users quickly lock the focus in a rapidly changing scene.
[0003] Autofocus is the most commonly used focusing method, which is divided into single-shot autofocus (AF-S) and continuous autofocus (AF-C). Single-shot autofocus is suitable for photographing stationary objects, while continuous autofocus is suitable for photographing moving subjects and can automatically adjust the focus distance as the image changes.
[0004] During the autofocus process, the accuracy of fitting directly affects the accuracy of focusing. How to determine a suitable fitting function has always been a difficult problem in focusing using the fitting algorithm.
[0005] In related technologies, such as a Chinese patent with the application number CN202210249149.8 and the invention name of a camera autofocus method based on image information entropy, this method discloses that when the real-time image information entropy at a certain moment is equal to the maximum fitting value of the information entropy, the camera is in the quasi-focus state and stops focusing; otherwise, the camera continues to autofocus automatically. Due to the deviation between the fitting value and the real value, it is easy to enter an infinite loop and is difficult to be actually applied.
[0006] Another example is "Application of Hybrid Search Method in Microscope Autofocus", "Opto-Electronic Engineering", Jiang Minshan, etc. In this paper, a hybrid search method is used to achieve the autofocus of the microscope. This method uses the gray variance evaluation function and the Laplacian function for focusing during the coarse and fine focusing processes respectively, and then through multiple rounds of hill climbing search, until the search interval is within the threshold range, the function approximation is used to fit the peak position. Therefore, the search efficiency is low, and due to the inconsistent shapes of the focusing evaluation function and the approximation function, the fitting accuracy is not ideal.
[0007] Therefore, it is necessary to provide a new method to solve the above technical problems. Summary of the Invention
[0008] To achieve the above objects and other advantages of the present invention, the first object of the present invention is to provide an autofocus method based on image information entropy power operation, including the following steps:
[0009] Obtain the initial image collected at the system zero position;
[0010] Calculate the evaluation function value of the image through information entropy power operation;
[0011] Take the evaluation function value of the initial image as the initial value, and determine the peak direction and climb the mountain with a large step size;
[0012] Take the evaluation function value at the peak position obtained by climbing the mountain with a large step size as the initial value for peak direction determination, adjust the moving step size to a small step size, and perform the second peak direction determination and mountain climbing;
[0013] Summarize and fit the data of the second peak direction determination and small-step mountain climbing to obtain the peak position as the ideal focus position;
[0014] Drive the displacement stage to the ideal focus position for imaging to complete autofocus.
[0015] Further, the formula for the information entropy power operation is:
[0016] ;
[0017] Among them, is the number of possible pixel values in the image, is the probability that the pixel value i appears, is the base of the logarithm, is the exponent of the power operation.
[0018] Further, the step of determining the peak direction and climbing the mountain with a large step size includes:
[0019] Take the evaluation function value obtained by peak direction determination as the initial value for mountain climbing, and start climbing the mountain with a large step size in the determined direction to determine the peak position.
[0020] Further, the step of performing the second peak direction determination and mountain climbing includes:
[0021] Take the evaluation function value obtained by the second peak direction determination as the initial value for mountain climbing, and start climbing the mountain with a small step size in the determined direction to obtain a more accurate peak position.
[0022] Further, the determination of the peak direction includes the following steps:
[0023] Drive the displacement stage to move a specified step size along the positive and / or negative directions from the initial position to collect images;
[0024] Compare the evaluation function values of the images at each position before and after the movement;
[0025] If the evaluation function value of the image at the initial position is the largest, skip mountain climbing and obtain the peak position;
[0026] If the evaluation function value of the image moving a specified step length in the positive direction is the largest, then use the evaluation function value of the image collected by moving the specified step length in the positive direction as the initial value for hill climbing, and start hill climbing in the positive direction;
[0027] If the evaluation function value of the image moving a specified step length in the negative direction is the largest, then use the evaluation function value of the image collected by moving the specified step length in the negative direction as the initial value for hill climbing, and start hill climbing in the negative direction.
[0028] Furthermore, the steps of hill climbing include:
[0029] Use the input value determined by the peak direction as the initial value, take one step forward in the specified direction, and collect an image;
[0030] Compare the evaluation function value of the collected image with the initial value;
[0031] If it is greater than the initial value, then use the evaluation function value of the collected image as the initial value, continue to loop forward until the evaluation function value of the collected image is not greater than the initial value, and obtain the position of the maximum evaluation function value, which is the current peak position.
[0032] Furthermore, the large step length is less than half of the full width at half maximum of the focusing function curve, the small step length is less than 0.25 times the large step length, and is not divisible by the large step length.
[0033] Furthermore, the base of the logarithm takes a value of 2, and the exponent of the power operation takes a value of 3.
[0034] Furthermore, the step of summarizing and fitting the data of the second peak direction determination and small-step hill climbing includes:
[0035] Summarize the data of the second peak direction determination and small-step hill climbing and perform m-order polynomial fitting.
[0036] Furthermore, it also includes the step:
[0037] When the number of summarized data is less than m, move a small displacement amount in each of the positive and negative directions from the relatively accurate peak position obtained from the second peak direction determination. The small displacement amount is less than the small step length, obtain the evaluation function of the positions moved by the small displacement amount in each of the positive and negative directions, supplement it as the data participating in the fitting, and perform m-order polynomial fitting;
[0038] If the number of data participating in the summary is still less than m, move 2 times the small displacement amount in each of the positive and negative directions from the relatively accurate peak position obtained from the second peak direction determination, and so on, until the number of data participating in the fitting is greater than or equal to m.
[0039] The second object of the present invention is to provide a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the above method are implemented.
[0040] The third object of the present invention is to provide a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0041] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0042] The present invention provides an automatic focusing method, device, and storage medium based on image information entropy power operation. By performing power operation on the information entropy, accurate determination can be made in the case of low image contrast, the sensitivity of the evaluation function is improved, and the evaluation function has polynomial characteristics. Then, data points around the peak region are extracted for polynomial fitting, improving the accuracy of fitting and thus the accuracy of automatic focusing; it can achieve automatic focusing of the device without the need to additionally increase a focusing mechanism, and high-precision automatic focusing can be achieved only through two hill-climbing searches, with low cost and fast focusing speed; compared with traditional fundus focusing systems that require adding a special focusing target, etc., the present invention is particularly suitable for automatic focusing of fundus confocal systems and can effectively avoid the influence brought by refractive errors.
[0043] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly and implement it in accordance with the content of the specification, the following takes the preferred embodiments of the present invention and combines with the accompanying drawings to elaborate in detail as follows. The specific implementation manners of the present invention are given in detail by the following embodiments and their accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings described herein are used to provide a further understanding of the present invention, form a part of this application, and the illustrative embodiments and descriptions of the present invention are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0045] Figure 1 is the flowchart of the automatic focusing method based on image information entropy power operation for Embodiment 1 Figure 1 ;
[0046] Figure 2 is the flowchart of the automatic focusing method based on image information entropy power operation for Embodiment 1 Figure 2 ;
[0047] Figure 3 is the flowchart of the automatic focusing method based on image information entropy power operation for Embodiment 1 Figure 3 ;
[0048] Figure 4This is a peak direction determination flow chart of Example 1;
[0049] Figure 5 This is a hill climbing flow chart of Example 1;
[0050] Figure 6 This is a peak search schematic diagram of Example 1;
[0051] Figure 7 This is a schematic diagram of a polynomial fitting curve of Example 1;
[0052] Figure 8 This is a schematic diagram of the image acquisition of Example 1;
[0053] Figure 9 This is a schematic diagram of a computer device according to Embodiment 2;
[0054] Figure 10 Schematic diagram of a computer-readable storage medium of Example 3. DETAILED DESCRIPTION
[0055] The present invention is further described below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. It should be noted that, under the premise of no conflict, the embodiments or technical features described below can be arbitrarily combined to form a new embodiment.
[0056] Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without making any creative work shall fall within the scope of protection of the present invention.
[0057] The figure numbers in this application are only used to distinguish the various steps in the scheme, and are not used to limit the execution order of the various steps. The specific execution order is subject to the description in the specification.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention. Example 1
[0059] An auto-focus method based on image information entropy power operation, such as Figures 1 - 3 As shown, the following steps are included:
[0060] S1, obtaining an initial image collected at the system zero position;
[0061] In one implementation, the system first returns to a zero position and captures a first initial image.
[0062] S2. Calculate the evaluation function value of the image through information entropy power operation;
[0063] In one implementation, the formula for the information entropy power operation is:
[0064] ;
[0065] where, is the number of possible pixel values in the image. For example, for a grayscale image, it is usually 255; is the probability that the pixel value i appears, is the base of the logarithm, is the exponent of the power operation.
[0066] Preferably, the base of the logarithm takes the value as 2, and the exponent of the power operation takes the value of 3.
[0067] S3. Take the evaluation function value of the initial image as the initial value, and perform peak direction determination and hill climbing with a large step size a;
[0068] In one implementation, the step of performing peak direction determination and hill climbing with a large step size a includes:
[0069] Take the evaluation function value obtained by peak direction determination as the initial value of hill climbing, and start hill climbing with a large step size a in the determined direction to determine the peak position.
[0070] After finishing hill climbing with a large step size a, in S4, take the evaluation function value at the peak position obtained by hill climbing with a large step size a as the initial value of peak direction determination, adjust the moving step size to a small step size c, and perform the second peak direction determination and hill climbing;
[0071] In one implementation, the step of performing the second peak direction determination and hill climbing includes:
[0072] Take the evaluation function value obtained by the second peak direction determination as the initial value of hill climbing, and start hill climbing with a small step size c in the determined direction. After finishing hill climbing, obtain a more accurate peak position.
[0073] Preferably, the large step size a is slightly smaller than half of the full width at half maximum of the focusing function curve to ensure that there are at least two sampling points in the peak region during the coarse focusing stage. The small step size c is less than 0.25 times the large step size a and is not divisible by the large step size a.
[0074] The principle of peak direction determination in step S3 and step S4 is the same. In one implementation, as Figure 4 shown, the determination of the peak direction includes the following steps:
[0075] S300. Drive the displacement stage to move a specified number of steps in the positive and / or negative directions from the initial position to acquire images.
[0076] S310. Compare the evaluation function values of the images at each position before and after the movement. For example, represent the evaluation function value of the image at the initial position as F0, the evaluation function value of the image after moving a specified number of steps in the positive direction as F1, and the evaluation function value of the image after moving a specified number of steps in the negative direction as F2.
[0077] S320. If the evaluation function value of the image at the initial position is the largest, skip the hill climbing and obtain the peak position.
[0078] S330. If the evaluation function value of the image after moving a specified number of steps in the positive direction is the largest, use the evaluation function value of the image acquired after moving a specified number of steps in the positive direction as the initial value for hill climbing and start hill climbing in the positive direction.
[0079] S340. If the evaluation function value of the image after moving a specified number of steps in the negative direction is the largest, use the evaluation function value of the image acquired after moving a specified number of steps in the negative direction as the initial value for hill climbing and start hill climbing in the negative direction.
[0080] In one implementation, as Figure 5 shown, the steps of hill climbing include:
[0081] Use the input value determined by the peak direction as the initial value, take one step forward in the specified direction, and acquire an image.
[0082] Compare the evaluation function value of the acquired image with the initial value.
[0083] If it is greater than the initial value, use the evaluation function value of the acquired image as the initial value and continue to loop forward until the evaluation function value of the acquired image is not greater than the initial value, then obtain the position with the largest evaluation function value, which is the current peak position.
[0084] In an alternative embodiment, the displacement stage can be driven to move a specified number of steps in the positive or negative direction from the initial position to acquire images. For example, drive the displacement stage to move a specified number of steps in the negative direction from the initial position to acquire images.
[0085] Compare the evaluation function values of the initial position and the image after the movement. For example, compare the evaluation function values of the initial position and the image after moving in the negative direction.
[0086] If the evaluation function value of the image after movement is greater than that of the image at the initial position, then use the evaluation function value of the image collected by moving a specified step length along the current direction as the initial value for hill climbing, and start hill climbing along the current direction. The principle of hill climbing is the same as that described above and will not be elaborated here. For example, if the evaluation function value of the image after moving in the negative direction is greater than that of the image at the initial position, it indicates that the peak search direction is correct and it is necessary to continue searching along the current direction. Then use the evaluation function value of the image collected by moving a specified step length in the negative direction as the initial value for hill climbing, take one step forward in the negative direction, and collect an image; compare the evaluation function value of the collected image with the initial value; if it is greater than the initial value, use the evaluation function value of the collected image as the initial value and continue to loop forward until the evaluation function value of the image collected after movement is not greater than the initial value, and the position with the maximum evaluation function value is obtained, which is the current peak position;
[0087] If the evaluation function value of the image after movement is not greater than that of the image at the initial position, then drive the displacement stage to move in the opposite direction from the initial position by a specified step length to collect an image; for example, if the evaluation function value of the image after moving in the negative direction is not greater than that of the image at the initial position, it indicates that the peak search direction is incorrect and it is necessary to change the direction and search again. Then drive the displacement stage to move in the positive direction from the initial position by a specified step length to collect an image;
[0088] Compare the evaluation function values of the image at the initial position and the image after the current movement again; for example, compare the evaluation function values of the image at the initial position and the image after moving in the positive direction;
[0089] If the evaluation function value of the image after the current movement is greater than that of the image at the initial position, then use the evaluation function value of the image collected by moving a specified step length along the current direction as the initial value for hill climbing, and start hill climbing along the current direction. The principle of hill climbing here is the same as that described above and will not be elaborated here. For example, if the evaluation function value of the image after moving in the positive direction is greater than that of the image at the initial position, it indicates that the peak search direction is correct and it is necessary to continue searching along the current direction. Then use the evaluation function value of the image collected by moving a specified step length in the positive direction as the initial value for hill climbing, take one step forward in the positive direction, and collect an image; compare the evaluation function value of the collected image with the initial value; if it is greater than the initial value, use the evaluation function value of the collected image as the initial value and continue to loop forward until the evaluation function value of the image collected after movement is not greater than the initial value, and the position with the maximum evaluation function value is obtained, which is the current peak position;
[0090] If the evaluation function value of the image after the current movement is not greater than the evaluation function value of the image at the initial position, it is determined that the evaluation function value of the image at the initial position is the largest, skip the hill climbing, and obtain the peak position. For example, if the evaluation function value of the image after moving in the positive direction is not greater than the evaluation function value of the image at the initial position, it indicates that the peak search direction is incorrect, then it is determined that the evaluation function value of the image at the initial position is the largest, skip the hill climbing, and obtain the peak position.
[0091] In another alternative embodiment, the displacement stage can be driven to move a specified step length from the initial position in both positive and negative directions to acquire images;
[0092] Compare the evaluation function values of the images at the three positions; that is, compare the evaluation function value F0 of the image at the initial position, the evaluation function value F1 of the image after moving a specified step length in the positive direction, and the evaluation function value F2 of the image after moving a specified step length in the negative direction.
[0093] If the evaluation function value of the image at the initial position is the largest, skip the hill climbing, and obtain the peak position;
[0094] If the evaluation function value of the image after moving a specified step length in the positive direction is the largest, use the evaluation function value of the image acquired by moving a specified step length in the positive direction as the initial value of hill climbing, and start hill climbing in the positive direction;
[0095] If the evaluation function value of the image after moving a specified step length in the negative direction is the largest, use the evaluation function value of the image acquired by moving a specified step length in the negative direction as the initial value of hill climbing, and start hill climbing in the negative direction.
[0096] The principle of hill climbing here is the same as the above-mentioned hill climbing principle, and will not be elaborated here.
[0097] It should be noted that the specific implementation method of peak direction determination can be selected in combination with the actual situation or actual needs, etc., and no specific limitation is made here.
[0098] Example, such as Figure 6As shown, the driving displacement stage first moves a large step length a from the initial position 0 along the negative direction to collect images, where the large step length a is 3 mm. The initial position is marked as 1, and the position moved from the initial position along the negative direction by a large step length a is marked as 2. The evaluation function values of the images at positions 1 and 2 are compared. The evaluation function value of the image at position 2 is less than the evaluation function value of the image at position 1, indicating that the peak direction of the current search is incorrect. The driving displacement stage then moves a large step length a from the initial position 0 along the positive direction to collect images, and the position moved from the initial position along the positive direction by a large step length a is marked as 3. The evaluation function values of the images at positions 1 and 3 are compared. The evaluation function value of the image at position 3 is greater than the evaluation function value of the image at position 1, indicating that the peak direction of the current search is correct and it is necessary to continue searching in the positive direction. The evaluation function value of the image at position 3 is taken as the initial value for hill climbing, and hill climbing is started in the positive direction. The driving displacement stage then moves a large step length a from position 3 along the positive direction to collect images, and the position moved from position 3 along the positive direction by a large step length a is marked as 4. The evaluation function values of the images at positions 3 and 4 are compared. The evaluation function value of is greater than the evaluation function value of the image at position 3, indicating that the peak direction of the current search is correct, and it is necessary to continue searching in the positive direction. The evaluation function value of the image at position 4 is used as the initial value for hill climbing, and hill climbing begins in the positive direction. The translation stage is driven to move a large step length a from position 4 in the positive direction to collect images, and the position where the position is moved by a large step length a from position 4 in the positive direction is marked as 5. The evaluation function values of the images at position 4 and position 5 are compared. The evaluation function value of the image at position 5 is greater than the evaluation function value of the image at position 4, indicating that the peak direction of the current search is correct, and it is necessary to continue searching in the positive direction. The evaluation function value of the image at position 5 is used as the initial value for hill climbing, and hill climbing begins in the positive direction. The translation stage is driven to move a large step length a from position 5 in the positive direction to collect images, and the position where the position is moved by a large step length a from position 5 in the positive direction is marked as 6. The evaluation function values of the images at position 5 and position 6 are compared. The evaluation function value of the image at position 6 is less than the evaluation function value of the image at position 5, indicating that position 5 is the position with the largest evaluation function value, that is, the current peak position. At this point, the hill climbing search process with a large step length a is completed.
[0099] The stage is driven to move from position 5 in the negative direction by a small step length c to collect images. Here, the small step length c is 0.54 mm. The position where the small step length c is moved from position 5 in the negative direction is marked as 7. The evaluation function values of the images at position 5 and position 7 are compared. The evaluation function value of the image at position 7 is less than the evaluation function value of the image at position 5, indicating that the peak direction of the current search is incorrect. The stage is driven to move from position 5 in the positive direction by a small step length c to collect images. The position where the small step length c is moved from position 5 in the positive direction is marked as 8. The evaluation function values of the images at position 5 and position 8 are compared. The evaluation function value of the image at position 8 is greater than The evaluation function value of the image at position 5 indicates that the peak direction of the current search is correct, and it is necessary to continue searching in the positive direction. The evaluation function value of the image at position 8 is used as the initial value for hill climbing, and hill climbing is started in the positive direction. The translation stage is driven to move from position 8 in a small step length c in the positive direction to collect images, and the position moved from position 8 in the positive direction by a small step length c is marked as 9. The evaluation function values of the images at position 8 and position 9 are compared. The evaluation function value of the image at position 8 is greater than that of the image at position 9, indicating that position 8 is the position with the largest evaluation function value, which is the current peak position. At this point, the hill climbing search process with a small step length c is completed.
[0100] The positions and evaluation function values of the images obtained by performing peak direction determination with a large step size a and a small step size c are shown in Table 1.
[0101] Table 1 Position and image evaluation function value table
[0102]
[0103] S5, summarizing and fitting the data of the second peak direction determination and small step length mountain climbing to obtain the peak position as the ideal focus position;
[0104] In one embodiment, the step of aggregating the data of the second peak direction determination and small step climbing for fitting includes:
[0105] The data of the second peak direction determination and small step climbing are summarized and fitted with an m-order polynomial. Preferably, the order m of the m-order polynomial fitting is the same as the power operation exponent in the above information entropy power operation formula. Take the same value.
[0106] Combined with the above example, the data marked as 5, 7, 8, and 9 in Table 1 are aggregated and fitted with an m-order polynomial. The fitted curve is as follows: Figure 7 As shown in the figure, the peak position 9.34 is obtained as the ideal focus position. In this example, the image collected at each position is stored by multiplying its position value by 6400. The image collected at each position (including the obtained peak position 9.34) is as follows: Figure 8 As shown. Figure 8It can be seen that the image captured at the peak position of 9.34 has the highest clarity.
[0107] In some embodiments, it further includes the steps of:
[0108] When the number of aggregated data is less than m, the relatively accurate peak position (p0) determined from the second peak direction is respectively moved by a small displacement amount d in the positive and negative directions, and the small displacement amount d is less than the small step size c, to obtain the evaluation functions of the positions moved by the small displacement amount in the positive and negative directions, that is, the evaluation functions of the positions p0 + d and p0 - d, which are supplemented as the data participating in the fitting, and an m-order polynomial fitting is performed;
[0109] If the number of data participating in the aggregation is still less than m, the relatively accurate peak position determined from the second peak direction is respectively moved by 2 times the small displacement amount in the positive and negative directions, that is, the data of p0 + 2d and p0 - 2d are supplemented, and so on, until the number of data participating in the fitting is greater than or equal to m.
[0110] S6. Drive the displacement stage to the ideal focusing position for imaging to complete autofocus.
[0111] This embodiment provides an autofocus method based on the power operation of image information entropy. By performing the power operation on the information entropy, accurate determination can be made in the case of low image contrast, the sensitivity of the evaluation function is improved, and the evaluation function has polynomial characteristics. Then, the data points around the peak region are extracted for polynomial fitting, which improves the accuracy of the fitting, and further improves the accuracy of autofocus; it can realize the autofocus of the device without additionally increasing a focusing mechanism, and only needs to perform two hill-climbing searches to achieve high-precision autofocus, with low cost and fast focusing speed; compared with the traditional fundus focusing system that needs to add a special focusing target, etc., the present invention is particularly suitable for the autofocus of the fundus confocal system and can effectively avoid the influence brought by refractive error. Embodiment 2
[0112] A computer device 700, as Figure 9 shown, includes a memory 710, a processor 720, and a computer program 730 stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of an autofocus method based on the power operation of image information entropy. For the detailed description of the method, reference can be made to the corresponding description in the above method embodiments, and details will not be repeated here. Embodiment 3
[0113] A computer-readable storage medium, as Figure 10As shown, a computer program is stored thereon, and when the computer program is executed by a processor, it implements the steps of an autofocus method based on image information entropy power operation. For a detailed description of the method, reference may be made to the corresponding description in the above method embodiments, which will not be elaborated here.
[0114] The number of devices and the scale of processing described here are used to simplify the description of the present invention. Applications, modifications, and variations of the present invention will be apparent to those skilled in the art.
[0115] Although the embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the specification and embodiments. It can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily made. Therefore, without departing from the general concept defined by the claims and their equivalents, the present invention is not limited to specific details and the examples shown and described here.
[0116] The devices, computer devices, non-volatile computer storage media provided in the embodiments of this specification correspond to the method. Therefore, the devices, computer devices, and non-volatile computer storage media also have beneficial technical effects similar to the corresponding method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the corresponding devices, computer devices, and non-volatile computer storage media will not be elaborated here.
[0117] Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, the method steps can be logically programmed to enable the controller to implement the same function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software units for implementing the method and structures within the hardware component.
[0118] The systems, devices, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. For the convenience of description, when describing the above devices, they are divided into various units according to functions for separate description. Of course, when implementing one or more embodiments of this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0119] Those skilled in the art should understand that the embodiments of this specification can be provided as a method, a system, or a computer program product. Therefore, the embodiments of this specification can take the form of an all-hardware embodiment, an all-software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0120] This specification is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of this specification. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices produce means for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or a combination of flows and / or blocks
[0121] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory produce a manufactured article including instruction means that implement the functions specified in Figure 1 one or more of the flows Figure 1 or a combination of flows and / or blocks
[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or a combination of flows and / or blocks
[0123] It should also be noted that the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising said element.
[0124] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program units. Generally, program units include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The specification may also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program units may be located in local and remote computer storage media including storage devices.
[0125] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference may be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, they are described relatively simply, and reference may be made to the corresponding parts of the method embodiments for the relevant content.
[0126] The above description is only for the embodiments of this specification and is not intended to limit one or more embodiments of this specification. For those skilled in the art, various changes and modifications can be made to one or more embodiments of this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of one or more embodiments of this specification shall be included within the scope of the claims of one or more embodiments of this specification.
Claims
1. An automatic focusing method based on image information entropy power operation, characterized in that: The following steps are involved: Obtain an initial image acquired at the system zero position; Calculate the evaluation function value of the image through information entropy power operation; Using the evaluation function value of the initial image as the initial value, performing the first peak direction determination and hill climbing with a large step length; The evaluation function value of the peak position obtained by large step length hill climbing is used as the initial value for peak direction determination, and the moving step length is adjusted to a small step length, and the second peak direction determination and hill climbing are performed; The data of the second peak direction determination and small step length hill climbing are summarized and fitted to obtain the peak position as the ideal focus position; Drive the translation stage to the ideal focus position for imaging and complete autofocus.
2. The automatic focusing method based on image information entropy power calculation as claimed in claim 1, characterized in that: The formula for the information entropy power operation is: , in, is the number of possible pixel values in the image, is the probability of pixel value i appearing, is the base of the logarithm, The exponent of the power operation.
3. The automatic focusing method based on image information entropy power calculation as claimed in claim 1, characterized in that: The first peak direction determination and hill climbing steps with a large step length include: The maximum evaluation function value obtained by the first peak direction determination is used as the initial value of hill climbing, and large-step hill climbing is started according to the determined direction to determine the peak position; wherein the maximum evaluation function value is obtained by comparing the evaluation function value of the initial position image during the first peak direction determination process, the evaluation function value of the image moved along the positive direction with the evaluation function value of the image moved along the negative direction with the specified step length.
4. The automatic focusing method based on image information entropy power calculation as claimed in claim 3, characterized in that: The second peak direction determination and mountain climbing steps include: The maximum evaluation function value obtained by the second peak direction determination is used as the initial value of hill climbing. Hill climbing with small steps is started according to the determined direction to obtain a more accurate peak position. The maximum evaluation function value is obtained by comparing the evaluation function value of the initial position image during the second peak direction determination process, the evaluation function value of the image moved along the positive direction with the evaluation function value of the image moved along the negative direction with the evaluation function value of the image moved along the negative direction with the specified step length.
5. The automatic focusing method based on image information entropy power calculation as claimed in claim 4, characterized in that: The first peak direction determination and the second peak direction determination both include the following steps: Drive the translation stage to move from the initial position along the positive and negative directions by specified steps to collect images; Compare the evaluation function values of the images at each position before and after the movement; If the evaluation function value of the image at the initial position is the largest, then hill climbing is skipped and the peak position is obtained; If the evaluation function value of the image with the specified step length moved in the positive direction is the largest, the evaluation function value of the image collected by moving the specified step length in the positive direction is used as the initial value of hill climbing, and hill climbing begins in the positive direction; If the evaluation function value of the image acquired by moving the specified step length in the negative direction is the largest, the evaluation function value of the image acquired by moving the specified step length in the negative direction is used as the initial value of hill climbing, and hill climbing begins in the negative direction.
6. The automatic focusing method based on image information entropy power calculation as claimed in claim 5, characterized in that: The steps to climb the mountain include: The maximum evaluation function value obtained by the peak direction is used as the initial value, and one step is taken in the specified direction to collect images; Compare the evaluation function value of the acquired image with the initial value; If it is greater than the initial value, the evaluation function value of the collected image is used as the initial value, and the cycle continues until the evaluation function value of the collected image is no greater than the initial value, and the maximum evaluation function value position is obtained, which is the current peak position.
7. The automatic focusing method based on image information entropy power calculation as claimed in claim 1, characterized in that: The large step length is smaller than half of the half-height width of the focus function curve, and the small step length is smaller than 0.25 times of the large step length and is not divisible by the large step length.
8. The automatic focusing method based on image information entropy power calculation as claimed in claim 2, characterized in that: Base of logarithms The value is 2, the exponent of the power operation The value is 3.
9. The automatic focusing method based on image information entropy power calculation as claimed in claim 4, characterized in that: The step of aggregating the data of the second peak direction determination and small step length mountain climbing for fitting comprises: The data of the second peak direction determination and small step climbing are summarized and fitted with an m-order polynomial.
10. The automatic focusing method based on image information entropy power calculation as claimed in claim 9, characterized in that: Also includes the steps: When the number of summarized data is less than m, the more accurate peak position obtained from the second peak direction determination and hill climbing is moved by a small displacement in the positive and negative directions respectively, and the small displacement is smaller than the small step size, and the evaluation function of the small displacement position in the positive and negative directions is obtained, which is supplemented as the data involved in the fitting, and an m-order polynomial fitting is performed; If the number of data involved in the summary is still less than m, the more accurate peak position obtained from the second peak direction determination and hill climbing is moved by 2 times the small displacement in the positive and negative directions respectively, and so on, until the number of data involved in the fitting is greater than or equal to m.
11. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 10 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, 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 10 are implemented.
Citation Information
Patent Citations
A camera autofocus method based on image information entropy
CN114845042B
Automatic focusing searching algorithm
CN107509023A
Spacecraft optical load on-orbit adaptive focusing method and device, equipment and medium
CN112526705A