## How to calculate DOF

Just bought that first macro lens? Post here to get helpful feedback and answers to any questions you might have.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

len
Posts: 66
Joined: Sat Dec 26, 2009 5:51 am

### How to calculate DOF

Hi,
In another post viewtopic.php?f=25&t=44178, Rik told me that 4X NA 0.1 objective has a nominal DOF of 0.055 mm.
I found an online calculator which give me another result:
http://extreme-macro.co.uk/microscope-o ... calculator NA 0.1 and Mag X4 equivalent to f/20
http://extreme-macro.co.uk/focus-stacking/#calculator F/stop 20 and 4X and APS sensor give me DOF of 0.216 mm
Why do I see such different results? What is the true value?

And another question, How can I calculate DOF of Canon APS-C sensor with 100mm lens and Raynox DC-150 ?

rjlittlefield
Posts: 23034
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

### Re: How to calculate DOF

len wrote:
Sat Oct 30, 2021 7:57 am
What is the true value?
There is no one crisply defined "true value". Focus degrades gradually as you get farther from perfect focus, so the number depends on how much blur you're willing to accept.

The formulas that I use come from a modern model that (a) accurately includes diffraction, and (b) assumes that you're pixel-peeping and are willing to tolerate only a little bit of softening in the zones between perfect focus. In that model, the formula is that DOF = 0.00055/(NA*NA). Plug in NA = 0.1 to get 0.055 mm DOF.

That calculator at extreme-macro.co.uk is based on a classic model that (a) ignores diffraction, and (b) assumes that you're willing to tolerate quite a lot of blur.

I guarantee that if you pixel-peep stacked images made with 4X NA 0.10 at 0.055 and 0.216 step sizes, you'll see a lot more blur with the larger step size.
And another question, How can I calculate DOF of Canon APS-C sensor with 100mm lens and Raynox DC-150 ?
Go to https://zerenesystems.com/cms/stacker/d ... romicrodof and use Table 2-B or the corresponding formula listed below it.

The reason this works is that adding a close-up lens does not change the effective aperture created by the rear lens.

--Rik

rjlittlefield
Posts: 23034
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

### Re: How to calculate DOF

BTW, elsewhere you asked about DOF when using the objective on different length tubes to control the magnification.

A good way to do that is to just treat the 4X NA 0.1 finite objective as if it were an ordinary lens set on f/4. (The f/4 comes from NA 0.1 at 4X, giving effective aperture f/20.)

Then at https://zerenesystems.com/cms/stacker/docs/tables/macromicrodof use Table 2-A or the formula below it.

At 4X, the formula gives 0.055 mm. That's the same as Table 2-C for NA 0.1, because all the tables use the same underlying model, just with different parameterizations.

Or, if you use less extension to give 2X, then Table 2-A says 0.079 mm, while the formula evaluates to 0.0792 .

As always, there is leeway in these numbers, depending on how much blur you're willing to tolerate.

--Rik

len
Posts: 66
Joined: Sat Dec 26, 2009 5:51 am

### Re: How to calculate DOF

rjlittlefield wrote:
Sat Oct 30, 2021 1:37 pm
A good way to do that is to just treat the 4X NA 0.1 finite objective as if it were an ordinary lens set on f/4. (The f/4 comes from NA 0.1 at 4X, giving effective aperture f/20.)
Not sure I understand the numbers.
Let's talk about the case of Objective 4X NA 0.1 on short tube = 2X magnification
According to the "NA to Effective f-stop calculator" in extreme-macro.co.uk the Effective f-stop = 10
I found on the net the equation: Nominal f-number = Effective f-stop / (1 + Magnification) so: Nominal f-stop = 10/(4+1) = 2
So now going to Table 2-A: Shouldn't I use the f/2.0 column with a magnification of 2 = DOF of 0.020 mm ?

rjlittlefield
Posts: 23034
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

### Re: How to calculate DOF

It will take me some time to explain in detail. I'll shoot for getting that done later today.

For now, let me just check one critical detail...

When you say "on short tube", are you talking about empty tube behind a finite objective, or tube lens behind an infinite objective?

--Rik

len
Posts: 66
Joined: Sat Dec 26, 2009 5:51 am

### Re: How to calculate DOF

