A high-precision optical automatic dynamic focusing system and focusing method thereof
By improving the window selection and search strategy in the autofocus system, combined with the image clarity evaluation model of CEEMDAN and the autocoding network, the efficiency, accuracy and reliability of the autofocus system in the prior art in complex environments is solved, and high-precision and fast autofocus effect are achieved.
Patent Information
- Application Number
- CN202411835398.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-13
AI Technical Summary
While improving focus accuracy and speed, existing autofocus systems are difficult to ensure the efficiency, accuracy and reliability of focus results, especially in complex environments.
By improving the window selection and search strategy in the autofocus process, an image clarity evaluation model is constructed using improved empirical modal decomposition (CEEMDAN) and self-encoding networks, combining Stacking integrated strategy to integrate multiple definition scoring functions to optimize the focus search process.
It improves the accuracy and reliability of autofocus results, enhances the real-time and stability of clarity evaluation, avoids frequent changes in focus search direction, and ensures focus accuracy, speed and versatility.
Smart Images

Figure CN119335685B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of optical fixed focus, and more specifically, to a high-precision optical automatic dynamic focusing system and a focusing method thereof. Background Art
[0002] As one of the key technologies of optical imaging systems, autofocus technology is widely used in satellite navigation, power line inspection, robot vision, automatic monitoring and other fields. With the popularization of various miniaturized imaging devices such as digital cameras and smart phones, consumers have higher and higher requirements for image quality. Both imaging quality and imaging speed are very important. How to achieve fast and accurate autofocus has become the key to the problem.
[0003] According to the different focusing principles used, the autofocus method can be divided into the autofocus method based on distance measurement, the autofocus method based on image detection and the autofocus method based on image processing. The method based on distance measurement requires the addition of additional distance measurement equipment to the system, which makes the focusing system complex and costly. The method based on image detection has high requirements on the optical and mechanical results of the system and is greatly affected by external environmental factors. The autofocus method based on image processing does not require any equipment to be added to the focusing system. It only relies on the clarity of the image collected by the imaging system for focusing. Compared with the distance measurement and image detection methods, it has the advantages of high focusing accuracy, fast focusing speed and high degree of automation. In the autofocus system based on image processing, the method for evaluating the clarity of the image is called the image clarity evaluation function, and the method for evaluating the clarity of the image is called the image clarity evaluation function. The clarity evaluation function directly affects the performance of the entire autofocus system. At present, most autofocus search strategies adopt a combination of multiple search strategies, and the focusing speed is slow. Therefore, how to improve the efficiency, accuracy and reliability of the autofocus results is an urgent problem to be solved. Summary of the invention
[0004] In order to solve the above technical problems, the present invention proposes a high-precision optical automatic dynamic focusing system and a focusing method thereof, the purpose of which is to improve the accuracy and reliability of the automatic focusing result by improving the window selection and search strategy in the automatic focusing process.
[0005] The present invention provides a high-precision optical automatic dynamic focusing system, including: a data acquisition and preprocessing module, a focus window construction module, a clarity evaluation module, a focus search module and a mechanical execution module;
[0006] The data acquisition and preprocessing module is responsible for acquiring the focused image sequence and preprocessing the focused image sequence;
[0007] The focus window construction module is responsible for selecting a focus window based on the preprocessed image;
[0008] The clarity evaluation module is responsible for extracting modal components of different scales using the improved empirical mode decomposition using the focus window, selecting a preset number of modal components according to energy entropy, and weighting the selected modal components, obtaining an image clarity evaluation model based on the autoencoder network, and obtaining an estimated value of the clarity peak point of the weighted modal component under the ideal clarity evaluation curve;
[0009] The focus search module is responsible for determining the search direction based on the estimated value of the retained clarity peak point, and searching for a range to obtain the best focus position;
[0010] The mechanical execution module is responsible for driving the high-precision optical device to move to the corresponding position to continue collecting images until the image of the measured target is clearest.
[0011] In this solution, the data acquisition and preprocessing module is specifically:
[0012] Preset a moving speed and an initial acquisition position of the high-precision optical device, and after acquiring an image of the measured target at the initial acquisition position, drive the high-precision optical device to move at a uniform speed based on the moving speed to acquire an image at the corresponding position;
[0013] The image data collected each time is used to form a focused image sequence, and the imaging parameters of the high-precision optical device are matched, the focused image is segmented, the segmented focused image is grayed, and the gray-level co-occurrence matrix of the image block is obtained to represent the texture feature;
[0014] The Scharr operator is used to convolve the grayed image block to extract the edge features of the image block.
[0015] In this solution, the focus window construction module is specifically:
[0016] Obtain image blocks after the focused image is segmented and the texture features and edge features corresponding to each image block, obtain the gradients of the image blocks in four directions in the edge feature extraction of the image blocks, and sum the obtained gradients to generate the gradient value of the image blocks;
[0017] In each image block, the grayscale image of the RGB three channels is calculated to obtain the image entropy corresponding to the RGB three channels, and the entropy weight method is used to perform weight amplitude, and the image entropy is weighted to obtain the color image entropy of the image block;
[0018] The contrast of the image block is calculated according to the texture features of the image block, the gradient value, color image entropy and contrast are adaptively weighted in each image block to obtain scoring information, and a preset number of image blocks are selected as focus windows according to the scoring information.
[0019] In this scheme, the focus window is used in the clarity evaluation module to use the improved empirical mode decomposition to extract modal components of different scales, a preset number of modal components are selected according to the energy entropy, and the selected modal components are weighted, specifically:
[0020] Adding adaptively decomposable Gaussian white noise to the image data corresponding to the focus window to obtain new image data, performing empirical mode decomposition on the new image data to obtain a first mode, and performing an averaging operation on the first mode to obtain a first modal component;
[0021] Subtracting the first modal component from the original focused image data to obtain a first residual, adding new Gaussian white noise to the first residual and performing empirical mode decomposition to obtain a second modal component;
[0022] Subtracting the second modal component from the first residual to obtain the second residual, obtaining the ith residual by repeated calculation, and when the ith residual is a monotonic function, ending the decomposition and extracting a number of modal components of different scales;
[0023] The modal components are divided into high-frequency modal components and low-frequency modal components according to energy entropy, and a preset number of modal components are reselected from the high-frequency modal components, and the weights of the selected modal components are extracted using a multi-head attention mechanism, and the weights are used to weight the selected modal components to reduce the influence of noise;
[0024] In this solution, in the clarity evaluation module, an image clarity evaluation model is constructed based on an autoencoder network, specifically:
[0025] Retrieve and obtain several auto-focusing examples based on image processing of the measured target, extract the clarity evaluation functions used in the examples, and select a preset number of clarity evaluation functions according to the appearance frequency of each clarity evaluation function;
[0026] At the same time, the defocused-in-focused-defocused images corresponding to the instances are extracted to construct training samples and verification samples. The Stacking integration strategy is introduced to select the clarity evaluation functions for integrated learning. Each clarity evaluation function is used to independently train the input training samples to obtain the corresponding clarity scores.
[0027] The clarity scores output by the base model corresponding to each clarity evaluation function are stacked, a meta-training set is constructed based on the training samples, and a meta-model is trained using the meta-training set to obtain a clarity score sequence output by the meta-model;
[0028] The clarity score sequence is iteratively calculated using the attention mechanism to obtain the attention weights of all clarity score sequences under the same training sample, and the attention weights are used for weighted integration to obtain the clarity score output by the Stacking integration strategy, and the in-focus image in the training sample is selected based on the output clarity score and verified using the verification sample;
[0029] Obtain a clarity score sequence that meets the verification standard, fit an ideal clarity evaluation curve based on the clarity score sequence that meets the verification standard, use an autoencoder network to perform feature encoding on the ideal clarity evaluation curve, and train to obtain a clarity evaluation model.
[0030] In this solution, the weighted modal components are used to obtain the actual measured value of the clarity score by using the clarity evaluation function integrated by Stacking, and the actual measured value of the clarity score is imported into the clarity evaluation model;
[0031] The measured value of the clarity score is encoded in the clarity evaluation model, and the estimated value of the clarity peak point under the ideal clarity evaluation curve is calculated by the decoder according to the encoding characteristics, and the estimated value of the maximum clarity peak point is retained by contrast between focus windows.
[0032] In this solution, the focus search module is specifically:
[0033] Obtaining a clarity score of an image obtained by a high-precision optical device at a current position, and calculating a difference between the clarity score at the current position and an estimated value of a retained maximum clarity peak point;
[0034] The difference values corresponding to the images at different lens positions are obtained, and the direction with the largest difference reduction is used as the search direction by comparing the difference values at different positions until the difference value is less than a preset difference threshold value, thereby obtaining the best focus position.
[0035] A second aspect of the present invention provides a high-precision optical automatic dynamic focusing method, comprising the following steps:
[0036] Acquire a focus image sequence collected by a high-precision optical device, preprocess the focus image sequence, and select a focus window based on the preprocessed image;
[0037] Using the focus window to extract image feature modal components of different scales using improved empirical mode decomposition, selecting a preset number of modal components according to energy entropy, and weighting the selected modal components;
[0038] An image clarity evaluation model is constructed based on an autoencoder network, and the weighted modal components are used as model input to obtain the estimated values of the clarity peak points of different modal components under the ideal clarity evaluation curve.
[0039] The search direction is determined based on the estimated value of the retained clarity peak point, and the range of the best focus position is searched to drive the high-precision optical device to move to the corresponding position to continue collecting images until the image of the target is clearest.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] (1) The present invention improves the window selection and clarity scoring function in the autofocus process. By introducing the CEEMDAN method to select an appropriate focus window, the amount of calculation is reduced, and the real-time performance of clarity evaluation is improved. In addition, the Stacking integration strategy is used to integrate multiple clarity scoring functions and the advantages of different clarity scoring scores, thereby improving the stability and robustness of the clarity scoring.
[0042] (2) The present invention optimizes the focus search, avoids frequent changes in the focus search direction, and prevents the occurrence of secondary peaks that lead to misfocusing, thereby improving the focus accuracy, focus speed and versatility, ensuring the efficiency and reliability of automatic focusing, and avoiding misjudgment. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments or exemplary embodiments of the present invention, the drawings required for use in the embodiments or exemplary descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained according to the drawings without paying creative work.
[0044] Figure 1 A block diagram of a high-precision optical automatic dynamic focusing system is shown;
[0045] Figure 2 The implementation flow chart of the focus window building module is shown;
[0046] Figure 3 A model building flow chart of the clarity evaluation module is shown;
[0047] Figure 4 A flow chart of a high-precision optical automatic dynamic focusing method is shown. DETAILED DESCRIPTION
[0048] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0049] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0050] Figure 1 A framework diagram of a high-precision optical automatic dynamic focusing system is shown.
[0051] like Figure 1 As shown, this embodiment provides a high-precision optical automatic dynamic focusing system, including: a data acquisition and preprocessing module 101, a focus window construction module 102, a clarity evaluation module 103, a focus search module 104 and a mechanical execution module 105;
[0052] The data acquisition and preprocessing module 101 is responsible for acquiring a focused image sequence and preprocessing the focused image sequence;
[0053] The focus window construction module 102 is responsible for selecting a focus window based on the pre-processed image;
[0054] The clarity evaluation module 103 is responsible for extracting modal components of different scales using the improved empirical mode decomposition using the focus window, selecting a preset number of modal components according to energy entropy, and weighting the selected modal components, obtaining an image clarity evaluation model based on the autoencoder network, and obtaining an estimated value of the clarity peak point of the weighted modal component under the ideal clarity evaluation curve;
[0055] The focus search module 104 is responsible for determining the search direction based on the estimated value of the retained sharpness peak point, and searching for the range of the best focus position;
[0056] The mechanical execution module 105 is responsible for controlling the motor speed, subdivision, direction and step length to drive the high-precision optical device to move to the corresponding position to continue to collect images until the image of the measured target is clearest.
[0057] It should be noted that the focusing method realizes automatic focusing by traversing different imaging positions of the lens. The focusing method collects images, selects the area where the target is located according to the constructed focus window for clarity evaluation, and determines the range of the best focus position based on the result of the clarity evaluation by the focus search algorithm, thereby driving the lens to move to the corresponding position to continue collecting images and repeat the above steps until the image of the target is clearest.
[0058] In the data acquisition and preprocessing module, the moving speed and initial acquisition position of the high-precision optical device are preset. After the image of the measured target is acquired at the initial acquisition position, the high-precision optical device is driven to move at a uniform speed based on the moving speed to acquire the image at the corresponding position; the image data acquired each time constitutes a focused image sequence, and the imaging parameters of the high-precision optical device are matched, the focused image is segmented, the segmented focused image is grayed, and the grayscale co-occurrence matrix of the image block is obtained to represent the texture characteristics; the Scharr operator is used to convolve the grayed image block to extract the edge characteristics of the image block.
[0059] Figure 2 The implementation flow chart of the focus window building module is shown;
[0060] According to an embodiment of the present invention, the focus window construction module is specifically:
[0061] S202, obtaining image blocks after the focused image is segmented and texture features and edge features corresponding to each image block, obtaining gradients of the image block in four directions in edge feature extraction of the image block, and summing the obtained gradients to generate a gradient value of the image block;
[0062] S204, in each image block, calculating the image entropy of the grayscale image of the RGB three channels, distributing the image entropy corresponding to the RGB three channels, performing weight amplitude calculation using the entropy weight method, and performing weighted processing on the image entropy to obtain the color image entropy of the image block;
[0063] S206, calculating the contrast of the image block according to the texture features of the image block, adaptively weighting the gradient value, color image entropy and contrast in each image block to obtain scoring information, and selecting a preset number of image blocks as focus windows according to the scoring information.
[0064] It should be noted that the focused image is segmented to obtain the segmented image blocks, and the cumulative gradient sum is calculated for each image block, which is used as a basis for selecting a single-area focus window. In actual scenes, when segmenting images with complex backgrounds, the accuracy of the focus window selected by a single area is low, so a multi-area focus window is set to improve the focus accuracy and stability. In edge feature extraction, the segmented image blocks are convolved using a four-directional Scharr operator as a template, and the gradients of the image blocks in four directions are calculated. The gradients in the four directions are summed to obtain the cumulative gradient value of the current image block. In addition, color separation is performed in the color image blocks, and the information features of each color channel are extracted using one-dimensional entropy, such as image The pixel value size is 5×5 pixels and its one-dimensional entropy The formula is: in represents the probability of each pixel appearing, The value range is 0-255. The entropy weight method uses information entropy to calculate the weight of each component index according to the degree of variation of each component. The greater the degree of variation in the component, the more information it contains. The greater the weight distribution, the more weight the color component information features that play a major role in the color component. The contrast is calculated based on the texture features of the image block. A wide histogram can reflect that an image has a high contrast. Conversely, a narrow histogram reflects that an image has a low contrast.
[0065] It should be noted that in order to better reflect the detail information in the image, the features of the image can be interpreted based on different scales. The EMD method decomposes nonlinear data into several IMF components and a residual, but the decomposed IMF components may contain mixed frequency components. EEMD adds white noise to alleviate the modal aliasing phenomenon, but EEMD depends on the added white noise, resulting in different decomposition results when adding different noises, affecting stability and consistency. The CEEMDAN method is introduced in the clarity evaluation module. Adaptively decomposable Gaussian white noise is added to the image data corresponding to the focus window to obtain new image data. The adaptively decomposed Gaussian white noise changes with the number of additions. The new image data is subjected to empirical mode decomposition to obtain the first mode, and the first mode is averaged to obtain the first modal component; the original focused image data is subtracted from the first modal component to obtain the first residual, and new Gaussian white noise is added to the first residual and empirical mode decomposition is performed to obtain the second modal component; the first residual is subtracted from the second modal component to obtain the second residual, and the second residual is obtained by repeated calculation. The residual, when When the residual is a monotonic function, the decomposition is terminated and several modal components of different scales are extracted; the modal components are divided into high-frequency modal components and low-frequency modal components according to the energy entropy, and a preset number of modal components are reselected from the high-frequency modal components, preferably the three high-frequency modal components with the largest energy entropy are selected, and the weights of the selected modal components are extracted using the multi-head attention mechanism, and the weights are used to weight the selected modal components to reduce the impact of noise.
[0066] According to an embodiment of the present invention, in the clarity evaluation module, an image clarity evaluation model is constructed based on an autoencoder network, specifically:
[0067] S302, retrieving and acquiring a number of auto-focusing examples based on image processing of the measured target, extracting the clarity evaluation functions used in the examples, and selecting a preset number of clarity evaluation functions according to the occurrence frequency of each clarity evaluation function;
[0068] S304, extracting the defocused-in-focused-defocused images corresponding to the instance to construct training samples and verification samples, introducing the Stacking integration strategy to select the clarity evaluation function for integrated learning, using each clarity evaluation function to independently train the input training samples, and obtaining the corresponding clarity score;
[0069] S306, stacking the clarity scores output by the base models corresponding to the clarity evaluation functions, constructing a meta-training set based on the training samples, training the meta-model with the meta-training set, and obtaining a clarity score sequence output by the meta-model;
[0070] S308, using the attention mechanism to iteratively calculate the attention weights of all clarity score sequences under the same training sample, using the attention weights to perform weighted integration to obtain the clarity score output by the Stacking integration strategy, and selecting the focused image in the training sample based on the output clarity score and verifying it using the verification sample;
[0071] S310, obtaining a clarity score sequence that meets the verification standard, fitting an ideal clarity evaluation curve according to the clarity score sequence that meets the verification standard, and using an autoencoder network to perform feature encoding on the ideal clarity evaluation curve, and training to obtain a clarity evaluation model.
[0072] It should be noted that a preset number of clarity evaluation functions are selected according to the frequency of occurrence of each clarity evaluation function. Preferably, SMD, variance, energy gradient, information entropy and Brenner function are selected as clarity evaluation functions to construct corresponding 5 base models. The Stacking integration strategy comprehensively utilizes several clarity evaluation functions for learning to improve the robustness and sensitivity of clarity evaluation. The instance image corresponding to the instance is extracted, and the disk model is used for blurring. The blur amount of the image is multiplied. The training sample is constructed by sorting according to defocus-focus-defocus. The focused image is selected as the verification sample in the defocus-focus-defocus image sequence. The training samples are used to train the 5 base models corresponding to SMD, variance, energy gradient, information entropy and Brenner function. The clarity scores of each base model for the training samples are stacked. According to the stacked clarity scores combined with the original training samples, a meta-data set is constructed to train 5 meta-models. The SMD, variance, energy gradient, information entropy and Brenner function in the meta-model training are different from those in the base model training. In addition, the attention mechanism is introduced to obtain the weight information of the meta-model, and weighted aggregation of weight information is used to achieve the comprehensive utilization of the advantages of multiple algorithms.
[0073] The goal of the clarity evaluation model based on the autoencoder network is to reconstruct the input clarity score and fully learn the characteristics of the clarity evaluation curve under ideal conditions. The clarity evaluation function under ideal conditions should be unbiased, unimodal, sensitive, stable and real-time. The weighted selected modal components are used to obtain the actual clarity score value using the Stacking integrated clarity evaluation function, and the actual clarity score value is imported into the clarity evaluation model; the actual clarity score value is encoded using an encoder in the clarity evaluation model, the encoder is composed of an input layer and a hidden layer, and the decoder is composed of an output layer and a hidden layer. The decoder calculates the estimated value of the clarity peak point under the ideal clarity evaluation curve according to the encoding characteristics, and retains the estimated value of the maximum clarity peak point by contrasting the focus windows.
[0074] It should be noted that the focus search is based on the clarity score of the image captured by the high-precision optical device. The mechanical drive module controls the lens to move and capture the image at the next position, approaching the optimal focus position, thereby achieving automatic focus. In the focus search module, the strategy based on the hill climbing method determines the next search direction by comparing the clarity scores of images at different lens positions. At the beginning of focusing, the lens search step size is set, and the clarity score is obtained while obtaining the focused image, and the adjacent positions are compared. and location The clarity rating is due to the location The clarity score is greater than the location The clarity score drives the lens from position Move to position However, in the hill climbing method, if the clarity score of the latest image obtained is less than that of the previous image, the direction needs to be changed, and interference factors such as noise will also cause the appearance of secondary peaks, affecting the focusing effect. Therefore, after obtaining the clarity score of the image obtained by the high-precision optical device at the current position, the difference between the clarity score of the current position and the estimated value of the retained maximum clarity peak point is calculated; in the neighborhood positions in the eight directions of the current position, the difference corresponding to the images of different lens positions is obtained, and the difference change amplitude is obtained by comparing the difference values at different positions, and the direction with the largest difference reduction amplitude is selected as the search direction, avoiding frequent changes in the focus search direction. During the search process, until the difference is less than the preset difference threshold, the best focus position is obtained. The above search method improves the focusing efficiency and prevents the appearance of secondary peaks from causing misfocus.
[0075] Figure 4 A flow chart of the high-precision optical automatic dynamic focusing method of the present invention is shown.
[0076] The second aspect of the present invention also provides a high-precision optical automatic dynamic focusing method, comprising the following steps:
[0077] S402, acquiring a focus image sequence collected by a high-precision optical device, preprocessing the focus image sequence, and selecting a focus window based on the preprocessed image;
[0078] S404, using the focus window to extract image feature modal components of different scales using improved empirical mode decomposition, selecting a preset number of modal components according to energy entropy, and weighting the selected modal components;
[0079] S406, constructing an image clarity evaluation model based on an autoencoder network, using the weighted modal components as model input, and obtaining estimated values of clarity peak points of different modal components under an ideal clarity evaluation curve;
[0080] S408, determining the search direction based on the estimated value of the retained clarity peak point, searching for the range of the best focus position, and driving the high-precision optical device to move to the corresponding position to continue collecting images until the image of the measured target is the clearest.
[0081] According to an embodiment of the present invention, imaging parameters such as object distance, image distance, focal length and depth of a measured target during a focusing process are obtained, the imaging parameters of the acquisition position are matched with the clarity score during the focusing process, a data set is set with the measured target, the imaging parameters, clarity score and best focus position of a historical focusing process are stored in the data set, and a database is constructed by aggregating several categories of measured targets; category information of the current measured target is obtained, a corresponding data set is retrieved based on the category information, similarity is calculated in the retrieved data set using the current imaging parameters and clarity score, historical focus data that meets a preset similarity standard is obtained, a corresponding best focus position is extracted based on the historical focus data, the obtained best focus position is used as a potential quasi-focus position, a preset range is selected based on the potential quasi-focus position with the maximum clarity score, and the best focus position is searched for.
[0082] The third aspect of the present invention also provides a computer-readable storage medium, which includes a high-precision optical automatic dynamic focusing method program. When the high-precision optical automatic dynamic focusing method program is executed by a processor, the steps of the high-precision optical automatic dynamic focusing method as described in any one of the above items are implemented.
[0083] In the several embodiments provided in the present application, it should be understood that the disclosed method can be implemented in other ways. The embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the modules can be electrical or other forms.
[0084] In addition, all functional modules in the embodiments of the present invention may be integrated into one processing module, or each module may be a separate module, or two or more modules may be integrated into one module; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0085] Those skilled in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiments; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), disks or optical disks, and other media that can store program codes.
[0086] Alternatively, if the above-mentioned integrated module of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0087] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A high-precision optical automatic dynamic focusing system, characterized in that: The system includes: a data acquisition and preprocessing module, a focus window construction module, a clarity evaluation module, a focus search module and a mechanical execution module; The data acquisition and preprocessing module is responsible for acquiring the focused image sequence and preprocessing the focused image sequence; The focus window construction module is responsible for selecting a focus window based on the preprocessed image; The clarity evaluation module is responsible for extracting modal components of different scales using the improved empirical mode decomposition using the focus window, selecting a preset number of modal components according to energy entropy, and weighting the selected modal components, obtaining an image clarity evaluation model based on the autoencoder network, and obtaining an estimated value of the clarity peak point of the weighted modal component under the ideal clarity evaluation curve; The focus search module is responsible for determining the search direction based on the estimated value of the retained clarity peak point, and searching for a range to obtain the best focus position; The mechanical execution module is responsible for driving the high-precision optical device to move to the corresponding position to continue collecting images until the image of the measured target is clearest; In the clarity evaluation module, the focus window is used to use the improved empirical mode decomposition to extract modal components of different scales, a preset number of modal components are selected according to the energy entropy, and the selected modal components are weighted, specifically: Adding adaptively decomposable Gaussian white noise to the image data corresponding to the focus window to obtain new image data, performing empirical mode decomposition on the new image data to obtain a first mode, and performing an averaging operation on the first mode to obtain a first modal component; Subtracting the first modal component from the original focused image data to obtain a first residual, adding new Gaussian white noise to the first residual and performing empirical mode decomposition to obtain a second modal component; Subtracting the second modal component from the first residual to obtain the second residual, obtaining the ith residual by repeated calculation, and when the ith residual is a monotonic function, ending the decomposition and extracting a number of modal components of different scales; The modal components are divided into high-frequency modal components and low-frequency modal components according to energy entropy, and a preset number of modal components are reselected from the high-frequency modal components. The weights of the selected modal components are extracted using a multi-head attention mechanism, and the weights are used to weight the selected modal components to reduce the impact of noise.
2. A high-precision optical automatic dynamic focusing system according to claim 1, characterized in that: In the data collection and preprocessing module, the specific data collection and preprocessing process includes the following steps: Preset a moving speed and an initial acquisition position of the high-precision optical device, and after acquiring an image of the measured target at the initial acquisition position, drive the high-precision optical device to move at a uniform speed based on the moving speed to acquire an image at the corresponding position; The image data collected each time is used to form a focused image sequence, and the imaging parameters of the high-precision optical device are matched, the focused image is segmented, the segmented focused image is grayed, and the gray-level co-occurrence matrix of the image block is obtained to represent the texture feature; The Scharr operator is used to convolve the grayed image block to extract the edge features of the image block.
3. A high-precision optical automatic dynamic focusing system according to claim 2, characterized in that: Selecting a focus window based on the preprocessed image using a focus window building module includes the following steps: Obtain image blocks after the focused image is segmented and the texture features and edge features corresponding to each image block, obtain the gradients of the image blocks in four directions in the edge feature extraction of the image blocks, and sum the obtained gradients to generate the gradient value of the image blocks; In each image block, the grayscale image of the RGB three channels is calculated to obtain the image entropy corresponding to the RGB three channels respectively, and the entropy weight method is used to perform weight amplitude, and the image entropy is weighted to obtain the color image entropy of the image block; The contrast of the image block is calculated according to the texture features of the image block, the gradient value, color image entropy and contrast are adaptively weighted in each image block to obtain scoring information, and a preset number of image blocks are selected as focus windows according to the scoring information.
4. The high-precision optical automatic dynamic focusing system according to claim 1, characterized in that: In the clarity evaluation module, an image clarity evaluation model is constructed based on an autoencoder network, including the following steps: Retrieve and obtain several auto-focusing examples based on image processing of the measured target, extract the clarity evaluation functions used in the examples, and select a preset number of clarity evaluation functions according to the appearance frequency of each clarity evaluation function; At the same time, the defocused-in-focused-defocused images corresponding to the instances are extracted to construct training samples and verification samples. The Stacking integration strategy is introduced to select the clarity evaluation functions for integrated learning. Each clarity evaluation function is used to independently train the input training samples to obtain the corresponding clarity scores. The clarity scores output by the base model corresponding to each clarity evaluation function are stacked, a meta-training set is constructed based on the training samples, and a meta-model is trained using the meta-training set to obtain a clarity score sequence output by the meta-model; The clarity score sequence is iteratively calculated using the attention mechanism to obtain the attention weights of all clarity score sequences under the same training sample, and the attention weights are used for weighted integration to obtain the clarity score output by the Stacking integration strategy, and the in-focus image in the training sample is selected based on the output clarity score and verified using the verification sample; Obtain a clarity score sequence that meets the verification standard, fit an ideal clarity evaluation curve based on the clarity score sequence that meets the verification standard, use an autoencoder network to perform feature encoding on the ideal clarity evaluation curve, and train to obtain a clarity evaluation model.
5. A high-precision optical automatic dynamic focusing system according to claim 4, characterized in that: Obtaining a measured value of the clarity score from the weighted modal components using the clarity evaluation function integrated by Stacking, and importing the measured value of the clarity score into the clarity evaluation model; The measured value of the clarity score is encoded in the clarity evaluation model, and the estimated value of the clarity peak point under the ideal clarity evaluation curve is calculated by the decoder according to the encoding characteristics, and the estimated value of the maximum clarity peak point is retained by contrast between focus windows.
6. A high-precision optical automatic dynamic focusing system according to claim 4, characterized in that: After obtaining the clarity score of the image obtained at the current position using the clarity evaluation model, searching for the range of the best focus position using the focus search module includes the following steps: Obtaining a clarity score of an image obtained by a high-precision optical device at a current position, and calculating a difference between the clarity score at the current position and an estimated value of a retained maximum clarity peak point; The difference values corresponding to the images at different lens positions are obtained, and the direction with the largest difference reduction is used as the search direction by comparing the difference values at different positions until the difference value is less than a preset difference threshold value, thereby obtaining the best focus position.
7. A high-precision optical automatic dynamic focusing method, characterized in that: A high-precision optical automatic dynamic focusing system as claimed in any one of claims 1 to 6, comprising the following steps: Acquire a focus image sequence collected by a high-precision optical device, preprocess the focus image sequence, and select a focus window based on the preprocessed image; Using the focus window to extract image feature modal components of different scales using improved empirical mode decomposition, selecting a preset number of modal components according to energy entropy, and weighting the selected modal components; An image clarity evaluation model is constructed based on an autoencoder network, and the weighted modal components are used as model input to obtain the estimated values of the clarity peak points of different modal components under the ideal clarity evaluation curve. The search direction is determined based on the estimated value of the retained clarity peak point, and the range of the best focus position is searched to drive the high-precision optical device to move to the corresponding position to continue collecting images until the image of the target is clearest.
Citation Information
Patent Citations
Automatic focusing method, device and system
CN107664899A
Imaging device and imaging method using the same
EP2166408A1