Relationship Between Magnification vs Depth of Field

Have questions about the equipment used for macro- or micro- photography? Post those questions in this forum.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

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

Re: Relationship Between Magnification vs Depth of Field

Post by rjlittlefield »

mjkzz wrote:
Fri Dec 02, 2022 9:05 pm
my niece emailed me this, just to make it "official" :D

Image
I know this formula. It is the one given by Nikon at https://www.microscopyu.com/microscopy-basics/depth-of-field-and-depth-of-focus .

This is an approximate formula that works OK when the image capture and display system is not able to fully resolve the optical image produced by the objective. When the image capture and display is able to fully resolve the optical image, then effectively e goes to zero, and the dependence on magnification disappears. Using a non-zero value for e assumes that your system is sensor limited.

Compare that situation with the one discussed below.

--Rik

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

Re: Relationship Between Magnification vs Depth of Field

Post by rjlittlefield »

mjkzz wrote:
Fri Dec 02, 2022 8:40 pm
Take a concrete example, using your logic, lets say we have an infinite objective with nominal magnification of 50, and NA of 0.5, and requires a tube lens of 200mm focal length. At 50x and NA of 0.5, I am pretty sure the diffraction term dominates the determination of DOF. However, lets say the tube lens is a perfect zoom lens focused to infinity, we change its focal length to 199mm, then it would have magnification of 49.75. So, people might ask, what happens to the DOF at two different zooms? using the first order derivative, the diffraction component stays the same and get subtracted out, but the change should be roughly proportional to 1/M^2, and M=50, that is only 0.04% change. Small, but it is there and it is solely due to change of geometry formed by light beams [edit] as magnification itself is a unitless geometric parameter[/edit]
Sure, I like concrete examples.

So let's take your starting point, and make it even more concrete by saying that we're using my Canon R7 camera, with pixel size 3.204 microns (22.3 mm / 6960 pixels).

Then doing the analysis stepwise...

The effective f-number is Feff = m/(2*NA) = 50/(2*0.5) = f/50.

