Research on 3-D measurement system based on handheld microscope

In this paper, a 3-D measurement system based on a simple handheld microscope and a CCD camera is exploited. Shape from Focus technology is used in desktop microscopes to measure small things for 3-D information. But desktop microscope is expensive and not easy to carry. What’s more, it could not measure the parts of the large objects. To overcome some shortages of desktop microscope and realize 3-D measurement with portability, handheld microscope is been made used of. We combined the Shape from Focus technology and handheld microscope together but existed methods for microscope cannot be applied directly in this portable device efficiently. Two main problems occurred during the application are: manual operation is not accurate enough when taking images and how to give them depth information. We proposed methods of characteristic points compare to solve the first problem, and focusing parts extraction and depth assignment to solve second problems. Take images of the object in different focal length by microscope. Use the image processing to deal with the images. Make images standard, extract the focusing parts from different images and give them correspondent depth information. Combine the different depth information with their place. We obtained the 3-D model of some target objects by method above.


Introduction
In order to realize 3-D measurement with portability, this research is proposed.Actually, in the electronics and mechanical industry, the demand of 3-D measurement technology is huge, which is used widely in the production line to help people to see whether the product meet the requests.3-D measurement which realized by microscopes can help people to measure small structures like weld point of circuit board to judge the quality or the fracture surface of the metal to analysis material attribute, etc.
Desktop microscopes are used to obtain 3-dimensional (3-D) information of small things based on Shape from Focus technology with high accuracy.They can help people see small structure and they are beneficial for industrial design.However, some electronics and mechanical components are not convenient to disassemble which means integral units are not able to be measured by desktop microscope.On the other hand, handheld microscopes have the advantage of convenience.They can measure the parts of the large objects.Therefore, we developed a 3-D image measurement system using handheld microscopes based on Shape from Focus technology [1] .
This technique is used to solve our problem of 3-D acquisition of a scene.This is a passive and monocular technique that provides a depth map of a scene based on a stack of 2-D images.And the Shape from Focus technology measurement principle is shown in Fig. 1.By changing the focal length of the microscope, we can obtain some clear platforms [2] .They represent the different characteristic in different depth of the object, which we can get the shape of the object from focus.This image position allows linking each pixel to a spatial position to obtain the depth map.We combine the information together and can get the 3-D information.
However, there are some problems in combination of 3-D measurement technology and handheld microscope.For example, the objects in different pictures have different sizes and positions because manual operation is not accurate enough and how to give each focusing parts depth information.Because handheld microscopes do not have a function of 3-D image measurement as they are and the measurement procedure used in desktop microscopes is not open to public.
We proposed methods of characteristic points compare to make images same size and position, and focusing parts extraction and depth assignment to give the depth information.The content of each chapter is organized as follows.Chapter 2: 3-D measurement system.In this chapter, we propose our measurement method in detail.Chapter 3: Testing and results.In this chapter, we test our method to get fusion images, depth information and 3-D model.Chapter 4: Conclusion and future tasks.Finally, we make a conclusion for our research and propose our later task.

System construction
The measurement system consists of a handheld microscope (including camera 1), a CCD camera (called camera 2) and a computer with an application.One example of the handheld microscope is shown in Fig. 2, the rotary knob with the handheld microscope is used to change focal length.The system construction is shown in Fig. 3. Camera 1 is used to take images of object and give them to computer.Camera 2 is used to take images of rotary knob which aim to record the magnification automatically and give them to computer.The application is used to process these images and give 3-D model.

Procedure of measurement
The procedure of measurement is shown in Fig. 4 which is divided into 5 steps.Camera 1 is used in step 1 to take images of target object.Images taken by camera 2 are used in step 4. In order to obtain the depth information automatically, many methods can be used such as adding an angle transducer.But here we used camera 2 to do that because it is easy to operate and needn't to change the structure of handheld microscope.When microscope is taking images of the object, camera 2 is used to take photos for scales of the microscope at the same time.

