Stacking step size

A forum to ask questions, post setups, and generally discuss anything having to do with photomacrography and photomicroscopy.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

ChrisR
Site Admin
Posts: 8668
Joined: Sat Mar 14, 2009 3:58 am
Location: Near London, UK

Stacking step size

Post by ChrisR »

Yes that old question again, sorry!

I use the calculators and tables as are recommended hereabouts and they're usually OK, but I've had to rerun a few stacks with finer steps, for what I think is a mix of reasons. Looking at adjacent images in the stack, and what the stacker does with them, I've thought up some reasons, but some of my thinking is probably wrong here.

"Show us" I can hear y'all thinking. But this post was prompted by Steve Kale's recent question so I don't have prepared stuff to hand.

First, at say 1:1 where diffraction isn't limiting the sharpness, the Circle of Confusion in some of the literature ( which uses say width / 1000 or 1500) is a bit big for a sensor say 5000+ pixels wide ( the Nikon 800D will be 7300 or so wide). Looking at pictures as the in-focus band moves along something like a hair, you can see it. It seems to show more on some features than others.

Second, stackers output pictures tend to lose a bit of sharpness when compared with single frames, we know. Pmax does it more than Dmap, but with some images ( eg hairy ones) Dmap's not so appropriate. Pmax seems to do better if there's a couple of frames with the detail fully sharp. Even Dmap I think, but much less noticeably, and maybe only when the third issue comes in:.

Third - alignment. The software can tug things around almost alarmingly. Sometimes things don't align perfectly between frames ( OK it's much worse if there's dust on the sensor!) Watching the stacker move through, I think the "best fit" can mean that not all the in-focus parts of the image are exactly aligned. Makes sense - if the thing which was in focus is gone, then what can it align with?

I mean if the blue parts are in focus, then the red, there's a problem for the aligner?:
Image

Turning the alignment controls off (either just rotation, (but secure your camera first) or scaling as well) can help, but of course we need those sometimes. I can't say I've worked out exactly what happens, but where I have seen alignment errors occur, and have rerun with finer steps, the output is cleaner. At worst it shows up as "stem stitch" (if you do embriodery), or if not that bad, still something Pmax has bother with.
I've just done a stack with a 10x NA 0.21 obective, which "needed" 5 micron steps.

I'm not sure how ZS works if frames are skipped - does it eg align the lot then stack the even ones, or only align & stack the even ones? It would matter of course.

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

Re: Stacking step size

Post by rjlittlefield »

ChrisR wrote:I'm not sure how ZS works if frames are skipped - does it eg align the lot then stack the even ones, or only align & stack the even ones? It would matter of course.
It depends on how you push the buttons.

Method A. Options > Preferences > "Stack every N'th frame", then Stack > Stack All. This aligns and stacks only the indicated images, preserving prior alignment if any.

Method B. Highlight every N'th frame using lots of control-mouseclicks, then Stack Selected. This aligns all images before stacking of the selected images begins.

The difference is by design, to simplify and speed up running tests like we're now talking about.

Regarding alignment...
The software can tug things around almost alarmingly.
Well said. The problem is especially bad for subjects that have regular structures, where the alignment procedure can end up deciding that completely different sections of the subject should go together because when focused they look more similar than anything else does. This problem is not restricted to engineered subjects --- one section of a moth scale looks very much like a neighboring section of the same scale, shifted along the axis of the grooves. When the grooves all run in the same direction, as they often do over sizable sections of a wing, you have opportunities for serious mischief.

The moth wing tests that I reported recently for 40X NA 0.50 showed results that were independent of alignment issues. This was done in two ways. First, I shot on a very stable platform, using the fine focus knob of an Olympus CH base and a camera that was hard-mounted to the same base. Second, I stacked all frames first, then every 2nd, every 4th, every 8th, and so on, all in the same run and in that order. This procedure causes all stacks to be run with exactly the same alignment, which guarantees that the resulting images line up suitably to use the flash-to-compare trick that I find so useful.

