Chris S. wrote:Rik, I wonder if you would mind commenting on this portion of the above?
Setting alignment parameters is a lot like trying to pick medications to deal with some disease. The disease has symptoms that are relieved by medications, but the medications themselves have side effects. As a result, the trick is to choose medications that leave you with the best combination of unrelieved symptoms and induced side effects. If the disease symptoms are severe and the medication side effects are mild, you use lots of medications. If the disease symptoms are mild and the medication side effects are severe, you may be better off to use no medications at all.
I think this is an apt analogy, so let's see if we can keep it going.
The "disease" in this case is really a set of interactions between finite perspective of the lens, lateral and longitudinal movement of the entrance pupil, and changes in scale due to focusing mechanisms. These interactions result in misalignment of corresponding subject features in adjacent frames. If that misalignment is big enough, then depending on the stacking method it can result in visible blurring, smearing, echoing, ghosts, and bumps on linear features such as bristles. The blurring, smearing, and so on are the "symptoms".
The "medications" are of course the various controls on alignment -- whether the alignment process is allowed to correct for X- and Y-shifts, scale changes, and rotation. And finally the "side effects" are again blurring, smearing, echoing, ghosts, bumps on linear features, and in addition unwanted scale changes and/or skewing of the stack that can mimic changes in perspective.
Good grief! Why would we ever want to use a set of medications whose side effects include all of the original disease symptoms, plus a couple of new ones?!
Of course the answer is that for many "patients" (stacks) the side effects do not appear, while the disease symptoms would be severe. If you have ever processed a typical close-up stack with alignment turned off, you know that the result is awful. Edges don't line up, PMax produces awful ghosting, and so on. At the very least, scale adjustment is required, and if you step focus by any means other than turning the focus ring, you usually need the shifts also because it's almost impossible to perfectly align the movement and optical axes.
On the other hand, for many stacks shot through a microscope objective the disease symptoms are very mild. At high magnification and wide aperture, the depth of field becomes so shallow that there is no
significant change in scale from one frame to the next. Similarly, the shallow DOF combined with the precision of the focus block means that there is no
significant shift from one frame to the next. I emphasize "significant" because almost always there is
some change in scale and/or shift between frames. But if those changes are too small to visibly degrade the stacked image, then they don't matter.
On the other hand, small changes do add up, and this provides an opportunity for side effects to appear. The most obvious example occurs when a shift of 0.5 pixel has accumulated, but the scale has remained unchanged. Alignment is of course a resampling operation, and what the 0.5 pixel shift means is that the resampling has to average neighboring pixels. The canonical example is that 0,254,0,254,0,254 turns into 127,127,127,127. Of course in practice the degradation is not this bad, but nonetheless there is guaranteed to be some loss of detail near the level of individual pixels.
In addition, small changes may add up incorrectly. More precisely, small changes may be systematically mis-estimated while analyzing the images, and the erroneous estimates then add up to significant errors. My favorite example here is the fruit fly that appears on the Zerene Stacker home page. Here are three renditions of the same stack, processed with different alignment settings.
In side-by-side views the differences are not so obvious, but in this animation they cannot be missed. The settings of "Default, everything on" and "Shifts, but no scale or rotation" produce clearly different perspective, with the fly appearing significantly more "bug-eyed" with Default than with Shifts only. Closer study of the upper left corner shows a couple of bristles that become bent and/or extended when the shifts are turned off also.
Regarding scale, what's happening is that the alignment procedure is being systematically misled by noise and out-of-focus elements. This stack was shot by changing the subject-to-lens distance in even increments. As a result, the change in scale between adjacent frames
should be constant throughout the stack. But here are the incremental scale changes found by the alignment process:
Accumulating these incremental scale changes across the entire stack (167 frames) produces the following result:
How does this compare to the ideal result? Well, I really don't know! By using a carefully selected calibration target, it is possible to accurately measure the scale change from frame to frame. But I didn't think about that when I shot this stack, now almost 3 years ago, and I'm not sure that I have all the information that would be needed to do the measurement now. (It depends on knowing exactly which objective was used, in addition to the magnification and focus step.) I'm guessing, based on considering the content of individual frames in this stack, that the correct value would be around 0.0002 per frame. If that's correct, then the total scale change over the entire stack would be around 3.3%, versus the 0% that is provided by turning off scale altogether and the 7.5% that is provided by adjusting scale based on analysis of each source image. Notice that turning off scale adjustment essentially
imposes orthographic projection, just like what would be provided naturally by telecentric optics. In the case of high magnification, wide aperture, and shallow DOF, this works fine because the scale change per frame is small enough to ignore without getting echoes or smearing.
I'm not sure that this directly answers your questions, but hopefully it makes some of the issues more clear.
Quick summary: At low magnifications, the default settings to adjust everything are safe, effective, and relieve what would otherwise be severe symptoms. At high magnifications, the adjustments may cause side effects that are more severe than the symptoms they are intended to relieve. It is not always easy to predict when this will occur, so you may have to try it both ways and see what happens.
By the way, to answer a question before it's asked: yes, I have thought about allowing scale change per frame to be specified by the user. It's "on the list", along with figuring out and documenting some reliable procedure to allow the right number to be accurately measured.
Chris, to specifically answer your questions:
Also, I would expect that in a stack hundreds of images deep, there would be some cumulative scaling that would need to be taken care of, unless the lens used is perfectly telecentric. So do these parameters apply to random variation between images, so that even if unchecked, ZS can deal with systematic changes that occur along the stack?
As noted above, you can just ignore scaling in high mag shallow DOF stacks, and the result is indistinguishable from what you would get with telecentric optics. ZS does not distinguish between random variation between images and systematic changes that occur along the stack. The limits apply to the overall transformation from each source image to its aligned form.
--Rik