A fast automatic focusing method for a measurement microscope based on an ISP chip

By using ISP chips in the microscope for hardware-accelerated image processing and using the mountain climbing method to adjust the lens position, the problem of low efficiency of existing microscope autofocus methods is solved, and a fast and high-precision autofocus effect is achieved.

CN119200195BActive Publication Date: 2025-06-13NANJING MUMUSILI TECH CO LTD +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411380855.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-06-13
Estimated Expiration
2044-09-30

AI Technical Summary

Technical Problem

The existing microscope autofocus method has problems such as large amount of image data, low transmission efficiency, low communication efficiency and low computing efficiency, making it difficult to achieve fast and high-precision autofocus.

Method used

The fast autofocus method of measuring microscope based on ISP chip is adopted to accelerate image processing through hardware, and gradually adjust the lens position using the mountain climbing method to quickly find the best focus point of the image.

Benefits of technology

It realizes fast autofocus, improves focus speed and accuracy, avoids the impact of local blurred areas affecting the overall focus effect, and is suitable for large-scale measurement needs in industrial microscopes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119200195B_ABST
    Figure CN119200195B_ABST
Patent Text Reader

Abstract

The present invention discloses a fast automatic focusing method for a measuring microscope based on an ISP chip. The method obtains an image from a microscope camera and inputs it into the ISP chip, performs block processing on the image, calculates the sharpness value of each block respectively. For the sharpness value of each block, combined with center-biased correction and compensation processing of adjacent blocks, the corrected sharpness value is obtained. The block area with the largest sharpness value is selected, and the position of the microscope lens is gradually adjusted by using the hill-climbing method to dynamically adjust the focal length, and finally the optimal focus point is determined and the automatic focusing is completed. The method uses the ISP chip for hardware acceleration processing, greatly improving the focusing speed and accuracy, and is applicable to complex measurement environments under different lighting conditions, having a wide range of application prospects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial microscope measurement, and particularly relates to a fast automatic focusing method for a measurement microscope based on an ISP chip. Background Art

[0002] Microscope image processing has some characteristics of its own: (1) The depth of field of the microscope is relatively small; (2) Under high magnification, the exit pupil illuminance of the microscope is relatively small; (3) The field of view of the microscope is relatively small, and the image feature points are not obvious during focusing; (4) The illuminance of the microscope light source is relatively large. For ring light sources, coaxial light sources, and bottom light sources, the maximum illuminance can reach 100,000 lux. Due to the influence of the light source, the camera is prone to overexposure, resulting in the loss of image texture. When using an industrial camera to collect microscope images based on traditional methods and judging the image sharpness on the Windows side, and focusing by controlling the working distance between the optical lens and the object to be measured, there are the following disadvantages: (1) The amount of image data is large. When the image is uploaded to Windows, it occupies a large bandwidth and the transmission efficiency is low; (2) The communication between the camera (real-time system), the single-chip microcomputer (real-time system), and the Windows system (non-real-time system) is the communication between a real-time operating system and a non-real-time operating system, and the communication efficiency is relatively low; (3) Judging the image sharpness on the Windows side is carried out by means of software algorithms (without hardware acceleration), and the operation efficiency is relatively low. Summary of the Invention

[0003] Technical Objective: Aiming at the deficiencies of existing automatic focusing, the present invention discloses a fast automatic focusing method for a measurement microscope based on an ISP chip. By accelerating image processing through hardware, the hill climbing method is used to gradually adjust the lens position to quickly find the best focus point of the image, improving the focusing speed and accuracy.

[0004] Technical Solution: To achieve the above technical objective, the present invention adopts the following technical solution:

[0005] A fast automatic focusing method for a measurement microscope based on an ISP chip specifically includes the following steps:

[0006] Obtain an image from the measurement microscope camera, input it into the ISP chip, start the focusing function, and determine whether a focusing area is set. If the focusing area is not set, manually select the focusing area;

[0007] The ISP chip performs block processing on the received image according to the set focusing area. Each block is composed of several pixel points, respectively representing different areas in the image;

[0008] Calculate the sharpness value of each block separately, perform weighted processing on the sharpness value of each block, perform center bias correction according to the distance of the block from the center of the image, and perform weighted averaging on the sharpness values of adjacent blocks to complete the compensation process, obtaining the sharpness value of each block after center bias correction and compensation processing;

[0009] Select the block area with the largest sharpness value and gradually adjust the position of the measurement microscope lens using the hill climbing method to find the best focus point of the image and complete autofocus.

[0010] Preferably, the specific steps for calculating the sharpness value of each block are as follows:

[0011] The ISP chip performs high-pass filtering processing on each block separately to extract the high-frequency components in the horizontal and vertical directions of each block;

