Focus Stacking Porn (Not really....)

I’m currently assembling a 3D resin printing station to print HO scale locomotive parts for a scratchbuilding project. My first print was the air compressor that’s bolted to the side of the locomotive, mainly to test the resolution of the printer on small details. Particularly, the piston has these thin fins for heat dissipation; I was worried they’d just resolve to a smooth surface. Anyway, they came out just fine…

Getting to the imaging part of this story, I wanted to inspect the part closely, so I dug out the macro lens. The part is only 1/2" long and a little more than 1/8" wide, so it’s hard to see what’s going on without some help. Those of you who do macro already know this, but I discovered how shallow is depth-of-field at those close distances. My Z 6 will shoot focus stacks, so I installed Hugin and spent spent some time shooting and stacking.

This image is the amalgam of a 30-capture stack shot with a strobe. I struggled a bit getting it all in focus; Nikon is rather vague regarding what is the focus interval; even Thom Hogan’s excellent book on the camera couldn’t offer a lot of help except to say it’s based on the circle of confusion at the focal length. A bit of trial-and-error got me to 30 captures on the smallest interval setting. I also struggled a bit with the starting image focus, had to switch out of AF-C to keep the focus I selected, selected:

This is a full-resolution rendition; download it and zoom in to see some of the artifacts of resin-based lithography. The white stuff is my bad, I was so excited to have a print that I neglected to properly dry off all the alcohol wash prior to UV curing. Eyeball viewing of the part looks like matte-textured surfaces, but with this image you can easily see the layers of the lithograph.

Anyway, a shout-out to Hugin and @patdavid’s excellent tutorial.

10 Likes

What is your dexterity level? I can’t even.

3 Likes

This is black magic to me and I regret not knowing enough to understand it all - Thank you for providing the tutorial, this sounds like an insane amount of work to even get your head around. Coolest thing I’ve seen this year

1 Like

Yeah, they are. I’ve played with this feature and decided that this needed to become a project of its own to figure it all out. And although the manual says that you can use AF-C, I also did not get that to work (AF-S works).

The type of focus shift shooting you show here seems indeed to need many shots with a small interval.

The thing I did notice while playing with this is that you get better results when focusing the first shot a bit before what it is you want to capture (so, basically the front is out-of-focus and the object is then brought into focus and completely “scanned”).

But, like I said: Need to put more time into this feature to get a goo handle on it. If you do run into tips I’m sure there are people here that would want to know about it (I would…).

1 Like

@ggbutcher I hope you have seen this threat about focus stacking:

1 Like

@ggbutcher

Since this is a showcase post, I don’t know if you would like some focus stacking tips and links to another forum. Would you?

1 Like

Not as good as it’s been. I used to do my railway modeling in N scale; eyesight and fumble-fingers got me to consider something bigger. HO scale is around twice as big, but I’m finding I didn’t get that gain with HOn3 (3-foot narrow gauge) because the locomotives and cars are so small…

I’ll take a look when I get a chance. In a bit, I’ll be cranking out more parts and I’ll need pictures…

I’ll do that, as I go. My first foray into it was yesterday, so I’m still figuring things out.

Yup, the first “heuristic” I ran into. I did about 15 stacks yesterday, and I couldn’t get the early ones to settle down after I’d compelled the focus and switched to the focus stacking menu to kick it off.

Indeed. Not sure I needed the smallest interval setting, and 30 shots seemed to be a reasonable extrapolation of the minimum distance in the D850 tables Thom Hogan has in his book.

Found exactly that, after determined my model was tilted toward the camera and I needed to focus on the top edge rather than the bottom piston where all the fins are. Even then, the nearest part is still a bit out of focus because of what you describe, and I’m not sure how I’d compel the Nikon mechanism to “pull forward” a bit. Maybe, in AF-S nail the focus, then pull it forward a bit with the lens ring… ???

Well, I didn’t meant that you gave us tips about focus stacking, but the other way around… :slightly_smiling_face:

Tips about how to light the subject, the best approach to perform the shooting process, the step-size, some artifacts to be expected from the stacking process, … There’s a lot to be taken into account if you want decent images (and I’m not saying your image is awful).

1 Like

This is what I did. Not sure if this is correct, though. If you “un-focus” a bit too much you get a weird jump from the first to the second shot.

I just had a look and even the Z6 II reference manual says, and I quote:

[…], the starting focus position should be slightly in front of (i.e., closer to the camera than) the closest point of the subject.

As I mentioned in my previous reply: I really do need to make a project of this and spend time figuring things out.

1 Like

The fool in the basement here can’t read…

Oh, I’ll take any advice offered. I’m trying to make model locomotive scratchbuilding a hobby, not focus stacking… :laughing:

Oh, but it is quite awful. I spent the day just trying to get the camera to focus the first image on the very front of the subject, everything else I let the camera figure out, apparently including composition…

Right now, I’m thinking of this capability as a means of QC-ing small parts I can’t see well with my old eyes. Already, I can see I’ll need to polish what I think are “smooth” surfaces, as even resin lithography has its limits…

I understand focus stacking as a tool, not as an end in itself.

