Good Afternoon,

I am new to the forum, and have been really getting into photography of late, with a particular passion in Macro and Micro Photography.

My background is in Science (Microbiology) and I want to start to automate some of my stacked shots whilst setting myself a challenge to do a simple VB.net program at the same time.

Anyway, my question is around calculating the depth of field each shot will take, I shoot with a Sigma 150mm Macro lense and a Nikon D5300, and I am wondering how I go about determining what the effective depth of field would be for a close up subject.

The reason I ask, is that I want to in my program set a starting point to drive a stepper motor to (that part is fine), and then using the effective depth of field, and an approximate depth of the object determine the number of photos I will need to take, and start a loop going to take the photos.

Apologies if I have asked this in the wrong forum, or it has already been asked but really what I am asking is how do I go about for a close object calculating the effective depth of field, to then determine given an object has a depth of x, how many images I would likely need to take to have the whole object in focus at the end of the focus stack merge?

Many Thanks!

## Depth of Field Calculator

**Moderators:** rjlittlefield, ChrisR, Chris S., Pau

- rjlittlefield
- Site Admin
**Posts:**23593**Joined:**Tue Aug 01, 2006 8:34 am**Location:**Richland, Washington State, USA-
**Contact:**

TravisH, welcome aboard!

Take a look at the "DOF Two Ways" spreadsheet that is described and linked at http://www.photomacrography.net/forum/v ... 606#126606.

Earlier posts in the same thread discuss a lot of the theory behind it.

Note however that with your D5300 and the Sigma 150mm macro lens, the camera body and lens probably are collaborating so that what you set and see in user interface is already the "effective f-number", properly corrected for the effects of magnification. You can check that by seeing if the wide-open f-number at closest focus is the same as it is at infinity focus. I'll bet the two numbers are different by a stop or two, in which case you can be pretty sure that it's telling you effective f-number directly.

So, for that combination, the formula in line 12 of the spreadsheet will be just a number, the same number that you set into the camera.

--Rik

Take a look at the "DOF Two Ways" spreadsheet that is described and linked at http://www.photomacrography.net/forum/v ... 606#126606.

Earlier posts in the same thread discuss a lot of the theory behind it.

Note however that with your D5300 and the Sigma 150mm macro lens, the camera body and lens probably are collaborating so that what you set and see in user interface is already the "effective f-number", properly corrected for the effects of magnification. You can check that by seeing if the wide-open f-number at closest focus is the same as it is at infinity focus. I'll bet the two numbers are different by a stop or two, in which case you can be pretty sure that it's telling you effective f-number directly.

So, for that combination, the formula in line 12 of the spreadsheet will be just a number, the same number that you set into the camera.

--Rik

Thanks for the pointer to the spreadsheet, I am hopiong you might be able to help me understand one thing. I am basically going through the objectives and calculating the values for these objectives as a bit of a rough guide I will use, of course, scales and everything will change as the image does (e.g. focus differences) but for a starting point it should be fine.

I have gone through your spreadsheet and calculated for my objectives the effective f-numbers which I have for a 11.3x/0.10 (true mag) @ 56.4, for a 26.3x/0.25 @ 52.6 and a 79x/0.65 @ 60.8

I want to now get the DOF values to give me an idea of what the DOF is for the various objectives, however the spreadsheet asks for CoC (Number of Pixels).

How do I calculate the COC in number of pixels, I know for my camera it is (apparently) 19 microns but I am not sure how that compares to pixels?

Many thanks!

For working with microscope objectives, an easier approach is to go to another of Rik's creations, DOF Estimates For Macro/Micro (depth of field, step sizes). Scroll down to the bottom of the page, table 2-C. You'll notice that all you need to know is the numerical aperture for any objective.

You can safely go with the values in that table, or use them as a starting point and experiment a bit. My own preference is for steps about 2/3 or 1/2 as large as those in the chart, but this just reflects my own balance point between small increases in final quality vs. the number of images that need to be taken and processed. Once you get into the neighborhood of appropriate increments, there's lots of room for personal judgement.

There was a time when focus stacking required a worksheet. But Rik's approach on that page is simpler, and gets you to the same place. (I'll confess to continuing to use a spreadsheet. But I got used to working with it a long before Rik published his simplified approach, and so continue. But the values in my spreadsheet closely mirror those in Rik's simpler method, after factoring the difference due to personal preference.)

--Chris

Travis, it's late night here, so this will be a too-short response. Rik's table doesn't go past NA 0.55--though I suspect Rik could add a line or two to do so, after seeing your post.TravisH wrote:Thanks for the link, do you know the DOF if it continues past 0.55, as I am curious about the 0.65 & 1.25.

I have no lenses with an NA of 0.65; but I regularly shoot at NA 0.70, which is pretty close. Here, my default increment is 0.5 microns. However, with these lenses, I sometimes make the increment 0.75 microns, or even 1.0 micron. The trade-off, with these larger increments, is a moderate loss of contrast in fine details. If my subject will rapidly wilt or otherwise degrade under photographic lighting, this loss can worth accepting in order to get the shot. Focus increments are mostly not carved in stone, but a matter of trade-offs. (The exceptions being at the ends of the continuum, when the increment is either so large as to cause focus-banding, or so small as to cause accumulation of noise that appears to the human eye as false detail.)