[0012] Calculate the horizontal maximum sharpness value and the vertical maximum sharpness value based on the high-frequency components in the horizontal and vertical directions of the block, and sum the two maximum sharpness values, which is set as the sharpness value of the current block;

[0013] Output the sharpness value information to complete the calculation of the sharpness value of each block.

[0014] Preferably, the calculation formula for the center bias correction weight is as follows:

[0015]

[0016] Where, W c represents the center bias correction weight, n represents the coefficient for normalizing d x and d y rule, d x represents the distance from the center of the block to the center of the image in the x-axis direction, d y represents the distance from the center of the block to the center of the image in the y-axis direction.

[0017] Preferably, the calculation formula for the sharpness value of each block is as follows:

[0018] C = βH 2 +(1 - β)*V 2

[0019] Where, C represents the sharpness of the block, β is a constant used to adjust the image sharpness threshold, H 2 represents the filtering output value in the horizontal direction, V 2 represents the filtering output value in the vertical direction.

[0020] Preferably, the specific steps for performing weighted averaging on the sharpness values of adjacent blocks to complete the compensation process are as follows:

[0021] Obtain the clarity value of the current block and determine the adjacent blocks of the current block. The adjacent blocks include four, three, or two;

[0022] Divide the clarity value of the adjacent blocks by the total number of adjacent blocks and add it to the current block to obtain the new clarity value of the current block.

[0023] Preferably, select the block area with the largest clarity value and use the hill climbing method to gradually adjust the position of the measurement microscope lens to find the best focus point of the image. The specific steps for automatic focusing are as follows:

[0024] Select the block area with the largest clarity value, determine the initial focal length position of the measurement microscope lens, and set an initial step size for lens adjustment;

[0025] Gradually adjust the lens focal length. Starting from the current focal length position, increase or decrease the focal length in turn, update the lens position, and recalculate the clarity value of the selected block area after each adjustment;

[0026] Compare the clarity values before and after adjustment, judge the change trend of the clarity value. If the clarity value after adjusting the focal length is greater than the clarity value at the previous position, continue to adjust the focal length and continue to search in the direction of increasing clarity value. If the clarity value starts to decrease, it indicates that the best focus point has been exceeded, and readjust the step size and direction;

[0027] When the clarity value is close to the maximum value, gradually reduce the step size of lens adjustment, and compare the clarity values of two consecutive adjustments. If the difference between the clarity values of two consecutive adjustment positions and the clarity value of the previous position is within the set threshold range, the current position is the best focus point. If the clarity value decreases, it indicates that the best focus point has been exceeded, and retreat to the position of the previous maximum value;

[0028] Fix the position of the measurement microscope lens at the best focus point to complete automatic focusing and output the current clearest image.

[0029] Preferably, the hill climbing method is also provided with a fallback mechanism. The fallback mechanism is specifically that if the clarity value starts to decline and has passed the maximum value, the fallback value is the probability of the maximum value position of the clarity value, and fine-tuning is performed at this position to ensure finding the best focus point.

[0030] Beneficial effects: A fast automatic focusing method for a measurement microscope based on an ISP chip provided by the present invention has the following beneficial effects:

[0031] 1. By using an ISP chip for hardware acceleration processing, the present invention can greatly shorten the time for image processing and calculation, achieving fast autofocus. This has an obvious speed advantage compared to traditional autofocus methods that rely on software algorithms, and is particularly suitable for microscope measurement scenarios that require fast focusing. At the same time, by performing block processing on the image, calculating the clarity value of each block separately, and performing weighted processing based on the distance of the block from the center of the image, the focusing accuracy is further improved. Coupled with the clarity compensation mechanism between adjacent blocks, the focusing result is more stable, avoiding the influence of local blurred areas on the overall focusing effect.

[0032] 2. The present invention uses the hill climbing method to gradually adjust the focal length of the microscope lens. The system can automatically search for the best focus point in the image, without excessive manual intervention, with convenient operation and high automation, suitable for large-scale measurement requirements in industrial microscopes. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] To more clearly illustrate the technical solutions in the embodiments of the present invention or in the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art.

[0034] Figure 1 It is the overall flowchart of the method of the present invention;

[0035] Figure 2 It is the flowchart of the focus area selection of the present invention;

[0036] Figure 3 It is the flowchart of the selection of the block area with the maximum clarity in the focus area of the present invention;

[0037] Figure 4 It is the flowchart of the block clarity calculation of the present invention;

[0038] Figure 5 It is the flowchart of the hill climbing method to find the best focus point of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0039] The following will more clearly and completely illustrate the present invention by way of a preferred embodiment in conjunction with the drawings, but the present invention is not limited to the scope of the described embodiments.