The diffraction cutoff frequency nu_0 is 1/(lambda*f#). Using lambda = 0.00055 mm green light, that gives nu_0 = 1/(0.00055*50) = 36.36 cycles/mm on sensor, or 0.0275 mm/cycle on sensor.

Doing the division, we see that there are 0.0275/0.003204 = 8.58 pixels per cycle. This is at the cutoff frequency, where MTF=0, so all resolvable details will be at even longer lengths, with more pixels per cycle.

As you know, the Nyquist sampling criterion requires only 2 pixels per cycle to allow exactly recovering the signal.

At 50X NA 0.5, this sensor has several times more resolution than is needed to capture all the information in the optical image.

Dropping the magnification to 49.75X does not change that situation.

So, by changing the magnification, you've made no change at all in the information captured. Both images resolve the same details at same out-of-focus distance. Same details at same out-of-focus distance gives same DOF.



I'm worried that this explanation is again TL;DR for you, so I'll summarize: you have chosen to work with math formulas that do not accurately model the situation being discussed. Garbage in, garbage out.

--Rik

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

OK, Rik, I did read through your posts, in fact every post :D

Now, if you are dismissing formula based on its inherent flaws, sure, garbage in and garbage out, math can not help that. No need to read on.

But if you are dismissing it due to the fact it is rather a continuous model and we are dealing with discrete capturing, as well as viewing, devices, then please do. In this case there will be a mapping function for that formula to work.

Hahahaha, I was trying to get you think about the fact that diffraction does not play any role with that 50x 0.5NA, zoomed at 199mm concrete example, yet, it plays right into your hand with discretion. But it also proves one point I keep saying: if it is not observable, it does not mean it is not there, it is there all the time, and when it is observable, its effect will be governed by that that continuous equation.

So, let zoom it down to 100mm, or better yet, lets take a concrete example of something people here can relate to: zooming down a Mitutoyo 5x 0.14NA to 100mm, I think the change is significant enough to be observed with a typical 24MP full frame camera in this concrete example. So here are some questions:

1. When zoomed down to 100mm, does DOF change? My answer is yes, DOF will increase according to that equation because magnification at this point is 2.5x, and it is inversely affecting the DOF.

2. Does diffraction play any role if DOF changes? My answer is no, zero, nada. Because DOF limited by diffraction is constant, it is not changing even we are zooming in and out.

3. Does geometry play any role if DOF changes? My answer is yet and the change of DOF (or in another word, same mitty used at different zoom) is solely because of change of geometry -- magnification is a dimensionless geometric parameter and it is changing.

4. What is relationship between magnification and DOF when comparing the same mitty at different zooms, hence different magnification? Inversely, even though there is another part due to diffraction, but that part is NOT being affected by zooming.

Whether something is observable or not, due to discrete capturing or viewing, the governing guide is in play by the continuous equation. Think of it another way, if the capturing device is a full frame 640x480 camera, changing zoom by little on that 5x mitty, with your way of thinking, the captured information is the same, thus no effect on DOF, but that is wrong, because if you change to a 61MP camera, it might or will be observable.

You are still thinking in determination of DOF at some extreme situations where diffraction become so dominant rendering that equation from MicroscopeU flawed. But even that, geometry will be in play as long as you use the word magnification and it [edit] change of DOF [/edit] will be only contributing factor because diffraction effect will be constant, and whether the end result due to geometry can be observed or not, it is there.

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

Another way to think about that 50x 0.5NA zoomed at 199mm is this: sure you might not observe the change, but if you continue to zoom down, at some point it will be observable. What does this mean? It means as long as you use the word magnification, the magnification is discretized in overall capturing and viewing system due to diffraction. But as soon as you are able to observe it, it is the geometry that is causing it (to be observed) and thus, geometry is the only factor.

[added]And as soon as the change of DOF is observable, those geometric formulas (fxsolver and Stanford) will take effect for the part caused by geometry, that is how magnification is calculated -- ratio of two dimensions governed by light path formation, they have nothing to do with diffraction, ie, independent of diffraction[/added]

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

Re: Relationship Between Magnification vs Depth of Field

Post by rjlittlefield »

I do not object to either continuous models or differentiating formulas.

But I do object to differentiating incorrect formulas and then claiming that the result means anything significant.

At this point, let me happily agree with your claim that reducing the magnification does increase DOF, and that this happens even for differentially small changes under all conditions.

See, we agree!

But then I'll ask "and by how much does it increase DOF, and why?", and I'll press for an answer that correctly reflects the imaging process.

In the thread that prompted this discussion, I answered another fellow's question by writing:
Changing the focal length of the tube lens has no effect on the subject-side NA of the optics. So, if you are in the regime where the imaging system is limited by diffraction then there is no effect on the DOF because diffraction-limited DOF is determined by NA. However, if you reduce the magnification enough to move into the regime where the imaging system is limited by sensor resolution, then you effectively allow a larger acceptable circle of confusion on the subject side and that does increase the DOF even at constant NA.
The part about "no effect" was approximate.

It would have been more accurate, but I think less clear, to say that in the diffraction limited regime the change in DOF is due only to minor effects of sampling density and is too small to matter.

Differentiating a correct formula would yield a correct result.

But in the diffraction-limited regime, correct closed-form symbolic formulas don't even exist. Computing an accurate answer requires numerically evaluating some ugly integrals to determine the MTF of the defocused lens, then modifying that optical MTF by the effects of digital sampling to get a system MTF, then interpreting that system MTF to produce a DOF number.

Revisiting the case of our 50X NA 0.5 objective on my Canon R7 camera, at 50X we're sampling the optical image at 8.58 pixels per cycle at the cutoff frequency. That means over 16 pixels per cycle at 50% MTF, which is the point where people usually measure sharpness and thus DOF.

For comparison, let's reduce the magnification by quite a lot, say down to 25X. That still means over 8 pixels per cycle at 50% MTF.

Now, DOF depends on what you can see. So whatever difference there is between 25X and 50X, it's due to the fact that 16 pixels per cycle gives a little more accurate sampling than 8 pixels per cycle does.

Offhand I don't know exactly the effect of 8 versus 16 pixels per cycle. But I will confidently predict that it's miniscule -- far smaller than the 15% difference in DOF that is predicted by Nikon's formula, and quite possibly too small to even be experimentally confirmed with any accuracy.

So, by differentiating Nikon's formula, you've gotten a garbage result.

If you now realize that it's a garbage result, then great.

Read on, for more info.

--Rik

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

Re: Relationship Between Magnification vs Depth of Field

Post by rjlittlefield »

Peter, near the end of this post, I'm going to give you a reference to study.

But first, I think it may help if I tell a story.

About 10 years ago, I was in pretty much the same state that you are today.

I knew the standard formulas for depth of field and I understood how they derived from geometric optics. I also knew about diffraction as it affected perfectly focused images.

But I did not understood how diffraction affected out of focus images. It seemed clear that geometric blur and diffraction blur must add together somehow, but I did not understand the details of that "adding".

There was nobody I could find to ask, so instead I dug into the literature.

What I discovered was that the physics had been analyzed in gory detail back in 1955, in a paper by H.H.Hopkins titled "The frequency response of a defocused optical system".

As presented in the paper, the main result of Hopkin's research was to validate that the geometric model and the full wave optics model made similar predictions in situations of interest at that time, which turned out to mean far away from perfect focus.

However, the mathematics derived in the paper is equally valid for systems that are close to perfect focus.

In particular the math is valid in what I call the "transition regime" where both diffraction and geometry make significant contributions.

regimes.jpg

The transition regime is very important for our purposes because it is where optimal settings for focus stacking are located.

So, having good mathematics in hand from Hopkins, I used that math, in combination with a lot of optical testing, to thoroughly investigate what happens in the transition regime.

After a lot of work -- literally hundreds of hours of study -- I came to understand in detail that geometric blur and diffraction blur do not add together in any of the ways that people commonly imagine.

This fact is well illustrated by looking at MTF curves. In the transition region, the geometric blur model predicts that MTF falls quickly to zero and changing focus moves the cutoff frequency. But what actually happens is that the MTF curve slopes gradually downward, and changing focus merely causes the curve to sag more or less, with no change to the cutoff frequency.

Here is an animation to make the point. The bold black line is what actually happens, and the red line is the erroneous prediction that is made by the geometric optics model.
DefocusExperimentMontageImagesAnimation.gif

This discrepancy means that none of the standard formulas are working like their users think they do.

OK, then what makes the formulas work well enough to be traditional?

As far as I can tell, that's because:
  • They're based on very intuitive concepts.
  • Their curves have roughly the right shape, so by suitable scaling of one parameter they can be made to give a good answer even in regimes where the model is fundamentally wrong.
  • The formulas normally get used in a sort of closed loop that ends up adjusting the scaling parameter so the number computed by the formula plays well with what the user sees in the images.
So, when used in the usual way the standard formulas work well enough, especially if you scale the COC to match the Airy disk when that gets big.

But things can go off the rails when the formulas are applied in unusual ways or extrapolated to inappropriate regimes, and in my opinion that's what is causing the current discussion.

Now for that reference I promised...

The evolution of my understanding about DOF formulas is discussed in some detail at https://www.photomacrography.net/forum/viewtopic.php?t=23751 and in the links contained therein.

I suggest to go study that material. It won't be an easy read, but the process should be a lot shorter than the hundreds of hours that I put into developing it.


After you have thoroughly read and understood what I've written, perhaps we can have a more productive discussion.

--Rik

chris_ma
Posts: 571
Joined: Fri Mar 22, 2019 2:23 pm
Location: Germany

Re: Relationship Between Magnification vs Depth of Field

Post by chris_ma »

I can't add much productive to this discussion, but I wanted to thank Rik for sharing his research and findings. while I don't quite understand the details it's fun to read about some of the concepts.

Having spent quite a bit of time digging into quantum electrodynamics this summer, I could imagine one of the reasons why it is difficult to to get a formula right on cases with diffraction might be because the wave theory just can't accurately describe the situation anymore and we'd have to use the model from quantum electrodynamics instead (which would be even more complex, but very accurate :).
chris

Sym P. le
Posts: 249
Joined: Thu Jul 04, 2019 9:53 pm
Location: BC

Re: Relationship Between Magnification vs Depth of Field

Post by Sym P. le »

Having gone quiet, I also thank Rik for sharing his expertise. It will take some time for me to absorb this info. I also need to brush up on the implications of aperture settings on my gimmicky lens stacks and infinity objective applications.

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

Rik,

Glad we agree. Now it is how we agree, right? :D
But then I'll ask "and by how much does it increase DOF, and why?", and I'll press for an answer that correctly reflects the imaging process.
So, by differentiating Nikon's formula, you've gotten a garbage result.
If you now realize that it's a garbage result, then great.
How much?: After differentiating Nikon's formula, dDOF/dM = -n * e / ((M^2) * NA), lets pick the slope at middle, ie, M at (50+25)/2 = 37.5, n = 1.0 and use that as approximation of slope, we get: dDOF / dM = -1.0 * e / (37.5*37.5*0.5) = 0.001422*e. So dDOF = 0.001422 * dM * e = 0.001422 * 25 * e = 0.03556*e

If we pick e = 14um, the difference in DOF is roughly 0.498um (actually 0.56um if you use brute force), yeap, that is quite a lot at 25x and 50x.
After you have thoroughly read and understood what I've written, perhaps we can have a more productive discussion.
Whoooo! That looks like a lot of reading :D

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

I suggest to go study that material. It won't be an easy read, but the process should be a lot shorter than the hundreds of hours that I put into developing it.
Darn it, that is a lot of reading, since you have done a lot of work on this, I will just quote you in your note in the PDF :D
. . .so equation 31 is further substantiation of Hopkins' viewpoint that ray optics is close enough for many purposes.
And let me also tell a story: all of my findings originated from effort to find a guideline for photogrammetry where magnification is currently well under 5x, most of time under 1x. I do not memorize formulas, I usually just scan through them, the Nikon version seems generic for both objectives and normal lenses and it contains both diffraction component and geometric component. As how they derived it, I do not know and I think I can just take stuff from Nikon for granted. And my experiments also seemed conform to that equation, and I use the one from fxsolver and Stanford for normal lenses under 0.5x.

Anyways, I will dive into this more since I am practically locked down in my home :D Thanks for all the info.

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

OK, read through your PDF, here is what I found:
TDOF_qlwe = lambda / (NA*NA)
Your TDOF_qlwe is actually the first term of the equation from Nikon, judging from its form, it is only dependent of NA and wavelength, caused by diffraction. What is interesting is that there is a geometric term in Nikon's equation that depends on the e that is missing in your TDOF_qlwe, and later, you specified that only use TDOF_qlwe when CoC is smaller than Airy disk, which is diffraction-limited. So here are questions:

1. When diffraction limited, determining DOF, are you saying only use TDOF_qlwe? That does not make sense at all, that means at 50x or at 25x because it only depends on NA (and lambda), DOF will be the same! No, it does not make sense at all, are you sure?

2. Usually, also as suggested in Stanford article, we pick CoC as pixel size, I used e = 14um in my previous post, in your geometry limited regime, so it is not a good number per this discussion fitting your thinking. If we use e = 4um, the difference will be 0.03556 * 4 = 0.1422um, or percentage change will be about (0.1422) / (2.2+0.1422) = 6.1%. The smaller the e, the smaller the percentage. If down to 1.342um, around your transition regime, it is even smaller, about 2.1% change of DOF. Please verify: lambda = 0.55um, n = 1, NA = 0.5 and M change from 50 to 25, just in case I made mistake.

3. Contribution from wave optics, ie, due to diffraction, only depends on NA, wavelength, and refracive index, n. That means at 50x or at 25x, contribution from wave optics is the same. I have said a few time, when speaking of different magnifications and DOFs for the same objective, we are comparing the difference, but they should cancel out.

4. Why Nikon has a geometric term and you suggest not to include them, related to question 1, that would make DOF not change at all. Something does not make sense here.

5. This might be a fundamental one: when you use wave optics, does that mean you should NOT include any contribution from ray optics? I am sure intensities do not add up but . . . the center peak is there and follows geometry, no?

Anyways, again, I took Nikon's formula for granted as they are the experts in the field, it seems their equation contains yours and then the geometric term. So what gives?

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

Please verify those number I posted, ate too much at dinner, very sleepy :D

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

Further clarification of question #5:

What does it mean to pick a CoC smaller than Airy disk? Even if smaller than Airy disk, the peak is still there, just like ray optics, the center of it, or in this case, most of it (CoC) will be in peak that has much more energy than other "rings", and this part should follow geometric regime (if you will) and I believe it should be included, meaning the Nikon formula contains much more info.

So the question here is: Is Nikon right? Is Nikon's equation garbage? I think Nikon is right, but I would like to know otherwise.

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

Rik,

I think there is a flaw in your analysis, it is the definition of "perfect focus" you used through out your analysis. In your analysis, that "perfect focus" is a single point and you defocus from it and get all the graphs you showed (which are correct and great, and also conforms to what I am about to say) where it seems the 1/4 wavefront error defocus is a cut off point.

But the problem is that the "perfect focus" is not a single point, it is a range determined by the CoC we pick arbitrarily. Just like defocusing, analysed using wave optics, it can push out by 1/4 wavefront error from a single "perfect focus" point, ie, anything within that 1/4 wavefront error will have good MFT, wave optics analysis pushes on both ends of the range determined by picking a CoC, ie, gaining additional "DOF" with good MFT on both end of that range -- we are considering each end of that range as "perfect focus".

This is why Nikon has the geometric term -- that term establishes a range, and each end of the range should be considered as "perfect focus" point, ie, acceptable MFT, wave optics then extends out due to diffraction. So I think Nikon's equation is right.

It is too late here and I am not good at drawing plus I am sooo sleepy, but I think you get the point. I might try to draw a diagram. To summarize it, I think you mentioned that calculate both ways, the ray optics way and wave optics way and pick the larger one. I think it should be the sum of both.

It is too late, gotta go sleep :D

mjkzz
Posts: 1689
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Re: Relationship Between Magnification vs Depth of Field

Post by mjkzz »

OK, still can not draw an illustration, even after morning coffee :D, But here is what it looks like: the DOF looks like a dumb bell, with two ends dominated by wave optics and the middle handle determined by ray optics.

Essentially, the Nikon formual says: if we think a point is "perfect focus", the wave optics says within qlwe around that point, the MFT are also good enough, so we need to extend it back to back, half of it in one direction. Nikon formula also says, if we pick a CoC (not to be confused with qlwe where wave optics dominates and we picked qlwe), then we have two points to be considered as "perfect focus", we need to extend these two points out determined by wave optics, so total extension is what that diffraction term in Nikon formula is, ie, two halves, ie the DZTDOF_qlwe in your analysis back in 2014.

Nikon formula makes sense, using that concrete example of 50x 0.5NA, 0.55um lambda, and n = 1 (vacuum or air), and an e :

DOF = 0.55*1 / (0.5*0.5) + 1/(M*0.5) * e = 2.2 + 2 * e / M.

For M = 50, and pick an e = 10um, DOF = 2.2 + 20 / 50 = 2.2um + 0.4um. Even at M = 25, e = 10um, DOF = 2.2um + 0.8um, and look at the 2.2um, it is calculated using wave otpics.

When e gets smaller and smaller, the geometric term becomes smaller and smaller, even percentage wise, compared to the first term governed by wave optics. If we pick a very, very small e, essentially we say the CoC is a point, then that formula represent wave optics perfectly.

But, even that, the term by wave optics is constant, judging from its independence of any geometry (except lambda). So, this is what I have said many times, the contribution from diffraction gets cancelled out if we speak of DOFs at different magnifications for the SAME optical system -- zooming in and out on the same objective, the diffraction regime does not matter, [edit] the difference caused by geometric term will be very, very small, too, maybe not even observable, but it is there! [/edit]

So, your statement back in 2014 is wrong :
RikDOF.png
It should be calculate both and add them up and it makes sense, too -- with geometric term there, you do not have a constant DOF for a given NA at different magnifications.

Back to your comments for another member:
Changing the focal length of the tube lens has no effect on the subject-side NA of the optics. So, if you are in the regime where the imaging system is limited by diffraction then there is no effect on the DOF because diffraction-limited DOF is determined by NA. However, if you reduce the magnification enough to move into the regime where the imaging system is limited by sensor resolution, then you effectively allow a larger acceptable circle of confusion on the subject side and that does increase the DOF even at constant NA.
Now that seems wrong, no, you do not have a constant DOF, there is small difference due to geometric term and I think this is what people here experienced in real world, too, ie, DOF is not constant even in diffraction regime.

Post Reply Previous topicNext topic