rjlittlefield wrote:
Sun Oct 31, 2021 12:08 pm
It will take me some time to explain in detail. I'll shoot for getting that done later today.

For now, let me just check one critical detail...

When you say "on short tube", are you talking about empty tube behind a finite objective, or tube lens behind an infinite objective?

--Rik
I'm talking about a finite objective with a tube shorter than 160mm so the magnification is less than it is written on the objective. In my example x4 objective which is used to photo at x2 to achieve a larger Field of view. I hope it clarifies my question and thanks a lot for your educative replies rjlittlefield
Posts: 23034
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

### Re: How to calculate DOF

OK, so then try this explanation...

There is nothing very special about a microscope objective. It has a short focal length, and it's optimized for best image quality over a small field, but other than that, "it's just a lens".

So if we know the objective's F-number when considered as an ordinary lens, then we can use the tables for ordinary lenses.

This is where things get a little tricky. The aperture of an objective is specified in terms of its "numerical aperture" (NA), and we have to convert that to some equivalent F-number.

You have already found the calculator at http://extreme-macro.co.uk/microscope-o ... calculator , which purports to convert between NA and effective F-number. But what you don't realize, and what I do not see written on the page, is that the calculator works only when the objective is used as intended. So yes, a 4X NA 0.10 objective is effective f/20 -- when the objective is used at 4X. But when you change the tube length to get less magnification, that calculator will no longer give you the correct answer when used in the obvious way.

Instead, what we can do is to take the calculator's answer in the correct case, f/20, think of the objective as "just a lens", and calculate what the nominal F-number of that lens must be.

I assume you know that for ordinary lenses, focused only by extension, the usual formula is that effective F-number = nominal F-number * (magnification+1). (There are some other assumptions in behind that formula, but for this discussion I will ignore those.) So then, we know that 20 = nominal F-number * (4+1), and then a little algebra tells us that nominal F-number = 4. In other words, the microscope objective is just an ordinary f/4 lens, extended to give 4X magnification, and thus effective f/20.

Now that we know what the objective looks like when considered as an ordinary lens, we can calculate using the formulas for ordinary lenses.

One such calculator is http://extreme-macro.co.uk/focus-stacking/#calculator , but I do not like that one for the reasons explained earlier, to wit, it gives numbers that will produce focus banding in the final image.

A better calculation is the formula that produces Table 2-A at https://zerenesystems.com/cms/stacker/d ... romicrodof . So to take your example, if we now plug 2X and f/4 into that calculation, the answer that comes out is 0.0792 mm.

All of this is the exact same approach that I wrote earlier, just with more words to explain the rationale.

You wrote:
According to the "NA to Effective f-stop calculator" in extreme-macro.co.uk the Effective f-stop = 10
Yes, but that's a misuse of the calculator. At 2X, your 4X-NA0.1-finite-on-short-tube will actually have effective f-stop = 4*(2+1) = f/12.
Nominal f-number = Effective f-stop / (1 + Magnification) so: Nominal f-stop = 10/(4+1) = 2
That equation works when correctly applied. But you have misapplied it in two different ways. First, you have used the wrong effective f-stop, which you got from misusing the "NA to Effective f-stop calculator". Second, even using the correct effective f-stop, you have to plug in the corresponding magnification. If you had plugged in f/10 (not quite right) and 2X, then you would have gotten 10/(2+1) = 3.33, which is not quite right by the same amount. If you had some way to find the right value, effective f/12, and plugged in 2x instead of 4x, you would have gotten 12/(2+1) = 4. But there are no calculators that would have given the correct value f/12, so we have to go about the whole process as I explained above.
I found on the net the equation:
One of my great frustrations in life is the large number of times when somebody reaches into the literature, grabs a formula that may or may not apply, plugs in some numbers that may or may not be appropriate, does some arithmetic that may or not be correct, ends up getting a number that does not correspond to reality, and then very reasonably asks "what did I do wrong". Often the first thought that crosses my mind is "Where do I start?"

This is not intended to be a personal criticism. I can totally understand how you got to where you did get, and I consider this conversation to be just an apparently necessary part of the learning process. I wish I knew how to write some explanation that would quickly and concisely give a newcomer enough understanding to get everything right by themselves. But I'm not there yet, and to be honest I don't feel a lot closer than I did 5 years ago. Thank you for your patience.