For NA 0.65, I'd suggest trying an increment of 0.5 microns, and experimenting a bit around it.

For NA 1.25, this must be an oil immersion objective? I've done no serious work with these--just a bit of messing around many years ago. My spreadsheet suggests 0.2 microns for this NA--but I haven't tested in this range.

Your ideal increments may well be larger than mine. My rig is automated and rapid, so taking more pictures for small gains has little downside.

Cheers,

--Chris

- rjlittlefield
- Site Admin
**Posts:**23593**Joined:**Tue Aug 01, 2006 8:34 am**Location:**Richland, Washington State, USA-
**Contact:**

Travis, the values in the table that Chris points to are computed using the formula DOF = 0.00055/NA^2.

That formula is based on the idea that DOF is proportional to whatever shift in focus produces maximum 1/4 lambda wavefront error across the aperture. The magic value 0.00055 mm happens to be the wavelength lambda that roughly corresponds to the green peak of human perception.

That idea about DOF versus wavefront error is pretty generally applicable, but the formula itself is only an approximation. It is accurate in the limit of small NA but progressively less accurate for large NA. To be honest, I forget which way it is off. There's a more accurate formula, but I would have to rummage around a while to find it.

In any case, the reason I write "pretty generally applicable" is because even the basic idea that DOF depends on 1/4 lambda wavefront error ignores other effects that become important at high magnification, especially with reflective subjects where features tend to "squirm around" laterally as focus is tweaked, even though they may still stay adequately focused. See HERE for one illustration of that effect.

The general message to all this is that DOF formulas should be taken as rough indication only, not treated as precise numbers that can be trusted to apply without testing. The lambda/NA^2 formula will give you the idea that DOF drops sharply with increasing NA, but at high magnification and large NA, it is best treated as a SWAG.

At NA 0.65, the formula predicts DOF = 1.3 microns, versus the 0.5 microns that Chris suggests as a starting point for step size. Given the "squirming" problem and the questionable accuracy of the formula, I'd follow his suggestion.

--Rik

That formula is based on the idea that DOF is proportional to whatever shift in focus produces maximum 1/4 lambda wavefront error across the aperture. The magic value 0.00055 mm happens to be the wavelength lambda that roughly corresponds to the green peak of human perception.

That idea about DOF versus wavefront error is pretty generally applicable, but the formula itself is only an approximation. It is accurate in the limit of small NA but progressively less accurate for large NA. To be honest, I forget which way it is off. There's a more accurate formula, but I would have to rummage around a while to find it.

In any case, the reason I write "pretty generally applicable" is because even the basic idea that DOF depends on 1/4 lambda wavefront error ignores other effects that become important at high magnification, especially with reflective subjects where features tend to "squirm around" laterally as focus is tweaked, even though they may still stay adequately focused. See HERE for one illustration of that effect.

The general message to all this is that DOF formulas should be taken as rough indication only, not treated as precise numbers that can be trusted to apply without testing. The lambda/NA^2 formula will give you the idea that DOF drops sharply with increasing NA, but at high magnification and large NA, it is best treated as a SWAG.

At NA 0.65, the formula predicts DOF = 1.3 microns, versus the 0.5 microns that Chris suggests as a starting point for step size. Given the "squirming" problem and the questionable accuracy of the formula, I'd follow his suggestion.

--Rik

All of this is intended as a guide only, and nothing of any great significance would be done without testing, but it does at least give me an idea of what to expect from each NA, and the table, and spreadsheet information is appreciated.

The 1.25NA is an oil immersion objective, which I have not hugely used yet although I suspect for some of the Cyanobacteria and related stuff I will likely use that so wanted to get a better idea.

At the moment my system is manual, however I have just started to get the gear together to start to automate the capture using a Trimatic driver, and Helicon remote, so that in part was where the question came from, so I can understand a rough estimate of the soft of DOF that I would be achieving from each individual image to work out how many shots I would need and so on.

Once I have the automated side up, then it is largely (e.g. for dead stuff) a case of setting it up and getting it running.

Thanks for being so responsive with this, I have had some microscopy experience but it has always been of the 'just to look at something' variety rather than having a greater understanding of what I was actually looking at, and what the DOF was, and the effective magnification rather than just objectives * eyepeices so I am on a learning curve but very much enjoying it .

If french is good for you i explain all here.

http://www.geoforum.fr/topic/31650-stac ... tre/page-2

But in O2 only.

http://www.geoforum.fr/topic/31650-stac ... tre/page-2

But in O2 only.

I work with a manfrotto 454 but uncommon system .

Objectives : BW APO PLAN 5x, Mitutoyo APO PLAN 7.5x, 10x, 20x and 50x, Seiwa APO PLAN 20x, BW APO PLAN 20x, Seiwa APO PLAN 10x, Nikon CF PLAN 50x, componon APO 40 mm, Componon 50 mm, Componon S 80 mm, Componon 105 mm, Componon 150 mm, Rodagon 135 mm.....

Objectives : BW APO PLAN 5x, Mitutoyo APO PLAN 7.5x, 10x, 20x and 50x, Seiwa APO PLAN 20x, BW APO PLAN 20x, Seiwa APO PLAN 10x, Nikon CF PLAN 50x, componon APO 40 mm, Componon 50 mm, Componon S 80 mm, Componon 105 mm, Componon 150 mm, Rodagon 135 mm.....