DIY optical profilometry of blade edges

Cyrano

Gold Member
Joined
Jun 13, 2015
Messages
350
Photos taken using a microscope typically have an extremely shallow depth of focus. For example, this image of a blade apex, taken with the edge pointing up towards the microscope, shows only the very apex in focus:

i-f6cdSL6-L.jpg


If one adjusts the microscope so that the edge near the shoulder is in focus, then the apex is blurred:

i-qBLxwTm-L.jpg


One can overcome this limitation by taking a series of images at varying focus distances, then merging them in software to create a composite image with much greater depth of focus:

i-JCgZ5Jk-L.jpg

Assume one knows the difference in focus distance between images, and one also knows the horizontal scale in each image. If one measures the horizontal distance between in-focus regions in sequential images, and combines that with the known vertical change in focus between sequential images, then one has the dimensions for the adjacent and opposite sides of a right triangle. One can then easily compute the slope of the hypotenuse, which corresponds to the slope of the sample being examined.

Executing this procedure for all the images in the focus stack results in sufficient data to model the profile of the blade edge.

I did this using a series of images taken using my microscope.
  • I used Photoshop to identify the in-focus regions in each image, and to measure the locations of those regions.

  • I used Excel to plot the measurements, taking care to adjust the aspect ratio of the plot to reflect the known vertical change in focus between images. This plot had the correct shape to represent the blade edge profile, but at an arbitrary scale.

  • I superimposed the plot on an image of a blade edge profile created using cross-sectional imaging. The scale in the cross-sectional image allowed me to scale the plot to match the magnification in the cross-sectional image without changing the shape of the plot.
Considering the many sources of error in this procedure, the results came out surprisingly accurate. In this image, the blue line with square dots is the Excel plot of measurements from the stack of images; the black shape is the actual blade profile as seen in cross-section.

i-43skLzz-XL.jpg
 
Man if I did that with one of MY edges it would split peoples head open just looking at it.
Kidding, kidding

