How to calculate step size

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

Moderators: rjlittlefield, ChrisR, Chris S., Pau

4odonates
Posts: 41
Joined: Sun Oct 30, 2022 12:43 pm
Location: Fairfax County, Virginia

How to calculate step size

Post by 4odonates »

What is the formula for calculating focus stacking step size? I visited several online step size calculators. Much to my surprise, every calculator features different input parameters so I guess it isn't surprising no two calculators produced the same output.

For reference, I'm trying to calculate the step size using the following photo gear: Fujifilm X-T3 digital mirrorless camera (APS-C sensor, crop factor 1.5); Laowa 25mm Ultra Macro lens set for 2.5x magnification and an aperture of f/4. I own the Canon version of the Laowa lens, mounted using Laowa's generic adapter (Canon EF lens mount-to-Fujifilm). The adapter doesn't feature electronic contacts -- all it does is move the lens to the flange focal distance (FFD) for Canon EF cameras (44 mm).

Thanks for your help!
Walter

Online
ray_parkhurst
Posts: 3412
Joined: Sat Nov 20, 2010 10:40 am
Location: Santa Clara, CA, USA
Contact:

Re: How to calculate step size

Post by ray_parkhurst »

Here is an excellent page for determining depth of field:

https://zerenesystems.com/cms/stacker/d ... romicrodof

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

Re: How to calculate step size

Post by rjlittlefield »

Walter, I wrote the page that Ray points to.

That page and all of the various calculators are each giving you a single number to reflect what is really a complicated set of interactions.

Barring outright error, which I have seen but only rarely, you get different numbers because of different underlying assumptions about what the user will consider acceptable.

The classic model is based on an acceptable blur circle that is about 1/1000 of the frame width, but with a modern camera that's likely to be 6 or 7 pixels wide. If you focus stack with that criterion, the resulting image will look OK if you make a 10" print, but if you pixel-peep the digital image you'll see definite focus banding -- bands of blur between bands of sharp. That condition is acceptable to some people, not acceptable to others, and there's roughly speaking a factor of 2 or 3 difference between the step sizes that would make each group happy.

The numbers at zerenesystems.com, and the corresponding DOF calculator inside Zerene Stacker, use a different model that avoids focus banding no matter how good your sensor is and how far you zoom in. Depending on what aperture you're working at, the resulting number might be somewhat larger, about equal, or much smaller than the classic calculation.

There are also a lot of other factors that can affect what step size is optimal for any particular application.

The best general advice I know is to treat any calculated value as a suggestion, then adjust to taste based on experience.

--Rik

4odonates
Posts: 41
Joined: Sun Oct 30, 2022 12:43 pm
Location: Fairfax County, Virginia

Re: How to calculate step size

Post by 4odonates »

Thanks for the quick replies, including one that disappeared. My apologies for being slow to respond -- I've been experimenting to see whether I understand the guidance that you shared.

If my understanding is correct, then one way to determine step size is to either calculate or measure depth of field (D.o.F.) and use 70% of that value as the step size. For example, using my Canon 5D Mark II camera and Canon 100mm macro lens set for maximum magnification (1:1) at a focus distance of 29.972 cm the total D.o.F. is 0.29 cm (2.9 mm, or 2900 microns). 70% of 2900 microns = 2030 microns or 2.3 mm. Is that right -- can the safe step size actually be slightly more than 2 mm? Another calculator says the total D.o.F. is 1.02 mm -- that's quite different from 2.3 mm!

After I get your feedback, I will share the results of my experimentation with determining the safe step size using my Fujifilm X-T3 and Laowa 25mm Ultra Macro lens.

Sincere thanks for your help!
Walter

4odonates
Posts: 41
Joined: Sun Oct 30, 2022 12:43 pm
Location: Fairfax County, Virginia

Re: How to calculate step size

Post by 4odonates »

Note: This reply is for Rik Littlefield.

Allan Walls has mentioned many times that he uses Zerene Stacker to determine step size. During the "Macro Talk" YouTube live stream on Tuesday, 31 January 2023 I asked Allan to demonstrate how Zerene can be used to determine step size. Allan deferred answering my question because I said I don't have Zerene. Yet. I wanted to see whether Zerene could be used to verify the results of my experimentation with determining step size.

Is there a related "Help" file that explains the process? Or maybe a YouTube video that shows how it works?

Thanks for your help, Rik!
Walter
Last edited by 4odonates on Fri Feb 03, 2023 11:02 pm, edited 1 time in total.

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

Re: How to calculate step size

Post by rjlittlefield »