[0040] As Figure 1 shown, the present invention provides a fast autofocus method for a measurement microscope based on an ISP chip, which specifically includes the following steps:

[0041] S101. As Figure 2 shown, obtain an image from the measurement microscope camera, input it into the ISP chip, start the focusing function, and determine whether a focus area is set. If no focus area is set, manually select the focus area by drawing a box.

[0042] S102. The ISP chip performs block processing on the received image according to the set focus area. Each block consists of several pixel points, representing different areas in the image. The purpose of block processing is to locally analyze the sharpness of the image, facilitating subsequent autofocus calculations.

[0043] S103. As Figure 3 shown, calculate the sharpness value of each block respectively, perform weighted processing on the sharpness value of each block, perform center - bias correction according to the distance of the block from the center of the image, and perform weighted averaging on the sharpness values of adjacent blocks to complete the compensation process, obtaining the sharpness value of each block after center - bias correction and compensation processing.

[0044] In one embodiment, as Figure 4 shown, the specific steps for calculating the sharpness value of each block are as follows:

[0045] The ISP chip performs high - pass filtering on each block respectively, extracting the high - frequency components in the horizontal and vertical directions of each block;

[0046] Calculate the horizontal maximum sharpness value and the vertical maximum sharpness value according to the high - frequency components in the horizontal and vertical directions of the block, and sum the two maximum sharpness values, setting it as the sharpness value of the current block;

[0047] Output the sharpness value information, completing the calculation of the sharpness value of each block.

[0048] Based on the high - frequency component method used by the ISP chip to calculate the sharpness value C, that is, when the image is clearer, the amplitude of the high - frequency part is larger, and the high - frequency components can be obtained by passing the image through a high - pass filter. Four filters and brightness information are provided, the horizontal - direction filtering output values H 1 、H 2 , the vertical - direction filtering output values V 1 、V 2 , as well as the brightness Y and the high - brightness counter Hicnt. Perform horizontal - direction IIR filtering and vertical - direction FIR filtering on the original image. The calculation formula for the sharpness value of each block is as follows:

[0049] C = βH i +(1 - β)*V i

[0050] where C represents the sharpness of the block, β is a constant used to adjust the image sharpness threshold, H i represents the horizontal - direction filtering output value, V i represents the vertical - direction filtering output value, and i represents the filtering output value index.

[0051] In the present invention, the parameter β in formula C is set to 0.75, and H i and V i are the output values of the horizontal and vertical filters respectively.

[0052] Preferably, the calculation formula for the center - bias correction weight is as follows:

[0053]

[0054] where W c represents the center - bias correction weight, n represents the coefficient for normalizing d x and d y , d x represents the distance from the center of the block in the x - axis direction to the center of the image, and d y represents the distance from the center of the block in the y - axis direction to the center of the image.

[0055] In one embodiment, the specific steps for performing compensation processing by weighted - averaging the sharpness values of adjacent blocks are as follows:

[0056] Obtain the sharpness value of the current block and determine the adjacent blocks of the current block. The adjacent blocks include four, three, or two;

[0057] Divide the sharpness values of the adjacent blocks by the total number of adjacent blocks and add them to the current block to obtain the new sharpness value of the current block.

[0058] Finally, weight the sharpness value C 1 of the image to obtain the distance - weighted image sharpness value C 2 = C 1 ×W C . Select the region with the largest sharpness value as the focus region. After obtaining the focus region, perform the hill - climbing method to search for the best focus position. S104. Select the block region with the largest sharpness value and gradually adjust the position of the measurement microscope lens using the hill - climbing method to find the best focus point of the image and complete the autofocus.

[0059] In one embodiment, as Figure 5 shown, the specific steps for selecting the block region with the largest sharpness value and gradually adjusting the position of the measurement microscope lens using the hill - climbing method to find the best focus point of the image and complete the autofocus are as follows:

[0060] Select the block region with the largest sharpness value, determine the initial focal - length position of the measurement microscope lens, and set an initial step size for lens adjustment;

[0061] Gradually adjust the lens focal length. Starting from the current focal - length position, increase or decrease the focal length in turn, update the lens position, and recalculate the sharpness value of the selected block region after each adjustment;

[0062] Compare the clarity values before and after adjustment, and judge the change trend of the clarity values. If the clarity value after adjusting the focal length increases compared to the clarity value at the previous position, continue to adjust the focal length and search in the direction where the eye clarity value increases. If the clarity value starts to decrease, it indicates that the best focus point has been exceeded, and the step size and direction are readjusted;

[0063] When the clarity value is close to the maximum value, gradually reduce the step size of the lens adjustment, and compare the clarity values of two consecutive adjustments. If the difference between the clarity values of two consecutive adjustment positions and the clarity value of the previous position is within the set threshold range, the current position is the best focus point. If the clarity value decreases, it indicates that the best focus point has been exceeded, and return to the position of the previous maximum value;