Step1: Focus to different platform and take images
To realize 3-D measurement by Shape from Focus technology, images taken in different focal length are needed.In this measurement, a handheld microscope is used.Take the images of the object in different focal length by rotating the rotary knob of the microscope.Charge whether ending to take images according to the shape of the object.If ending, go to the step2.If not, do this step again until require the demand which get the 2-D information.
Step2: Pre-processing In the conventional procedure of desktop microscopes, because of its high accuracy, it doesn't need to change the position of the object or calibrated on the system.But handheld microscope needs that, because manual operation is not accurate enough and the microscope would be Fig. 3 3-D measurement system construction slightly moved during the processing.And because of change of focus, the size of object is changed.Pre-processing would make them the same.
We use a method of characteristic point comparison in the pre-processing in order to solve different sizes and places of the object caused by change of focus.We choose at least three characteristic points and find their center points from the two images.Calculate the distances between the center points and the characteristic points: 1,  2 .Use equation ( 1), we can get the value of scale which means how much we should change the size.Find the relative position of characteristic points and move the images to the same place. =1 Step3: Find the focus parts and fuse them to clear image In this step, we use some knowledge of image fusion because we need to know the relative position of different parts.And get to know the different clear parts of fusion image come from which original images.Here we used the extended block selection method to fuse the image .
Combine the images with their clear parts.Our work is to extract the clear parts in each image which is decided by microscope's focus.The image has clear part when the focus is on that level and this part is more active.As a result, we need to find some function to represent the level of activity and it is important for image fusion.In this paper, we choose Space-frequency, Variance and Laplace operator.In the equation, M×N represents the size of the image, f (i, j) represents pixel value.(a)Space-frequency react the level of activity of the image.
C and R represent column and row frequency.
(b)Variance represents the discrete grey compared to average grayscale.The value of vaniance is bigger, the grey is more discrete.
̅ represents the average grayscale: (1)Dividing image into uniform blocks This method can divide the image in uniform blocks and calculate the value according to the clear function.The main point in this way is to choose the size of the blocks.In the resent years, Genetic algorithm and Differential evolution algorithm are used in dividing uniform blocks.
But uniform blocks have some problems.Sometimes, this way can't extract the border clearly.If the block is too small, the function can't judge which is clear and which is fuzzy so that it would make mistakes.If the block is too big, this way can't extract border clearly.
(2)Dividing image into different blocks For uniform blocks have problems.Some people proposed that divide the image in different blocks.Actually, we can choose blocks with big size in the area of clear or fuzzy parts.In the area of border of clear and fuzzy, we can choose blocks with small size [4] .The main point of this way is how to confirm the border.For now, the adaptive blocks and differential are used in this method, but they can't solve the problem of confirming the border.
In this paper, we divide image into uniform blocks and combine two images firstly, then use two models to find the border.If we judge that the blocks contain the border, we divided them again.By this way, we can save the time and solve the block phenomenon in a suitable way.Because the images taken by handheld microscope has the same size, we can set the size of blocks in advance.According to experiment we did before, the suitable size of block is one over sixty-four to one over thirty-two size of original image.If the size is big, the phenomenon of block would be obvious.If the size is small, the judgement function may make mistakes.The size of images in the experiment is 640×480, so we can set 20×15 for the size of blocks.It is suitable for containing enough information, and seems not big.After confirming the size of blocks, we calculate the SF of each block of two images and choose the big one to give it to fusion image.Fig. 5 shows the on dividing image in to different blocks.
We make the model of cross to scan the fusion image.The model contains five blocks, and the target block is in the middle.For example, if we find three or four blocks around the target come from the A image, but the target block is from B image, then we change the target block from B to A. Use this method to scan the fusion image once or two times, the noise could be got rid of.
Then we use two kinds of model to find the border in the fusion image.The first kind of model is two vertical blocks.second kind of model is horizontal blocks.We use these two models to scan the fusion image.In the processing of scanning, two blocks compare the grey value to the original images.If we find these two blocks come from different images, we can conclude that blocks may contain the border or have that possibility.In this situation, these two blocks would be divided to four parts and judge again.We use this method to reduce the phenomenon of block in the border.
Step4: Give each clear platform depth information For our system, the step of displacement of the focal length is moved by operator.Schematically, we are in the case shown in Fig. 6 where d is the distance we have calibrated before and ∆ is the value of the step between two acquisitions which means the depth between two focusing parts in two different images [5] .
Thus, we can determine the relationship between magnification h and the value of depth ∆ As mentioned before, in order to get the magnification h in equation ( 10), camera 2 is used to take photos for scales of the microscope.Here we used the digital identification technology to get the value in the image.Fig. 7 shows one of the images of scale taken by camera 2.
Several solutions to read the value in the images can be found in the literature [6][7] .Image grey match could be used in this part.Firstly, we use feature function to find the position of the triangle (X1) and its' nearest two numbers positions (X0, X2) which shown by red lines.Next, the number templates made before are used to scan these two positions to obtain which numbers they are( 1 ,  2 ).Image grey match is used here.Finally, use the equation.11to obtain the h which means the magnification of corresponding object image.
After that, we realize the function of different levels assignments.We use the grey level blocks of fusion image in previous step compare to four original images.If the grey level blocks are same to one of the original images.Then we give them relevant depth information.Calculate the position's depth information by equation.10.We make program to realize give different levels different depth information, and give out the position information to the 3-D software.
Step5: Make 3-D model  In this step, the text file which contains the points' information is made and transformed to the software.The software can present place of points, and the 3-D model of target object can be obtained.