4odonates wrote:
Thu Feb 02, 2023 1:00 am
If my understanding is correct, then one way to determine step size is to either calculate or measure depth of field (D.o.F.) and use 70% of that value as the step size. For example, using my Canon 5D Mark II camera and Canon 100mm macro lens set for maximum magnification (1:1) at a focus distance of 29.972 cm the total D.o.F. is 0.29 cm (2.9 mm, or 2900 microns). 70% of 2900 microns = 2030 microns or 2.3 mm. Is that right -- can the safe step size actually be slightly more than 2 mm? Another calculator says the total D.o.F. is 1.02 mm -- that's quite different from 2.3 mm!
If you can tell me exactly where those numbers came from, then probably I can tell you what they mean and why they span that range. I would be interested to know in any case.

About the step size of 2.3 mm at 1:1, yes, under some conditions I would be very comfortable with that. A simple example is when using a camera and lens with nominal f/16, focused by extension to give effective f/32.

However, even on a Canon 5D Mark II that setting will result in an image that is significantly blurred from diffraction. So, while 2.3 mm will avoid focus banding, the final result will not appear very sharp when viewed at camera resolution actual pixels.

Here is the DOF Calculator in Zerene Stacker, showing that situation. Note that when it says "Aperture is near optimum", what it really means is that the aperture setting is well matched to the specified COC, which I have adjusted to span 5.5 pixels so as to match the aperture. Such a large COC will correspond to an image that looks blurred when pixel-peeped at camera resolution, though it may look fine in a print or certainly when reduced to 1K pixels for web display.

5DMkII_m1f16.png

You would get a sharper result by shooting at nominal f/8, effective f/16, in which case I would recommend a step size around 0.56 mm.

Here is the calculator for that case, showing that it is equivalent to using a CoC of only 2.75 pixels.

5DMkII_m1f8.png

4odonates wrote:
Thu Feb 02, 2023 1:09 am
...see whether Zerene could be used to verify the results of my experimentation with determining step size.

Is there a related "Help" file that explains the process?
Yes, but only because I have just now written one. See https://zerenesystems.com/cms/stacker/docs/dofcalculator . No doubt it will evolve in the coming days.

I'm afraid you will find that the discussion seems dauntingly complicated. The underlying problem is that the actual situation is dauntingly complicated. The light does not behave the way the classic models assume.
Neither do people, when they're using modern displays. As a result, we end up having a choice between simple calculations that differ from each other by large factors because of unspecified assumptions, or complicated calculations that have fewer unspecified assumptions but expose all their inputs.

--Rik

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

Re: How to calculate step size

Post by rjlittlefield »

4odonates wrote:
Fri Jan 27, 2023 4:03 pm
For reference, I'm trying to calculate the step size using the following photo gear: Fujifilm X-T3 digital mirrorless camera (APS-C sensor, crop factor 1.5); Laowa 25mm Ultra Macro lens set for 2.5x magnification and an aperture of f/4.
Here is a calculation for that configuration. Again, I've used COC around 3 pixels, corresponding to sharp when viewed at actual pixels.

FujiXT3_m2.5f4.png

use 70% of that value as the step size
I usually just use the calculated wave optics DOF, rounded down to some convenient value. In this case 0.05 mm works both ways.

--Rik

4odonates
Posts: 41
Joined: Sun Oct 30, 2022 12:43 pm
Location: Fairfax County, Virginia

Re: How to calculate step size

Post by 4odonates »

Thanks for the detailed replies, Rik!

You asked about the D.o.F. calculators that I used. The first is an old favorite. Well, it was an old favorite.

https://www.dofmaster.com/dofjs.html

The second site is one that was recommended in the comment on my post that disappeared. See "Macro Depth of Field Calculator."

https://www.cambridgeincolour.com/tutor ... lenses.htm

And the last calculator I used is another one from the Cambridge in Colour Web site that I discovered accidentally.

https://www.cambridgeincolour.com/tutor ... ulator.htm

I tried to attach screen captures that show the settings I used for each calculator, for both my Canon 5D Mark II and Fujifilm X-T3, but got an error message that the files are too big. Please let me know whether you need to see that information.

Walter

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

Re: How to calculate step size

Post by rjlittlefield »

4odonates wrote:
Fri Feb 03, 2023 10:56 pm
I tried to attach screen captures that show the settings I used for each calculator, for both my Canon 5D Mark II and Fujifilm X-T3, but got an error message that the files are too big. Please let me know whether you need to see that information.
Thanks for the links.

Yes, I would like to see the settings that you plugged in.

This forum's restrictions on image size are max 1024 pixels on each side, and max 300 KB (kilobytes) per image. The usual method of fitting inside forum limits is to save images as JPEG, with compression quality adjusted so as to meet the 300 KB restriction. Using Photoshop, File > Export > Save For Web (Legacy) can make shorter files by leaving out metadata. For screen captures of user interfaces that have lots of blank space, PNG works well because it compresses out the blank space while not affecting the appearance. But even quite low quality JPEG will work fine for the current task, since I just need to see the numbers and selections.

