Focus Stacking Porn (Not really....)

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

It would be neat if we could have access to your stacking set to see what others could do. Probably not for me though due to my laptop’s inability to handle your camera’s output resolution.

OpenSCAD? I’m jealous you have a printer that lets you see artifacts of the CAD software at faces=90. :stuck_out_tongue:

Ah, I don’t know which yet. It’s just that when looking at the CAD render, the faces generated are roughly aligning with the stair-stepping I’m seeing, particularly in the standoff between the two cylinders:

versus:

The printer is a Elegoo Mars 3, about $350US. A LOT cheaper than the lathe/milling machine setup I was originally considering… :laughing:

I’ve been very tempted by an SLA printer, I primarily just don’t have enough space for Yet Another Printer, especially with the ventilation requirements for MSLA.

Not only ventilation, but possibly temperature. My basement is chilly, ~60F, so I need to mitigate that to 70-80F. I built this:

All (well, mostly) scrap wood; the inline fan is a 200CFM jobbie for grow tents, and there’s a cheap Amazon heater in the cabinet and a grow tent thermostat hung on the outside. I don’t have room for a cabinet large enough to let me manipulate the printer cover, so I’m experimenting with the slide-up plexiglass covered with a red acrylic film for UV filtering, and just running the printer without its cover.

I’m not too worried about off-topic stuff here; SLA printing is an elemental form of imaging… :crazy_face:

4 Likes

Good put; I think I’ll do that in a week or so when I get a stack where the part doesn’t look so crappy…

I would be specially interested in the present stack, because of the flare/haze problems it shows. I would like to investigate a bit if it can be improved.

And about the printer: if the standoff between the 2 cilinders is the most important part for you, maybe is worth trying to print the part lying down, with the hole facing up. That way you could take advantage of the greater horizontal resolution of the printer: it seems the vertical resolution (or steps) is coarser than the horizontal resolution. The downside is that the cilinders would become less «polished» and will show those steps

I tar.gz-ed the raws and my processing script, you can find it here:

https://glenn.pulpitrock.net/stacks/stack1.tar.gz

It’s 385MB, took a hour to upload on my dodgy internet.

Actually, my priority is the resolution of the fins on the lower cylinder, and the vertical orientation nicely renders that. I’m not sure if the stair-stepping in the standoff is the printer or my CAD resolution, so I’ll test that in a couple of days with a higher CAD #faces setting. Even if it’s the printer, I think I can live with it, especially if painting will fill it in. Looking at my other models in this scale, I don’t think it would be noticeable as-is anyway, just have to keep “rivet-counters” from bringing their magnifying glasses… :laughing:

2 Likes

Thanks for the upload, appreciated!

Having a large(-ish) set to play with is always a nice-to-have :nerd_face:

Edit: Ah, just noticed the embedded script. Great to have a “sidecar” for comparison.

Oh, need to inform, the first line of the script is the invocation of img, the rawproc command line processor. Replace with your favorite equivalent…

:joy: :joy: Sneaky!

I have played a bit (well, not a bit, TBH) and all my suggestions still apply (and some extra ones):

  • recheck the vertical resolution of the 3D printer: to me, it’s way lower (its resolution) than the horizontal resolution
  • I’m still not sure if your camera takes too few images: it seems that they don’t overlap enough and there are fuzzy areas where no image had those areas ever focused
  • AFAICT, the ghost can’t be removed: background brightness keeps changing at every shot. Load all your unaligned tifs on gimp, in a single image, each shot in its own layer. Go to filters > animation > playback. Put playback speed to 0,25x and run it (top left button). You will see what I mean (unless RT is doing some weird things, which I doubt…). So, given that the luminosity of each image is different, the stacking algorithm can’t correct it, and it creates the haloing
  • I honestly wouldn’t use that 40mm lens anymore for focus stacking: I’ve had to apply a really strong defringing. We are lucky the part is mostly B&W. If you don’t remove that fringing, it will end up in the final stack, and a myriad of colourful artifacts will appear. And the more artifacts you have to fix or remove, the less time you will be checking the quality of your parts
  • I would use a light tent and continous lighting, unless you really trust your strobe (I wouldn’t, looking at the images)

And finally the image:

This is the processing done in all images before stacking them:
DSZ_0001.NEF.pp3 (14.1 KB)

Exported as linear tiff, stacked and then reexported to sRGB without any further processing.

I must add that I haven’t been able to stack them with enfuse (the aligning part keep just throwing only one image), so I’ve had to use Zerene. Don’t worry, to me this is a proof of concept, just to show that the bright haloing could be tamed down. You can keep mastering enfuse if you wish…

HTH

2 Likes

Wow, learned a lot from your post.

Yeah, I just let the flash strobe with a 2sec delay for recovery, which may not have been long enough. I’m definitely going to do the next campaign with a light box and my trusty LowellPro halogen spot. That’ll let me switch to electronic shutter, hope that doesn’t bring its own issues…

Not good news on my lens. It’s the Nikkor 40mm DX macro, which I bought primarily to do slide and negative reproduction. Not really good for any other macro application, too short. Surprised at the CA, wouldn’t have expected Nikon to make a lens that bad.

Hmm, I never had an alignment failure with hugin’s align_image_stack.

Regarding the printer, I’m going to try a few prints when I get going again, switching out combinations of CAD faces and Z-increments, easy to do with such a small object (1/2hr to print). Right now all I’m missing is the right foam board to make my vat covers, no joy at the first hobby store just an hour ago. Got one more to try…

1 Like