Hi all,

In my program evolution Macrophotography I'm thinking of doing a series of calculations similar to those performed for calculators of Deep of Field (DOF).

As I have understood, for the calculation the following is required:

1. - Circle of Confusion (CC). It is a model that depends costante of our camera. As the application runs reflex cameras from Canon, Nikon and Olympus, I have only to identify the camera to attach to a table that has that value. This is not a problem.

2. - F-stop (F). You can tell the program which aims f value invested, the microscope objective or lens macro we are using.

3. - Focus. I have no clear meaning, but ...

4. - Focal distance (FD). I have no clear how to calculate too, but ...

But I think for the calculation in macro photography, is not required to take into account neither the distance nor the focal distance approach. Therefore must be applied this formula:

DOF = FD * CC * ((M +1) / (M elev 2)) this is for the beginning

And the double for the end.

I'm a little confused with these calculations, see if someone experienced in these formulas can clarify.

Thank you very much,

Oscar.

## How to calculate DOF to stacking must better...

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

The link is dead now, but if you PM me your email address, I can send it to you. There may already be an answer to your question in the thread. Several other forum members have also shared spreadsheets that may help you.

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

Well, I'm happy to share with you some words I recently wrote in response to zerenesystems.com support question.

--Rik

**Question:**Would you know if there is simple math to figure out the number of steps and slices per inch for a given depth? (I know you have a tutorial on steps and slices using a book page; maybe I need to give that a try.)

**Answer...**The bottom line is that if you want to compute DOF for a system in which the user provides the camera and optics, you had better be prepared to ask the user a lot of questions about what they're using and how they have it set up, then choose the proper formula from among a half dozen that are each appropriate in some different situation, and provide some nice adjustable scale factor that the user can set to adjust the calculation after the basic formula gives a result that does not work well for them.For any one lens in a limited range of low magnifications, there's a pretty simple and reasonably accurate approximation:

DOF varies as 1/(magnification squared), and

DOF varies in direct proportion to f-number.

So, if you know the required step size at one magnification and f-number, you can adjust the DOF step at a nearby magnification and a different f-number using

DOF2 = DOF1 * (m1/m2)^2 * (f2/f1)

In other words, f/22 could reasonably be expected to give 1.375 times as much DOF as f/16 [calculated as 22/16=1.375], and m=0.5 would be expected to give 0.36 as much DOF as m=0.3 [calculated as (0.3/0.5)^2=0.36 ].

Beyond that things get ugly.

The reason that page-of-text tutorial exists is that I'm not very happy with any of the math. Let me walk through some and you'll see why.

From geometric optics, there is a standard formula for macro depth of field that says

TDF = 2*C*N*(m+1)/(m*m)

where TDF is total depth of field (both sides of the focal plane), C is the diameter of the circle of confusion, N is the infinity-focus f-number, and m is the magnification.

If you have a copy of Lefkowitz, "The Manual of Close-up Photography", you find this and other related formulas in Table B-2 on page 258. Instead of N, Lefkowitz uses the symbol Fr, which he describes as the "relative (marked) aperture".

The above formula applies for a symmetric lens that is focused by extension.

For a non-symmetric lens, you also have to know something called the "Pupillary Magnification Factor". This name is often shortened to just "pupil factor" or "pupil ratio" because the number is computed as the ratio of diameters of the entrance and exit pupils.

Lefkowitz defines the pupillary magnification factor P as P = exit/entrance. (Other authors define it as entrance/exit, and use correspondingly different formulas.) To compute TDF for a non-symmetric lens that is focused by extension, you have to account for P. Using Lefkowitz's notation,

TDF = 2*C*Fr*((m+P)/(P*m*m))

Well, that's a lot harder to work with, and there's still a problem: modern macro lenses often get shorter as they focus closer, so despite the markings on the lens it's not really clear what f-number should be put into the equation at macro focusing distances. With Nikon bodies and modern lenses, there's the additional wrinkle that the setting may actually be in units of "effective aperture", already corrected for magnification and (in concept) able to plug in directly to replace N*(m+1) in the first equation or Fr*((m+P)/P) in the second. Between Nikon and Canon, this latter issue alone can change the meaning of "f/11" by a factor of 2 at 1:1 reproduction.