--Rik

4odonates
Posts: 41
Joined: Sun Oct 30, 2022 12:43 pm
Location: Fairfax County, Virginia

Re: How to calculate step size

Post by 4odonates »

Here are the settings I used to calculate DoF for my Canon 5DM2 macro rig ...
CiC_DoF-Calculator_Canon5DM2-100mm-macro_annotated.jpg
Macro-DoF-Calculator_Canon5DM2-100mm-macro_annotated.jpg
DoF-Calculator_5DM2-100mm-macro_annotated.jpg
I will send the screen captures for my Fujifilm X-T3 rig under separate cover.

Thanks, Rik!
Walter

4odonates
Posts: 41
Joined: Sun Oct 30, 2022 12:43 pm
Location: Fairfax County, Virginia

Re: How to calculate step size

Post by 4odonates »

Here are the settings I used for my Fuifilm X-T3 rig ...

[three attachments]

Thanks, Rik!
Walter
Attachments
DoF-Calculator_Fujifilm-XT3-Laowa-25mm-Ultra-Macro-annotated.jpg
CiC_Macro-DoF-Calculator_Fujifilm-XT3-Laowa-25mm-Ultra-Macro_annotated.jpg
CiC_DoF-Calculator_Fujifilm-XT3-Laowa-25mm-Ultra-Macro _annotated.jpg

JKT
Posts: 420
Joined: Fri Oct 28, 2011 9:29 am
Location: Finland
Contact:

Re: How to calculate step size

Post by JKT »

The case of 100 mm macro lens seems simple enough. The first calculator has one problem with input and two missing inputs for correct calculation.

The problem is focal length. At 1:1 it likely is not 100 mm. Either you didn't mention which 100 mm macro lens you had or I missed it. In case of Canon 100mm f/2.8 IS USM Macro L, the focal length at 1:1 is 74mm.

The missing inputs are pupil magnification and lens length. The former is 0.28. That and the focal length are from Photons to photons. The lens length (from sensor) is necessary to get the focus distance. Even then there would be smaller errors as even more data would be needed to avoid thin lens assumption.

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

Re: How to calculate step size

Post by rjlittlefield »

Walter, thanks for the additional information.

I looked "behind the scenes" to see what those calculators are actually doing. I found that they're using classic DOF equations based on ray optics and COC (circle of confusion).

First, about your inconsistent results...

The big inconsistency between your various results happened because in two cases you and the calculators disagreed about what some words meant. In particular, the calculators at https://www.dofmaster.com/dofjs.html and https://www.cambridgeincolour.com/tutorials/dof-calculator.htm ask for "Subject distance" and "Focus Distance", and you plugged in 29.972 cm (299.72 mm). I'm guessing you got that number from a lens manufacturer's specification for "Closest Focusing Distance". Unfortunately, those words coming from a lens manufacturer usually refer to distance from sensor to subject, not from lens to subject. Even if the lens manufacturer were to quote something like working distance from the physical front of the lens, that would still not be what the calculator wants. No, what the calculator wants is the distance from the lens's front principal plane to the subject, under the assumption that the lens's working focal length is equal to the specified focal length. When you plugged in 299.72 mm, the calculator took that number, inferred that you meant 299.72 mm in front of the lens and therefore 150.07 behind the lens (because of the thin lens formula), for a working magnification of 0.5007 X.

One calculator then dutifully ran the standard formulas for 0.5007X at f/8 with a 0.030 mm COC, and calculated a DOF of 2.873 mm = 0.29 cm. The other calculator did the same thing but used a slightly larger COC of 0.032 mm, getting DOF = 0.3065 cm.

If you had plugged in 20 cm (200 mm), then the calculators would have used 200 in front, 200 behind, magnification 1X, and calculated DOFs of 0.096 cm and 0.102 cm, the latter value matching the value calculated by https://www.cambridgeincolour.com/tutorials/macro-lenses.htm when you said magnification 1X. The difference between 0.096 and 0.102 is because of the different values for COC, 0.030 and 0.032 mm.

It should be apparent that there's lots of potential for confusion in using these calculators. If you already know how the calculator works, then maybe it's simple enough to plug in correct values. Otherwise it's simple to plug in the wrong number. I'm quite confident you are not the first person to have plugged in a wrong number for "Subject distance" or "Focus distance".


Now, I would like to pop way up to the conceptual level and talk about what "depth of field" really means.

When a lens and subject are at perfect focus, the image inevitably still has some amount of blur due to diffraction.

As you move away from perfect focus, the amount of blur gets larger.

If we graph the amount of blur versus defocus, we get a picture that looks like this.