That's some cool stuff there. Thanks for posting.
I have a digital camera capable microscope but have never used that function. I just fool around. I had a little microscope as a small child and my Mom gave it away to Goodwill without asking me. I suppose she thought I had "out grown" it.
WHAAAAAT !
All that finally caught up to me a few years ago (I'm in my fifties) and I thought : "Hey, I could BUY another microscope ! Why the hell not ! ? ! ".
So now I have one but am sure not making full use of it as you, indeed, ARE Sir !
Good job !
 
Good stuff! I have a few questions and comments.

First photo: I'm impressed that you got the apex so well aligned in focus (the vertical "line"), especially after I looked your knife up and see that the edge is curved.

I take it this microscope you're using doesn't have the built-in focus stacking? Or did you just do this as an exercise?

Granted it's not by much (227.4x vs 224.2x), but how come the magnification changes between the first and second pic?
And then in the 3rd (composited) pic, it's larger than either pic, at 228.8x (is that 228.8 also a composite number, that the software calculated?). Weren't you only changing the focus between pics? Maybe it has something to do with the way focusing works and it's unavoidable that the magnification changes slightly as you move the focus?

In any case, great composite photo. I wonder if the Dino-lite microscopes that have EDOF (built-in focus stacking) have enough range to do this with a one-button operation...any idea?

re: "Assume one knows the difference in focus distance between images..."

I'm not sure I know how one would know that, to any level of precision anyway? BTW, your microscope stays at a fixed height relative to the blade edge in all the photos, right?

re: "If one measures the horizontal distance between in-focus regions in sequential images..."

I'm not entirely sure I understand what you mean or how you did that. I'm guessing you started by superimposing the first 2 sequential images, but in doing that, don't their focus fringes blur into each other in the composite photo?

The edge of the in-focus region would seem to be hard to define (even in an individual, non-composited photo) since it's sort of a tapered blurring as you get away from peak focus in all directions. But you were obviously able to do it or your results wouldn't have matched as well as they did. I'm just having a hard time imagining how/what you did for this.

Maybe if you posted the full sequence of images you took before compositing them, that might help me to understand (I don't know how many separate pics that was, so only if it's practical to post them all).

Does the software stacking in photoshop require that you have at least one image that is in focus for each step in the sequence? Or can you get away with, for example, just 3 photos (one with apex in focus, one with the heel of the bevel in focus, and one in the middle) and the software interpolates pretty well in between?
 
... I take it this microscope you're using doesn't have the built-in focus stacking? Or did you just do this as an exercise?

The latter. When my scope does EDOF, it doesn't output how it masked the individual images. (Here, "mask" means a pattern used to hide/reveal specific regions of an image.) For this exercise, I wanted to see the mask used for each image to create the composite EDOF image.

... Weren't you only changing the focus between pics? Maybe it has something to do with the way focusing works and it's unavoidable that the magnification changes slightly as you move the focus?
I was changing only the focus, with the 'scope head and the knife both immobile. With my scope, this always results in a change in magnification.

... I wonder if the Dino-lite microscopes that have EDOF (built-in focus stacking) have enough range to do this with a one-button operation...

My Dino-Lite 'scope has one-click EDOF, but it is limited to a fixed number of images, and thus a fixed depth of field to capture. This depth of field would not be sufficient to capture the entire blade edge.

My scope does allow the user manual control over the focus increments and the number of exposures used to create an EDOF. With this manual control, one can compass large depths of field.

re: "Assume one knows the difference in focus distance between images..." I'm not sure I know how one would know that, to any level of precision anyway?

I measured this using a microscope calibration target, which is a micron-scale precision ruler. With the target inclined at a known angle, I made a series of exposures along the length of the target. In each exposure, I marked the location along the target which showed the best focus, which told me how much the focus had shifted along the incline between exposures. Multiplying that value by the sine of the inclination angle gave me the vertical movement of the focal plane between exposures.

The result of this exercise was that the plane of focus of my scope shifted 99.7 microns with each click of the mouse wheel.

re: "If one measures the horizontal distance between in-focus regions in sequential images..." I'm not entirely sure I understand what you mean or how you did that ...

I loaded the sequence of images as discrete layers into Photoshop, and used Photoshop's automated focus-stacking feature to create an EDOF image. Photoshop does this by masking each individual image so as to reveal the areas of sharpest focus, while hiding all other regions of the image.

In this example, the left side shows an original micrograph with focus near the edge apex. The right side shows how Photoshop masked this image to reveal only the areas of sharpest focus:

i-Xw3SPhx-XL.jpg


This example is similar, except the micrograph had focus near the shoulder of the edge:

i-4GvqPwM-XL.jpg


For each image in the stack, using Photoshop's mask as a guide, I used human judgement to decide where, along a fixed horizontal line, the positions of sharpest focus were. The distances between these positions (marked in the diagram below by red arrows) formed the lateral components of slope:

i-GHXM3ST.jpg



Does the software stacking in photoshop require that you have at least one image that is in focus for each step in the sequence? Or can you get away with, for example, just 3 photos (one with apex in focus, one with the heel of the bevel in focus, and one in the middle) and the software interpolates pretty well in between?

Photoshop is doing no interpolation; it is only choosing which areas in each image to contribute to the EDOF composite.

In this situation, I don't see how interpolation could be done in a useful fashion. Blurred regions contain no useful information about the surface details of the sample being examined. Interpolation between in-focus regions might create an aesthetically pleasing composite, but a misleading one. The viewer might see sharp detail in all areas of the image, and believe all that detail to be accurate information about the sample, when in fact much of that detail is illusory.
 
Cyrano, thank you for the extra details. That helped clarify things for me a lot.

If it's not too much bother, could you show a photo of what the built-in EDOF in your microscope would show as the (stacked) region of good focus (maybe aim the 'scope at more of an angle to the apex rather that looking straight down, so that the side of the knife and one side of the bevel is in focus).