Then there's the matter of C, the circle of confusion. Historically that's been a value around 1/1000 of the frame diagonal, or maybe 1/1500 if you're a picky printer. But in these modern days of pixel-peeping on digital displays, some viewers may see degradation if it's as little as say 2 pixels. On your D800, that would be 1/3000 of frame width.

Finally, for AF motor focusing there are the issues that a) the proper formulas would have a completely different form, b) you usually have no clue what the units would be, and c) there's not even a guarantee that the units would be the same from lens to lens.

I have a degree in math, and from my standpoint the math here is not very useful. You have to know too much in order to apply it correctly. Then to be sure that you _have_ applied it correctly, you have to see whether the computed step size actually does provide a result image that is free of visible focus banding.

So as a matter of practice, what I recommend is to use the math (if at all) only to get a ballpark value, then either 1) go enough smaller to be safe, or 2) experiment with various step sizes to see what you really need. Once you know the required step size at three or more different magnifications, it's safe and effective to interpolate for the same optics using a smooth curve.

Periodically I think about putting a DOF calculator into Zerene Stacker. But then I think about Canon vs Nikon. (Actually Nikon does it two different ways depending on what body & lens.) I think about magnification by extension versus closeup lenses, and about reversed enlarger lenses on bellows, and microscope objectives on tube lenses, and what happens when you stick in a teleconverter, and reversed combos (now was that stopped in the front or in the rear?), and...

This process goes on for a while and then I throw up my hands and give the advice to just measure what you need in one case, then do local adjustment based on magnification and f-number.

--Rik

PMR, diffraction & probably more screw up the equation but I'm not best qualified to "go there".