In your case I think you will need a good view of the details, not an artistic depiction of the subject, and my comments will go in that direction.

This is a crop of your images with some areas of interest:

  • the area circled in yellow shows the problem @Jade_NL and you have already pointed out: it’s out of focus. In case it’s an important area, it has to be in focus and Nikon doesn’t make it easy for you, you can buy (or better yet DIY) a macro focus rail. That way you would set up everything with your Z6, focusing at the very front of the subject, but before starting shooting pictures, you would move the camera slightly backwards with the rail (it’s better to move the camera instead of the subject; that way the relative position of the lights won’t change). Suggested reading: Using a Macro Lens on a DSLR

  • I’m not sure about the red area, but just in case: it seems that there’s a stripe of out of focus details, top to bottom, almost next to the left border of the subject. If it is indeed out of focus, it may be because there hasn’t been enough overlapping between adjacent images. That is, the steps between images were too large. It is usually advised that images overlap around 25% for better stacking. You may or may not control what your Nikon does, but if you find out you can’t set smaller steps, you can always shoot from farther away, getting lower magnification, so your steps would be good enough. Your Z6 sensor would still give you enough details after cropping the stack. Suggested readings: (1) DOF Estimates For Macro/Micro; (2) Is it better to use a focus rail or the ring on my lens?; (3) Using ControlMyNikon To Step Focus (commercial software)

  • the green area shows a typical problem while stacking: bright areas spill over darker areas. This is really difficult to avoid if you’re not careful with your lighting setup. A technical explanation shows that the out of focus brighter areas create some sort of haze over the darker areas. You can reduce a bit the problem closing the lens aperture, but if you close it too much, you will enter diffraction territory.
    However, the easier and in the end better solution is using diffused lighting, e.g. with a light tent (which of course you can DIY). That way lighting won’t be so harsh and you will prevent creating some artifacts (at least to a certain degree) like the bright coloured pixels on the right side highlights of the subject, most probably caused by thin film interference, and one pesky artifact (read until the end of the first post) where the subject seems to be moving between shots

  • in that green area you can also see that you have missed some images at the rear side of the subject, although that is usually not so important (you will usually wish to see the front side and not care much about the rear side of the subject)

  • all around the subject there’s a ghost image, a halo which most probably will be caused by the stacking algorithm. Just try another app with a different algo

  • if you need to get details better resolved, shoot your images with your lens wide open. That means you will have to take more images, because of the shallower depth of field

It seems too much for some casual focus stack, but once you get the hang of it you will pretty much focus (pun not intended) on the subject and nothing else.

HTH

4 Likes

@XavAL, thanks a lot for this feedback. I’ve always wanted a macro rail, never quite knew why 'till now…

Wondering if what’s going on in the green circle might have to do with the translucency of the material. UV curing resins work better if a bit translucent, so the curing light can reach farther into the material. This resin is probably somewhere in the neighborhood of 30% translucent; thin parts are pretty see-thru, but the material rapidly transitions to opaque as the material thickens.

The ghost was worse in my first stacks, but enfuse has a parameter to control that I added to later processing. Not being familiar with the algorithms, I have some study to do to understand its specific effect.

HTH: Definitely!

Well, I can’t be 100% sure if I can’t see the real object, but I bet that at least the effect explained in the link I provided is clearly present in your stack.

Long story short, given this scenario:

where the white circle is farther away from us than the black square, you expect your camera focused at the square will give you this:

but in fact what it will record this:

So after stacking, there will be some haze on the square caused by the unfocused circle as shown in several images within the stack.

You can minimize this problem by stacking linear TRC images and then further post-processing the resulting stack.

Remember this effect is unavoidable. You can just minimize it as best you can.

Try Piccolay, or Zerene Stacker (it’s free to try). But of course you can still try to master enfuse (with Hugin, Macrofusion, or some other frontend)

4 Likes

I have been tempted so many times to buy one of WeMacro’s automated rails - but then I put it off because I know I wouldn’t use it much, and as an electrical engineer, I’d rather try to DIY it. :slight_smile:

The problem with DIYing it is that my mechanical skills kind of suck… But if you’re 3D printing N-scale model railroad parts with an MSLA printer, you might have good success building your own macro rail. I’ve seen from your SSF project that your mechanical skills are much better than mine. :slight_smile:

1 Like

Well, the idea is not having the top notch linear stage, but something which will move the camera backwards a bit more stylish than doing it by hand…

One of the myriad of possibilities to DIY such linear stage could be this one (including 3D printing some parts), or another one coming from a University. So no excuses :grin:

2 Likes

That university one is a bit on the $$$ side, but that other one is a perfect starting point to add a stepper motor to. :slight_smile:

1 Like

I love it; nice machining in the university version, with spaghetti wiring… :crazy_face:

I can probably print the other one with my new toy; after I do a few locomotive parts I’ll queue this one up.

1 Like

I was looking at the CAD model of this part this morning; those layers may be the resolution of the cylinder that subtracts to make the hole, #faces=90. I’ll have to print it with a higher face count to see if that’s what is showing up here…

1 Like