Image

In the above graph, the bold blue curved line is what the light actually does, as calculated by wave optics and confirmed by careful experiment. In contrast, the thin black straight line is what the DOF calculators pretend that the light does. When I wrote earlier that "The light does not behave the way the classic models assume", this is what I'm talking about.

One might reasonably ask, "So, if the classic model is that bad, how have those formulas been used so successfully for so many years?" I think there are at least four reasons. One is that the model is so comfortable that dislodging it would take compelling evidence. Another is that the classic model isn't that bad if you stay on the right side of the graph. A third is that the model & corresponding formulas are essentially self-calibrating in use. Nobody knows what an image with COC=0.030 mm would look like if the light did work the way the model pretends, because there's no way to get such an image except by computing it. Instead, people have always just looked at the images, decided how sharp they needed the image to be, and picked whatever value for COC happened to match their subjective judgement. To the extent that people agreed about the viewing conditions and judging criteria, they ended up with more or less the same values for COC. And fourth, that troublesome region over on the left is easy to sweep under the carpet. "Yeah, things get complicated when diffraction kicks in. But that's where things get fuzzy, so we don't want to run there anyway." (I'll say more about that last part in a later post.)

Anyway, quickly summarizing: the image gets blurred as it goes out of focus, and it does that smoothly and continuously. Whatever number is computed for DOF reflects some human's judgement about what is "good enough".

Now, let's apply this understanding to focus stacking.

Here I have plotted the variation in blur, across a slanted subject, for four different step sizes.

Image

The green steps are big and you get big variation in MTF50 detail between perfect focus and maximum defocus, almost a 2:1 range in MTF50 blur size. The blue steps are smaller and you get smaller variations, about a 4:3 range in MTF50 blur size. The red steps are smaller yet. The orange line has steps that are the smallest of all, and the variation is tiny, less than 6% difference in MTF50 blur size. In going from green to orange, you reduce the blur variation by a factor of almost 15, in exchange for shooting and processing 4.5 times more frames.

Where is the optimum point? When does the improvement no longer justify the added cost?

These are all subjective judgements. Ultimately the best that any calculator can do is to
  1. get you in the right ballpark in the first place, and
  2. estimate your optimum point for different setups, after you have determined that point for one setup.

Finally, and back to your very first question...
4odonates wrote:
Fri Jan 27, 2023 4:03 pm
What is the formula for calculating focus stacking step size?
The calculator inside Zerene Stacker combines two different formulas. One of them is the classic ray optics formula, driven by magnification, aperture, and a COC of your choosing. The other is a wave optics formula that understands in gory detail about diffraction and defocus, and always recommends a DOF that corresponds to the blue line in the Blur Variation graph above.

For how to calculate effective aperture, see viewtopic.php?f=29&t=44327 .

The two formulas are then approximately[*]:
  • Classic: DOF = 2 * C * Feff / m^2
  • Wave optics: DOF = 0.0022 * Feff^2 / m^2
The final recommendation is whichever DOF comes out bigger. The rationale is that if you've specified COC then you're willing to accept at least that amount of blur, no matter how much variation it gives. Otherwise, you'll get the wave optics recommendation on the theory that it gives little enough variation you'll never see focus banding. (Yes, I'm probably being a little optimistic on that last point, but if so, nobody has told me yet.)

I hope this helps. Questions welcome, of course.

--Rik

(*) "Approximately" means that the calculator actually uses a much more complicated wave optics formula than is shown here. However, for any lens below 10X NA 0.25, the added complexity buys only about 2% difference in calculated value, so it's not worth showing the complication here.

4odonates
Posts: 41
Joined: Sun Oct 30, 2022 12:43 pm
Location: Fairfax County, Virginia

Re: How to calculate step size

Post by 4odonates »

Thanks for the detailed replies, Rik! I'm working on compiling a list of follow-up questions. Hope to get back to you soon.

Walter

JKT
Posts: 420
Joined: Fri Oct 28, 2011 9:29 am
Location: Finland
Contact:

Re: How to calculate step size

Post by JKT »

I think I have one question as well.

The formula gives the optimal effective aperture. And in the classic macro lens range (down to 1:1) that value is usually reachable throughout the magnification range. That should mean the required illumination is constant as well, doesn't it?

The question is how to know what value to set in the camera in order to get that effective f-number? That seems to be more of a problem with Canon, if Nikon shows that one to begin with. :) A quick test seemed to indicate that the numbers given at Photons to Photons are not reliable - if so, they likely don't follow what the aperture really does when magnification is changed. Is there any other way besides brute force (testing every lens at sufficient number of magnifications with even illumination level and then anchoring that to number at infinity focus)?

Post Reply Previous topicNext topic