I'm probably going to buy a usb microscope soon and I'm wondering if the extra cost of the EDOF models of the Dino-Lite is worth it, versus getting one model below the EDOF model and putting the savings toward buying Photoshop (not to mention, spending time to learn how to use it).

PS, the depth of field is larger for less magnification, but I'm not sure of the math (depth of field calculators don't use magnification as an input, and these microscopes don't give enough info on the optical system to fill in those calculators anyway). Except to say that it's not linear. But I think the DoF at 100x should be more than 2x what the DoF is as 200x.

Example of a DoF calculator: https://www.lensation.de/calculators/
 
Last edited:
Sounds like m
Man if I did that with one of MY edges it would split peoples head open just looking at it.
Kidding, kidding

That's some cool stuff there. Thanks for posting.
I have a digital camera capable microscope but have never used that function. I just fool around. I had a little microscope as a small child and my Mom gave it away to Goodwill without asking me. I suppose she thought I had "out grown" it.
WHAAAAAT !
All that finally caught up to me a few years ago (I'm in my fifties) and I thought : "Hey, I could BUY another microscope ! Why the hell not ! ? ! ".
So now I have one but am sure not making full use of it as you, indeed, ARE Sir !
Good job !

Sounds like me although i'm pushing 70. Got a nice scope but not digital savvy enough to get photos out of it. Also it's what I would refer to as a dissecting scope and i rarely go over 50X. comes in handy looking at blades though.
 
... Got a nice scope but not digital savvy enough to get photos out of it. Also it's what I would refer to as a dissecting scope ...

Amscope makes a wide variety of digital cameras which fit into an eyepiece tube. They are controlled by software on your computer, and they're quite easy to use.
 
... If it's not too much bother, could you show a photo of what the built-in EDOF in your microscope would show as the (stacked) region of good focus ...

Here is the maximum depth of focus I could achieve using Dino-Lite's software:
i-BBsNM4M-XL.jpg


Here is what I could achieve using Photoshop:
i-CRBjc6M-XL.jpg


I've determined that Dino-Lite's focus-stacking algorithm is fine, and compares favorably with Photoshop's results when using the same source images. I believe the maximum EDOF range which can be achieved using Dino-Lite's software could be increased, but I have not yet discussed this with Dino-Lite.

I'm probably going to buy a usb microscope soon and I'm wondering if the extra cost of the EDOF models of the Dino-Lite is worth it, versus getting one model below the EDOF model and putting the savings toward buying Photoshop (not to mention, spending time to learn how to use it).

You can't buy Photoshop, you can only rent it. Adobe has moved to a subscription model, so if you want Photoshop, you must pay every month.

Photoshop will offer you a universe of image editing capabilities beyond EDOF. If you are serious about digital imaging, spending the time and money to add Photoshop to your toolkit will be a worthwhile investment. If all you want is EDOF, you needn't make the investment in Photoshop.

PS, the depth of field is larger for less magnification, but I'm not sure of the math (depth of field calculators don't use magnification as an input, and these microscopes don't give enough info on the optical system to fill in those calculators anyway) ...

I don't believe DoF calculators intended for conventional photography are at all applicable to microscopy.
 
Thanks for the extra photos Cyrano. I have Adobe Lightroom 5, which works just fine for what I use it for, but I don't think you can do the focus stacking. I'm not a fan of Adobe's subscription model. I wonder if photoshop elements, which I think is still available for purchase, can do focus stacking? Or maybe some other non-adobe software package.

re: DoF calculators, mainly what I was getting at is if you used 100x compared to 228x, the DoF would extend well beyond the bevel, and 100x is still a decent level of magnification. But to your point, aren't these digital microscopes essentially digital cameras? They probably use a camera sensor that they buy from Sony or wherever (and associated CoC value), and the lens must have a foal length and aperture, and that's all the DoF equation requires. But since they don't disclose any of those parameters, you couldn't use the DoF calculator. But maybe I'm missing something and there's something inherently non-camera-like about the microscopes?
 
Back
Top