When that same set of images is processed several times independently, with FSF=1, 2, 4, 8 etc having nothing to do with each other, and with shift-X and shift-Y enabled, then a flash-test of the stacked images shows obvious differences in alignment depending on step size, even down to 1/16 micron versus 1/8 micron.(!) The DMap results look equally good up through 2 microns step size when viewed individually, but when overlaid to compare, they have different geometries.

I think there is no simple take-away message here, except possibly "Avoid computational alignment if you can, and shoot as many frames as you can afford otherwise."

No one number can possibly be correct in general, since arbitrarily bad situations can occur. Well documented experience on typical subjects would be very helpful for determining guidelines.

--Rik

ChrisR
Site Admin
Posts: 8668
Joined: Sat Mar 14, 2009 3:58 am
Location: Near London, UK

Post by ChrisR »

Thanks Rik that's about what I expected it did.
Method B saves a lot more processing time of course as it isn't doing the extra aligning, so I do use it.

A rather minor timesaver....
is to arrange the file-chooser window size carefully, so that the files you want are displayed in convenient rows/columns.
It works best for me with files displayed as Icons .
It's quicker to find them and Ctrl-Click them.
This is files selected as Icons in Windows Explorer. Drag 'em all as one, to the ZS input window...

Image

If you wanted every third file, set the window to show 9 icons across, etc.

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

Post by rjlittlefield »

ChrisR wrote:It's quicker to find them and Ctrl-Click them.
Even quicker, you can Ctrl-press-and-drag on the background to surround and select whole columns at a single go. But take care not to accidentally make copies of files by press-and-dragging on a file instead of the background!

That was the technique I used before Options > Preferences > "Stack every N'th frame" became available.

Now I select and drag in the whole lot, leaving them still selected in the Explorer window. When I want to independently process with a different skip factor, I clear out the input files list in Zerene using either Close Project or File > "Remove from list" > Input Files, then go back to the Explorer window and drag in the same files again. This is a lot less trouble than having to select a different set before doing the drag.

--Rik

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

Post by rjlittlefield »

To illustrate some foibles of alignment, here are DMap outputs from my moth wing test processed independently at 1/16 micron, 1/4 micron, and 1/2 micron step size, allowing only X- and Y-shifts. I think it's pretty clear that the final geometries are not the same in any case, though all cases are far below the 2 micron DOF for this lens.

Image Image

If you're unclear about what's causing these differences, join the club! I have the stacks in hand, I wrote the code, I know the algorithms forwards and backwards, and I have no idea exactly what features of the source images are causing alignment differences to appear and accumulate in these various ways across respectively 191, 47, and 23 source images. It is, as they say, "a matter for future investigation".

By the way, there is one other aspect of alignment that you did not mention. That's the old bugaboo that at the level of pixel-peeping, sub-pixel shifts often result in some reduction of contrast due to the need for interpolating pixel values. The canonical example is that 0,100,0,100,0,100 becomes 50,50,50,50,50,50 when shifted by 1/2 pixel. This is not so much an issue when working past the diffraction limit, but in the case you mention "at say 1:1 where diffraction isn't limiting the sharpness", I think you'll be bound to find a lot of cases where the stacked result is not as sharp as an individual frame because of this effect.

--Rik

Edit: added info about the test.
Last edited by rjlittlefield on Wed Mar 21, 2012 1:52 pm, edited 2 times in total.

ChrisR
Site Admin
Posts: 8668
Joined: Sat Mar 14, 2009 3:58 am
Location: Near London, UK

Post by ChrisR »

Ah - I didn't know one could Select like that :smt023

but I'm having trouble with what follows.
Sounds like you drag in the whole lot, clear them out then drag the same still-selected files in again. :? :? :smt017

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

Post by rjlittlefield »

ChrisR wrote:Sounds like you drag in the whole lot, clear them out then drag the same still-selected files in again. :? :? :smt017
Exactly. But remember that I'm processing with different settings for "Stack every N'th frame". The point of clearing out the input files is to discard any alignment information that had been determined in earlier stacking.

--Rik

Post Reply Previous topicNext topic