--Rik

len
Posts: 66
Joined: Sat Dec 26, 2009 5:51 am

### Re: How to calculate DOF

Ok, I think I understand tell me if I'm wrong:
1. The magnification input in extreme-macro.co.uk's calculator uses the objective nominal magnification. So when we use it we always assume 160mm tube and nominal=effective magnification?
2. The magnification in the equation: Nominal f-number = Effective f-stop / (1 + magnification) use the effective magnification. i.e. Nominal f-number = Effective f-stop / (1 + effective magnification)

Since in (1) nominal=effective magnification, we can find the Nominal f-number with (2): 20 / (1+4) = 4.

rjlittlefield
Posts: 23034
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

### Re: How to calculate DOF

len wrote:
Mon Nov 01, 2021 3:47 am
1. The magnification input in extreme-macro.co.uk's calculator uses the objective nominal magnification. So when we use it we always assume 160mm tube and nominal=effective magnification?
I assume that you're talking about the "NA to f/stop Calculator".

That calculator is valid under two conditions:
1) with finite objective, only at nominal magnification
2) with infinite objective, at any magnification IF the rear lens is focused at infinity.

Looking at it a different way, the calculator is valid whenever the objective is located at its designed distance from the focused subject. With an infinite objective, you can get different magnifications by changing the rear lens focal length, without changing the objective-to-focused-subject distance, as long as the rear lens is focused at infinity. With a finite objective, changing the distance between camera and objective also changes the distance between objective and focused subject. That latter change of distance also changes the effective NA of the objective, when used at the new distance, and it's that change of effective NA that puts the calculation off.

By the way, within the optical design community the term "NA" always means what I've called here "effective NA"; that is, it describes the angles of the light rays and not an immutable property of the lens. In that community, a finite objective that is labeled "4X NA 0.1" gives some different NA when used on a shorter tube at 2X. But outside the optical design community, NA seems to be considered a property of the lens, not the use, so I have started using "effective NA" to make it more clear what's being talked about.

2. The magnification in the equation: Nominal f-number = Effective f-stop / (1 + magnification) use the effective magnification. i.e. Nominal f-number = Effective f-stop / (1 + effective magnification)
Correct. The effective f-stop has to be at the same magnification used in the formula.

--Rik

len
Posts: 66
Joined: Sat Dec 26, 2009 5:51 am

### Re: How to calculate DOF

rjlittlefield wrote:
Tue Nov 02, 2021 10:26 am
len wrote:
Mon Nov 01, 2021 3:47 am
1. The magnification input in extreme-macro.co.uk's calculator uses the objective nominal magnification. So when we use it we always assume 160mm tube and nominal=effective magnification?
I assume that you're talking about the "NA to f/stop Calculator".

That calculator is valid under two conditions:
1) with finite objective, only at nominal magnification
2) with infinite objective, at any magnification IF the rear lens is focused at infinity.

Looking at it a different way, the calculator is valid whenever the objective is located at its designed distance from the focused subject. With an infinite objective, you can get different magnifications by changing the rear lens focal length, without changing the objective-to-focused-subject distance, as long as the rear lens is focused at infinity. With a finite objective, changing the distance between camera and objective also changes the distance between objective and focused subject. That latter change of distance also changes the effective NA of the objective, when used at the new distance, and it's that change of effective NA that puts the calculation off.

By the way, within the optical design community the term "NA" always means what I've called here "effective NA"; that is, it describes the angles of the light rays and not an immutable property of the lens. In that community, a finite objective that is labeled "4X NA 0.1" gives some different NA when used on a shorter tube at 2X. But outside the optical design community, NA seems to be considered a property of the lens, not the use, so I have started using "effective NA" to make it more clear what's being talked about.

2. The magnification in the equation: Nominal f-number = Effective f-stop / (1 + magnification) use the effective magnification. i.e. Nominal f-number = Effective f-stop / (1 + effective magnification)
Correct. The effective f-stop has to be at the same magnification used in the formula.

--Rik
Using the words "effective" and "nominal" in the equations variable names is super important since it's so easy for a newbie like me to confuse about it.
Thanks very much for the educational and comprehensive explanation. I really appreciate the effort.

Best regards,
Len