depth of field measurements
Moderators: Chris S., Pau, Beatsy, rjlittlefield, ChrisR
depth of field measurements
Greetings! It's probably been discussed here somewhere before, but I'm interested to know some recommended techniques for measuring Depth of Field, to determine focus steps to use with different studio lens/camera setups and avoid focus bracketing. I currently work over on BugGuide.net with several different Powershots and various reversed prime SLR lens configurations, with focus steps automated by CHDK scripts. To-date, my DoF technique has been strictly low-tech: trial and (mostly) error. But I’m presently trying to work up a new lens/camera/script configuration, and seeing all the detailed macro technique information on this site, makes me think there must be a better way.
Thanks!
Tim
Thanks!
Tim
-
- Posts: 7
- Joined: Mon Dec 13, 2010 10:51 pm
- Location: USA
Re: depth of field measurements
For diffraction-limited optics in visible light, such as (hopefully!) microscope objectives its easy: DOF (in microns) = (f/#)^2 = (1/2*NA)^2. This amount of defocus will transform a perfect lens with Strehl ratio ~1.0 into a just-barely-diffraction-limited lens with Strehl ratio ~0.8. For situations where aberrations come into play this DOF calculation is too strict, and you can loosen it somewhat.Tim M wrote:Greetings! It's probably been discussed here somewhere before, but I'm interested to know some recommended techniques for measuring Depth of Field, to determine focus steps to use with different studio lens/camera setups and avoid focus bracketing. I currently work over on BugGuide.net with several different Powershots and various reversed prime SLR lens configurations, with focus steps automated by CHDK scripts. To-date, my DoF technique has been strictly low-tech: trial and (mostly) error. But I’m presently trying to work up a new lens/camera/script configuration, and seeing all the detailed macro technique information on this site, makes me think there must be a better way.
Thanks!
Tim
-
- Posts: 7
- Joined: Mon Dec 13, 2010 10:51 pm
- Location: USA
Re: depth of field measurements
Note that the focus step size can be double the DOF figure I mentioned above since the maximum error will occur halfway between the steps. Also, by "f/#" I meant "effective f/#"brianc1959 wrote: For diffraction-limited optics in visible light, such as (hopefully!) microscope objectives its easy: DOF (in microns) = (f/#)^2 = (1/2*NA)^2. This amount of defocus will transform a perfect lens with Strehl ratio ~1.0 into a just-barely-diffraction-limited lens with Strehl ratio ~0.8. For situations where aberrations come into play this DOF calculation is too strict, and you can loosen it somewhat.
Thanks Brian, but I always did need help with my homework, and that feeling is quickly returning.DOF (in microns) = (f/#)^2
Specifically, the A650 Powershot I'm now working with is f4.8 wide open at 44mm (max zoom). On the end of that goes a reversed Canon 50mm f1.4 prime lens (used wide open). How do I combine those two lens apertures to calculate DoF?
Thanks for your patience,
Tim
- rjlittlefield
- Site Admin
- Posts: 24427
- Joined: Tue Aug 01, 2006 8:34 am
- Location: Richland, Washington State, USA
- Contact:
Tim, welcome aboard!
I have a lot of formulas that I'll be happy to share. However, my recommendation is to build yourself a table based on experimental data.
Each point in the table gets established like this:
I realize that this approach may seem crude compared with just plugging numbers into some formula. However, there are several problems with formulas:
It's far more reliable to measure, tabulate, and fit.
--Rik

I have a lot of formulas that I'll be happy to share. However, my recommendation is to build yourself a table based on experimental data.
Each point in the table gets established like this:
- Choose your subject size (magnification).
- Determine by test images how far you can stop down while still getting whatever sharpness you need.
- Shoot a calibration stack of a finely detailed subject, using a step size that is several times smaller than it needs to be. It's best to pick a subject with regular structure, such as a compound eye, so that focus banding will be most obvious in the next step.
- Process the calibration stack several times, doing every N'th frame, to determine the largest N that will give you a clean result with no visible focus banding.
- Compute the required actual focus step by multiplying N times the calibration step size.
I realize that this approach may seem crude compared with just plugging numbers into some formula. However, there are several problems with formulas:
- They're often quite crude compared with what the lenses actually do when you measure them.
- It's often difficult to figure out what parameter value matches the situation you care about. For example there's a big difference in acceptable CoC between an 8x10 print and a 560-pixels BugGuide image.
- It's remarkably easy to grab the wrong formula or to misapply the right one. As one example, in the formula just quoted by brianc1959, the parameter he's calling "f/#" is very different from the ones marked on your lenses or set in your camera menus.
It's far more reliable to measure, tabulate, and fit.
--Rik
-
- Posts: 7
- Joined: Mon Dec 13, 2010 10:51 pm
- Location: USA
Hi Tim:Tim M wrote:Thanks Brian, but I always did need help with my homework, and that feeling is quickly returning.DOF (in microns) = (f/#)^2
Specifically, the A650 Powershot I'm now working with is f4.8 wide open at 44mm (max zoom). On the end of that goes a reversed Canon 50mm f1.4 prime lens (used wide open). How do I combine those two lens apertures to calculate DoF?
Thanks for your patience,
Tim
Assuming you focus the 44mm lens at infinity, 50mm reversed on 44mm will give a magnification of 1:(50/44) = 1:1.1. The aperture will be limited by the rear lens, which has an entrance pupil diameter of 44/4.8 = 9.17mm. The effective f/# at the subject plane will then be 50/9.17 = f/5.5, or NA = 1/11 = 0.09. The step size would then be 2 x 5.5^2 ~60microns.
Thanks Rik,
I can see that my error in my trial-and-error approach was trying to solve this with the fewest steps, not the lot-o-steps as you recommend. Using lots of steps is easy, just means a longer script, and slightly longer shooting and stacking times. My original Powershots, A610 and A640 are a lot slower than the A650 (different processor), so I naturally tried to minimize the number of steps. But I can see I just should pile them on (and sort it out later). Since the CHDK script actually steps the focus of the Powershot built-in lens, the in-focus distance actually increases as it steps from min focus to max. I also got hung up on working along that graduated scale in programming script step sizes.
I typically shoot with the lens wide open, and after finding this wonderful site and reading all the posts on NA and resolution, I’m inclined to stay wide open as I think I’m seeing the resulting resolution limits of my optics on 3mm beetles and smaller. But that’s a post and question for another day.
Thanks again,
Tim
I can see that my error in my trial-and-error approach was trying to solve this with the fewest steps, not the lot-o-steps as you recommend. Using lots of steps is easy, just means a longer script, and slightly longer shooting and stacking times. My original Powershots, A610 and A640 are a lot slower than the A650 (different processor), so I naturally tried to minimize the number of steps. But I can see I just should pile them on (and sort it out later). Since the CHDK script actually steps the focus of the Powershot built-in lens, the in-focus distance actually increases as it steps from min focus to max. I also got hung up on working along that graduated scale in programming script step sizes.
I typically shoot with the lens wide open, and after finding this wonderful site and reading all the posts on NA and resolution, I’m inclined to stay wide open as I think I’m seeing the resulting resolution limits of my optics on 3mm beetles and smaller. But that’s a post and question for another day.
Thanks again,
Tim
-
- Posts: 7
- Joined: Mon Dec 13, 2010 10:51 pm
- Location: USA
Hi Rik:rjlittlefield wrote:Tim, welcome aboard!![]()
I realize that this approach may seem crude compared with just plugging numbers into some formula. However, there are several problems with formulas:It is certainly possible to get accurate formulas by incorporating enough aspects of the lens designs, but I doubt that you really want to get into analyzing combos of thick asymmetric lenses with aberrations.
- They're often quite crude compared with what the lenses actually do when you measure them.
- It's often difficult to figure out what parameter value matches the situation you care about. For example there's a big difference in acceptable CoC between an 8x10 print and a 560-pixels BugGuide image.
- It's remarkably easy to grab the wrong formula or to misapply the right one. As one example, in the formula just quoted by brianc1959, the parameter he's calling "f/#" is very different from the ones marked on your lenses or set in your camera menus.
It's far more reliable to measure, tabulate, and fit.
--Rik
The formula I used is very conservative in the sense that it gives the diffraction limited depth of field. This is very different than conventional COC approaches. Its true that you have to be able to figure the effective f/# in object space, but this is really not so difficult. The only potential problem I can see is you might wind up using a too-small step size if you use a poorly corrected lens. This particular formula has the advantage of being really easy to remember.
Wow! Only 60microns? I'm stepping much bigger than that. Currently running a 20 step script while shooting beetles that are under 5mm thick at best. I do have the script start at min focus (about 2 feet at max tele) and back out from there. But I finish well shy of infinity. At min focus I do see about 10.5mm wide on the sensor, which I believe is 7.6mm wide, so a bit less than 1:1.brianc1959 wrote: The step size would then be 2 x 5.5^2 ~60microns.
Off to add lots more steps to the script!

Thanks everyone,
Tim
- rjlittlefield
- Site Admin
- Posts: 24427
- Joined: Tue Aug 01, 2006 8:34 am
- Location: Richland, Washington State, USA
- Contact:
Brian, hello and welcome aboard! 
But as far as potential problems are concerned, I do see a few others with respect to Tim's problem and for other readers of photomacrography.net.
First is that the formula requires some specialized background knowledge to use properly even in the simplest case. The distinction between effective f/# in object space versus image space is so fundamental to your occupation as an lens designer that you probably don't even think about it. But I've been helping people to understand DOF for quite a few years now, and I can assure you that the formula f/# = 1/(2NA) is very frequently misunderstood.
Second is that while the formula works well when the rear focal length is known, that's only the case at ends of the range. At intermediate zooms, focal length is something that's not reported by the camera. Sure, the focal length can be computed by measuring the field size at the subject and working backwards, but that's another calculation that is not obvious and is easy to mess up.
Third is that by ignoring COC, the formula hides a powerful approach to optimizing workflow: stop down as far as you can and still get images that are sharp enough for the application. Maybe this doesn't apply in Tim's case, since in one of his posts he says that he typically shoots wide open. But his question seems rooted in the need to optimize workflow, and for some applications there's 10X or more improvement to be made by thinking about how everythihg fits together.
Fourth is that even though you answered the exact question that Tim asked, the formula doesn't really solve his problem because it gives units that don't apply directly to his setup. As explained by his followup post, his CHDK scripts work by driving internal focus of the lens. In order to use a DOF calculation in microns, he would have to back-calculate from DOF to steps of the focus motor. Offhand I have no idea how hard that is.
I'm not sure how long you've been lurking on the forum. If you're a recent newcomer, then be aware that I'm a retired R&D guy who teaches college math and has spent a lot of time trying to correct errors that were caused by using an inappropriate formula, using an appropriate formula incorrectly, or just plain blowing the calculation. So despite my fondness for math, I recommend more direct approaches whenever they're practical.
--Rik
Edit: fixed a typo about which post.

I like your formula. Unless I've blown the calculation, it's the first term of the formula listed at http://www.microscopyu.com/tutorials/java/depthoffield/, rounded by about 10% to simplify the coefficient. As you say, it's simple and easy to remember.brianc1959 wrote:The formula I used is very conservative in the sense that it gives the diffraction limited depth of field. This is very different than conventional COC approaches. Its true that you have to be able to figure the effective f/# in object space, but this is really not so difficult. The only potential problem I can see is you might wind up using a too-small step size if you use a poorly corrected lens. This particular formula has the advantage of being really easy to remember.
But as far as potential problems are concerned, I do see a few others with respect to Tim's problem and for other readers of photomacrography.net.
First is that the formula requires some specialized background knowledge to use properly even in the simplest case. The distinction between effective f/# in object space versus image space is so fundamental to your occupation as an lens designer that you probably don't even think about it. But I've been helping people to understand DOF for quite a few years now, and I can assure you that the formula f/# = 1/(2NA) is very frequently misunderstood.
Second is that while the formula works well when the rear focal length is known, that's only the case at ends of the range. At intermediate zooms, focal length is something that's not reported by the camera. Sure, the focal length can be computed by measuring the field size at the subject and working backwards, but that's another calculation that is not obvious and is easy to mess up.
Third is that by ignoring COC, the formula hides a powerful approach to optimizing workflow: stop down as far as you can and still get images that are sharp enough for the application. Maybe this doesn't apply in Tim's case, since in one of his posts he says that he typically shoots wide open. But his question seems rooted in the need to optimize workflow, and for some applications there's 10X or more improvement to be made by thinking about how everythihg fits together.
Fourth is that even though you answered the exact question that Tim asked, the formula doesn't really solve his problem because it gives units that don't apply directly to his setup. As explained by his followup post, his CHDK scripts work by driving internal focus of the lens. In order to use a DOF calculation in microns, he would have to back-calculate from DOF to steps of the focus motor. Offhand I have no idea how hard that is.
I'm not sure how long you've been lurking on the forum. If you're a recent newcomer, then be aware that I'm a retired R&D guy who teaches college math and has spent a lot of time trying to correct errors that were caused by using an inappropriate formula, using an appropriate formula incorrectly, or just plain blowing the calculation. So despite my fondness for math, I recommend more direct approaches whenever they're practical.
--Rik
Edit: fixed a typo about which post.
Last edited by rjlittlefield on Fri Dec 17, 2010 12:27 am, edited 2 times in total.
- rjlittlefield
- Site Admin
- Posts: 24427
- Joined: Tue Aug 01, 2006 8:34 am
- Location: Richland, Washington State, USA
- Contact:
Are you getting obvious focus banding? If so, then I would wonder why you are surprised. But if not, then I would wonder why the prediction does not agree with the experiment as reported.Tim M wrote:Wow! Only 60microns? I'm stepping much bigger than that. Currently running a 20 step script while shooting beetles that are under 5mm thick at best.brianc1959 wrote: The step size would then be 2 x 5.5^2 ~60microns.
This could get interesting...
--Rik
-
- Posts: 674
- Joined: Sat May 01, 2010 6:12 am
- Location: Nice, France (I'm British)
I would encourage you to write another post about focus stepping by controlling a PowerShot lens using the CHDK, which is a different and interesting approach to that usually employed by many on this site (manual or motorised movement of the camera or the subject). I'm sure it would make for interesting reading.Tim M wrote: Since the CHDK script actually steps the focus of the Powershot built-in lens, the in-focus distance actually increases as it steps from min focus to max. I also got hung up on working along that graduated scale in programming script step sizes.
-
- Posts: 674
- Joined: Sat May 01, 2010 6:12 am
- Location: Nice, France (I'm British)
-
- Posts: 7
- Joined: Mon Dec 13, 2010 10:51 pm
- Location: USA
Hi Rik:rjlittlefield wrote:Brian, hello and welcome aboard!
I like your formula. Unless I've blown the calculation, it's the first term of the formula listed at http://www.microscopyu.com/tutorials/java/depthoffield/, rounded by about 10% to simplify the coefficient. As you say, it's simple and easy to remember.
But as far as potential problems are concerned, I do see a few others with respect to Tim's problem and for other readers of photomacrography.net.
First is that the formula requires some specialized background knowledge to use properly even in the simplest case. The distinction between effective f/# in object space versus image space is so fundamental to your occupation as an lens designer that you probably don't even think about it. But I've been helping people to understand DOF for quite a few years now, and I can assure you that the formula f/# = 1/(2NA) is very frequently misunderstood.
Second is that while the formula works well when the rear focal length is known, that's only the case at ends of the range. At intermediate zooms, focal length is something that's not reported by the camera. Sure, the focal length can be computed by measuring the field size at the subject and working backwards, but that's another calculation that is not obvious and is easy to mess up.
Third is that by ignoring COC, the formula hides a powerful approach to optimizing workflow: stop down as far as you can and still get images that are sharp enough for the application. Maybe this doesn't apply in Tim's case, since in one of his posts he says that he typically shoots wide open. But his question seems rooted in the need to optimize workflow, and for some applications there's 10X or more improvement to be made by thinking about how everythihg fits together.
Fourth is that even though you answered the exact question that Tim asked, the formula doesn't really solve his problem because it gives units that don't apply directly to his setup. As explained by his followup post, his CHDK scripts work by driving internal focus of the lens. In order to use a DOF calculation in microns, he would have to back-calculate from DOF to steps of the focus motor. Offhand I have no idea how hard that is.
I'm not sure how long you've been lurking on the forum. If you're a recent newcomer, then be aware that I'm a retired R&D guy who teaches college math and has spent a lot of time trying to correct errors that were caused by using an inappropriate formula, using an appropriate formula incorrectly, or just plain blowing the calculation. So despite my fondness for math, I recommend more direct approaches whenever they're practical.
--Rik
Edit: fixed a typo about which post.
Good points - especially the part about the OP's use of internal focus within his lens, which is something that took me by surprise. You are correct about the formula - its the diffraction-limited DOF portion (first term) of the NikonU formula, where I've ignored the wavelength dependence by assuming blue-green (0.5 micron) light. I hadn't considered the sensor-related second term in the NikonU formula, but it certainly makes sense.
-
- Posts: 7
- Joined: Mon Dec 13, 2010 10:51 pm
- Location: USA
Remember that the prediction is that using diffraction-limited DOF steps will result in absolutely no visible focus banding. I admit that its a very conservative calculation since it leads to a maximum focus error of 0.25 waves.rjlittlefield wrote:Are you getting obvious focus banding? If so, then I would wonder why you are surprised. But if not, then I would wonder why the prediction does not agree with the experiment as reported.Tim M wrote:Wow! Only 60microns? I'm stepping much bigger than that. Currently running a 20 step script while shooting beetles that are under 5mm thick at best.brianc1959 wrote: The step size would then be 2 x 5.5^2 ~60microns.
This could get interesting...
--Rik
Sticking to diffraction-limited DOF steps is almost certainly overkill in the OP's case, since the optics themselves probably aren't diffraction-limited. Doubling the step size to 120 microns probably wouldn't make a detectable difference, but quadrupling it to 240 microns might start to show some subtle focus banding.