[0064] Fix the position of the measurement microscope lens at the best focus point, complete the autofocus, and output the currently clearest image.

[0065] In one embodiment, the hill climbing method is further provided with a fallback mechanism, and the fallback mechanism is specifically that if the clarity value starts to decline and has passed the maximum value, the fallback value is the probability of the maximum value position of the clarity value, and fine-tuning is performed at this position to ensure finding the best focus point.

[0066] The above are only the preferred embodiments of the present invention. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A fast autofocus method for a measuring microscope based on an ISP chip, characterized in that: The specific steps include: Acquire an image from the measuring microscope camera, input it into the ISP chip, start the focus function, and determine whether to set the focus area. If the focus area is not set, manually select the focus area. The ISP chip processes the received image in blocks according to the set focus area. Each block consists of several pixels, representing different areas in the image. Calculate the clarity value of each block respectively, and perform weighted processing on the clarity value of each block, perform center bias correction according to the distance of the block from the center of the image, and perform weighted average compensation processing on the clarity values ​​of adjacent blocks to obtain the clarity value of each block after center bias correction and compensation processing; The specific steps for calculating the clarity value of each block are as follows: The ISP chip performs high-pass filtering on each block to extract the high-frequency components in the horizontal and vertical directions of each block; Calculate the maximum horizontal definition value and the maximum vertical definition value according to the high-frequency components in the horizontal and vertical directions of the block, and sum the two maximum definition values ​​to set the definition value of the current block; Output the clarity value information and complete the clarity value calculation of each block; The calculation formula of the center bias correction weight is as follows: Among them, W c represents the center bias correction weight, n represents the d x and d y Regularization coefficient, d x Indicates the distance from the center of the block to the center of the image in the x-axis direction, d y Indicates the distance from the center of the block to the center of the image in the y-axis direction; The specific steps of performing weighted average compensation on the clarity values ​​of adjacent blocks are as follows: Obtaining a definition value of a current block, and determining adjacent blocks of the current block, wherein the adjacent blocks include four, three or two; Divide the definition value of the adjacent block by the total number of adjacent blocks and add the result to the current block to obtain a new definition value of the current block; The block area with the largest clarity value is selected and the position of the measuring microscope lens is gradually adjusted using the hill climbing method to find the best focus point of the image and complete automatic focusing.

2. The method for rapid automatic focusing of a measuring microscope based on an ISP chip according to claim 1, characterized in that: The calculation formula of the clarity value of each block is as follows: C=βH2+(1-β)*V2 Among them, C represents the clarity of the block, β is a constant used to adjust the image clarity threshold, H2 represents the horizontal filtering output value, and V2 represents the vertical filtering output value.

3. The fast automatic focusing method of a measuring microscope based on an ISP chip according to claim 1, characterized in that: Select the block area with the largest clarity value and use the hill climbing method to gradually adjust the position of the measuring microscope lens to find the best focus point of the image. The specific steps to complete the autofocus are as follows: Select the block area with the largest clarity value, determine the initial focal length position of the measuring microscope lens, and set an initial step length for lens adjustment; Gradually adjust the lens focal length, starting from the current focal length position, increase or decrease the focal length in sequence, update the lens position, and recalculate the clarity value of the selected block area after each adjustment; Compare the clarity values ​​before and after adjustment to determine the change trend of the clarity values. If the clarity value after adjusting the focal length increases compared to the clarity value at the previous position, continue to adjust the focal length and continue searching in the direction where the eye clarity value increases. If the clarity value starts to decrease, it indicates that the best focus point has been exceeded, and readjust the step size and direction. When the clarity value approaches the maximum value, the lens adjustment step is gradually reduced, and the clarity values ​​of two consecutive adjustments are compared. If the difference between the clarity values ​​of two consecutive adjustment positions and the clarity value of the previous position is within the set threshold range, the current position is the best focus point. If the clarity value decreases, it indicates that the best focus point has been exceeded and the camera returns to the position of the previous maximum value. The measuring microscope lens position is fixed at the best focus point, completes automatic focus, and outputs the clearest image at the moment.

4. The method for rapid automatic focusing of a measuring microscope based on an ISP chip according to claim 3, characterized in that: The hill climbing method is also provided with a back-off mechanism. Specifically, if the clarity value starts to decrease and has passed a maximum value, the back-off mechanism returns to the maximum value position of the clarity value and performs fine-tuning at this position to ensure that the best focus point is found.

Citation Information

Patent Citations

  • Automatic focusing method for intelligent digital microscope

    CN113852761A

  • Digital microscope apparatus, focusing position searching method therefor, and program

    JP2014178474A