Operation interface
In our application, we use C# to make the operating interface which is showed in Fig. 8.The process is divided into two steps: image fusion and modeling 3-D information.Then some details of application are described as following.After the image fusion, users can click the measurement button and input the depth parameters calculated according to the magnification value get by camera 2. Click OK and get the 3-D model.In the future, we are going to realize it automatically.

Testing and Results
The measurement device is shown in Fig. 9.The right handheld microscope is camera 1 which is used take images of target object.The size of image is 640*480 pixels.The camera 2 is used to take images of scale of camera 1.Its image size is set as 1280*1024 pixels.The camera 2 is put on the side of rotary knob and their distance is about 2cm.At that distance we can obtain images clearly.The two cameras are set to take images at same time.
In the experiment, we measured the weld point of We used the third target's fusion image and chose some characteristic points.Then use the depth information made by our device between these points and the depth information made by desktop microscope as comparison (Fig. 11).Point a is used as the basing point, and the depth between each point and point a are shown in Table .1.In this model, point c is in the top place and g is in the bottom.From the results, the 3-D models of the weld point of circuit board and the metal section have been made.They have the mostly same shapes compare with the model made by desktop microscope.But the accuracy is not well compared to the comparison value.The depth deeper, the error is smaller, because we can divide them from different images clearly.

Conclusion and future tasks
In order to realize 3-D measurement with portability and overcome some shortages of desktop microscope, a 3-D image measurement method made by handheld microscope for small object is proposed.In this process, we proposed methods of characteristic points compare and focusing parts extraction and depth assignment to solve problems caused by handheld microscope.And we use camera 2 to obtain depth information innovatively Firstly, we use the camera 1 to take images of the object in different focal length.In order to get the depth information automatically, the camera 2 is used to the take images for scales of microscope at the same time.It is a convenient way to get depth information.Next, pre-processing and image fusion are used to deal with these images.In the end, give focus platforms depth information and make 3-D model.
According to the results, we can see that this system can measure textured object and it better has color.The object can be small which size is about 1mm to 5mm.This kind of target could be measured.
In the future, we are going to develop more practical system applications according to the reaction and advice by users.

Fig. 4 Fig. 1
Fig.4 Procedure of measurement (c) Laplace operator. = ∑ ∑  2 (, ) (7)   The calculation method of  2 (, )  2 (, ) = |  2 (, )  2 | + |  2 (, )  2 | = |2(, ) − ( − 1, ) − ( + 1, )| +|2(, ) − (,  − 1) − (,  + 1)| (8) These three indicators above can reflect the extent to which image is clear.The bigger the number of clear part's indicators is, the clearer the combined image.Then, we can use one of the indicators to realize clear parts extraction.We divided the images into many blocks and calculate out the indication of activity.Choose the big value and give that block to the fusion image.The result of the clear parts extraction is based on the function of clear parts judgment and the size of blocks.Here are some methods about dividing blocks.

Fig. 5
Fig.6 Relationship between magnification and depth

Fig. 7
Fig.7 Scale (magnification) X0 X1 X2 (a) Image fusion As said above, during the process of making 3-D model, we realized the function of image fusion.Users can put in the some pictures of the same scene with different focus parts.So it can fuse the images which not taken by microscope but other kinds of camera with their clear parts.The application would give the fusion image in the dialogue and save it in the appointed file.(b) Modeling 3-D information.
Fig.10 Measurement results of target Figure.11 Results