(Not sure what you mean about "double for the end"? Certainly the front and rear focused depths are only considered equal at macro distances, but I can't remember where they become significantly different.

It would certainly be great if some of these parameters could be incorporated into an automatic stepper. The NA of a microscope objective would be the input figure for those, of course. (DOFs are quoted on eg Nikon and Mitutoyo websites, though they disagree a bit).

The thing I grapple with more, is getting the C of C right, for the size of the reproduction of the picture. For example if I only need 1000 pixels wide but a deep stack, I know I want a smaller aperture, because I don't need ultimate resolution from the lens and do want to minimize the number of shots. Therefore I'd like to be able to set the C of C , perhaps in terms of pixel-width multiples.

Edited for typos - I'd fallen asleep, so on waking just hit "send" without thought..

(Not sure what you mean about "double for the end"? Certainly the front and rear focused depths are only considered equal at macro distances, but I can't remember where they become significantly different.

It would certainly be great if some of these parameters could be incorporated into an automatic stepper. The NA of a microscope objective would be the input figure for those, of course. (DOFs are quoted on eg Nikon and Mitutoyo websites, though they disagree a bit).

The thing I grapple with more, is getting the C of C right, for the size of the reproduction of the picture. For example if I only need 1000 pixels wide but a deep stack, I know I want a smaller aperture, because I don't need ultimate resolution from the lens and do want to minimize the number of shots. Therefore I'd like to be able to set the C of C , perhaps in terms of pixel-width multiples.

Edited for typos - I'd fallen asleep, so on waking just hit "send" without thought..

Last edited by ChrisR on Thu Mar 14, 2013 2:04 am, edited 1 time in total.

I think the best is to have an Excel chart type in the app so that the user will fill in the data as Magnification, FOV, slices according to the experience of each so you can reference it at any time.

Regards, Oscar.

P.D.: Let's see if I fall asleep at 3:25 that are already in Spain!!!

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

More than a bit. The ones I've seen disagree by at least a factor of 2.ChrisR wrote:DOFs are quoted on eg Nikon and Mitutoyo websites, though they disagree a bit

http://www.microscopyu.com/tutorials/ja ... index.html says that

d_tot = lambda*n/NA^2 + (n/(M*NA))*e

Mitutoyo Catalog Ne. E4191-378, page 30 (http://www.krebsmicro.com/MitutoyoE4191-378.pdf ) says

+-DOF = lambda/(2*NA^2) [implicitly in air]

The basic disagreement in the formulas is only that Mitutoyo quotes maximum distance from perfect focus (single-sided DOF), while Nikon quotes distance between front and rear limits (double-sided DOF).

In addition Nikon gives allowance for finite resolution of the camera sensor, while Mitutoyo assumes a perfect sensor.

--Rik

Ok, i think to calculate the DOF with Lefkowitz formula like this:

Distance = 2*CoC*f*((m+1)/(m*m))

CoC is a constant. Because i know the camera parameters, i can use this.

f is the Aberture of the lens.

m is the magnification.

For example, my Canon lens inverted have 4x magnification.

I ajust my lens to f5,6 before to inverted. Lock in this.

And my CoC for my EOS 600D are 0,019

If i apply the formula the result are:

Distance = 2 * 0,019 * 5,6 * ((4+1)/4*4) = 2*0,019*5,6*(5/16)=2*0,019*5,6*0,3125=0,0665mm displacement between photos.

In this case i think is important to overlap 25% between photos. The result are 0,049875mm, round to 0,05mm

In my Foucus Rail i have 0,005mm of resolution per step of my stepper motor. In this case i need 10 steps = 0,05mm displacement to take another photo.

This is valid? This is valid too for microscope lens?

I think for microscope lens to use conversion between f and NA. Any people know the formula for this?

I know, this calculations isen't for all the case but if it is for the majority of cases, i think.

Regards, Oscar.

Distance = 2*CoC*f*((m+1)/(m*m))

CoC is a constant. Because i know the camera parameters, i can use this.

f is the Aberture of the lens.

m is the magnification.

For example, my Canon lens inverted have 4x magnification.

I ajust my lens to f5,6 before to inverted. Lock in this.

And my CoC for my EOS 600D are 0,019

If i apply the formula the result are:

Distance = 2 * 0,019 * 5,6 * ((4+1)/4*4) = 2*0,019*5,6*(5/16)=2*0,019*5,6*0,3125=0,0665mm displacement between photos.

In this case i think is important to overlap 25% between photos. The result are 0,049875mm, round to 0,05mm

In my Foucus Rail i have 0,005mm of resolution per step of my stepper motor. In this case i need 10 steps = 0,05mm displacement to take another photo.

This is valid? This is valid too for microscope lens?

I think for microscope lens to use conversion between f and NA. Any people know the formula for this?

I know, this calculations isen't for all the case but if it is for the majority of cases, i think.

Regards, Oscar.

Collection http://www.flickr.com/photos/23556887@N05/

Photography http://macrorail.com/GaleriaEng.php

Personal http://TuPlaneta.es

Photography http://macrorail.com/GaleriaEng.php

Personal http://TuPlaneta.es

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

The calculation appears to be correct.ofarcis wrote:This is valid?

For your purposes, use f=1/(2*NA).This is valid too for microscope lens?

I think for microscope lens to use conversion between f and NA. Any people know the formula for this?

Example #1: treat a 10X NA 0.25 objective as if it were f/2 (1/(2*0.25)=2). Then the Lefkowitz formula will calculate DOF = 2*0.019mm*2*(10+1)/(10*10) = 0.00836 mm. The actual DOF is a little more than that: 0.0088 mm using the 1/4 lambda criterion (0.00055/NA^2).

Example #2: treat a 4X NA 0.10 objective as if it were f/5 (1/(2*0.10)=5). The formula calculates 2*0.019mm*5*(4+1)/(4*4) = 0.059375 mm. In this case the actual DOF may be a little smaller: 0.055 mm by 1/4 lambda criterion.

Example #3: treat a 20X NA 0.40 objective as if it were f/1.25 (1/(2*0.40)=1.25). The formula calculates 2*0.019mm*1.25*(20+1)/(20*20) = .002494 mm. The DOF by 1/4 lambda is 0.003438 mm.

Example #4: treat a 50X NA 0.55 objective as if it were f/0.909 . The formula calculates =2*0.019mm*0.909*(50+1)/(50*50)=0.000705 mm; DOF by 1/4 lambda is 0.001818 mm.

--Rik

Ok, thanks Rik.

Regards, Oscar.

Regards, Oscar.

Collection http://www.flickr.com/photos/23556887@N05/

Photography http://macrorail.com/GaleriaEng.php

Personal http://TuPlaneta.es

Photography http://macrorail.com/GaleriaEng.php

Personal http://TuPlaneta.es