Zerene settings question

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

Moderators: rjlittlefield, ChrisR, Chris S., Pau

realjax
Posts: 138
Joined: Wed May 19, 2010 12:22 pm
Location: Netherlands
Contact:

Zerene settings question

Post by realjax »

Hi,

I was wondering what changing these values do. If I set shift x and y to say 5% I can see a larger area of the input images being used, which is good but there's probably a downside to it as well :)
Can someone tell me a bit more?

Image

Used an image from Zerene's website here, hope that's ok ?
Jacco

ChrisLilley
Posts: 674
Joined: Sat May 01, 2010 6:12 am
Location: Nice, France (I'm British)

Post by ChrisLilley »

My understanding, which is probably flawed,is that increasing these values gives ZS a larger problem space to explore, which may make it slower and may make it misalign images because it latches onto a bit of detail that would only line up if there was a huge scale and rotate to make it line up.

If your equipment is solid and your focus stacking method does not produce large scale shifts from one end of the stack to the other (i.e. you are not focusing by changing the position of the rear standard of the bellows), then my understanding is that the best results are obtained by setting these to the smallest values that still result in correct alignment.

Shift needs to be set to a small value, rather than off, because even the best setup will have some small shift at the pixel level due to mechanical inaccuracies and vibration. Similarly scale should be set to small values rather than disabled.

For stacks which are not handheld, rotate can be switched off, in my experience.

Similarly if lighting is well controlled, brightness can be switched off (but better be sure that your flashes are giving really repeatable power per flash).

I'm sure Rik will chime in here and explain which of my assumptions are faulty. :)

realjax
Posts: 138
Joined: Wed May 19, 2010 12:22 pm
Location: Netherlands
Contact:

Post by realjax »

Thanks Chris, a lot more clear now.
..that increasing these values gives ZS a larger problem space to explore..
Wouldn't that be decrease ?
Jacco

ChrisLilley
Posts: 674
Joined: Sat May 01, 2010 6:12 am
Location: Nice, France (I'm British)

Post by ChrisLilley »

realjax wrote:Thanks Chris, a lot more clear now.
..that increasing these values gives ZS a larger problem space to explore..
Wouldn't that be decrease ?
No. Increasing the values (to allow say a 50% scale change) means that it needs to search for a picel that matches, not just nearby, but further away.

Similarly increasing the amount of rotation means that it needs to search for something that matches within a wider span of possible rotations.

realjax
Posts: 138
Joined: Wed May 19, 2010 12:22 pm
Location: Netherlands
Contact:

Post by realjax »

I see! I'll lower that significantly then. Thanks.
Jacco

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

Post by rjlittlefield »

Chris, your explanation looks fine.

Coincidentally, I had another user asking about these same parameters yesterday. Here is what I replied to him:
Alignment in ZS is done by choosing one image as master, then essentially registering each other image to the master by a rigid transformation that can incorporate shift, rotate, and scale. The shift limits are in terms of frame width and height, the scale limit is variation from 100% (no change in scale), and the rotation limit is in degrees.

Under most circumstances the defaults work fine. If your setup physically prevents rotation of the camera, then you can uncheck Rotation, and stacking will go a little faster. If your rig is very stable and perfectly centered with focus stepping straight along the optical axis then you can uncheck Shift X and Shift Y. This is unusual with cameras but common for microscopy. Unchecking Scale is recommended for high magnification work (10X or higher on sensor) to keep the software from being misled by blooming of out-of-focus features, but at lower magnifications unchecking Scale will usually produce radial smearing or echoing. When in doubt, try that one both ways to see what works best.

The numeric values seldom require attention. Exceptions include some stereo microscopy work where shifts larger than 20% are seen, and focus stepping by moving the rear standard of a bellows, where scale changes greater than 20% may occur.
The situation described by Jacco is unusual, that reducing the shift limits results in preserving a larger area while also not introducing obvious artifacts. This can happen when large shifts accumulate in a long stack, while from frame to frame the shifts are small.

I am curious to know, what is the setup to shoot the stack?

False matches as described by Chris don't happen very often, but they definitely can happen once in a while. and the limits are in there to help prevent those.

No problem using the image from the Zerene website. Permission granted, and in any case exactly the same image could have been captured off any Windows XP screen.

--Rik

realjax
Posts: 138
Joined: Wed May 19, 2010 12:22 pm
Location: Netherlands
Contact:

Post by realjax »

Thanks Rik!
... reducing the shift limits results in preserving a larger area while also not introducing obvious artifacts.
Ah, I have not run an actual stack yet with these changes. I merely lowered them and noticed a larger area being used while stacking, which I aborted :)
I'll run a full stack again tonight and report back.
I used a horizontal setup by the way.

Thanks.

(I need to upgrade my hardware, as it easily takes 30 minutes to do a 100 images Dmap stack on my system)
Jacco

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

Post by rjlittlefield »

realjax wrote:Ah, I have not run an actual stack yet with these changes. I merely lowered them and noticed a larger area being used while stacking, which I aborted :)
In that case, I'm guessing that the smaller shift limit somehow changed the automatic decision about which end of the stack to start with. Once that decision was made, stacking would proceed as usual until some point quite a ways through the stack, when enough shift accumulated to again run up against the limit. No artifacts would have been introduced until that happened. In addition, since you were probably watching at reduced scale, even when the artifacts appeared they might not have been evident. And finally, if you were using DMap, you probably wouldn't have seen the artifacts even at 100% zoom because of the hard boundaries between frame selections during pass 1.

I'm looking forward to seeing results from full runs.

--Rik

lauriek
Posts: 2402
Joined: Sun Nov 25, 2007 6:57 am
Location: South East UK
Contact:

Post by lauriek »

Also when hand held stacking because I'm so cack-handed I have to up the shift values to around 20% in order for the images to be align-able...

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

Post by rjlittlefield »

Good point about hand held stacking needing relatively large limits. 20% is default though.

--Rik

Chris S.
Site Admin
Posts: 4042
Joined: Sun Apr 05, 2009 9:55 pm
Location: Ohio, USA

Post by Chris S. »

Rik, I wonder if you would mind commenting on this portion of the above?
Shift needs to be set to a small value, rather than off, because even the best setup will have some small shift at the pixel level due to mechanical inaccuracies and vibration. Similarly scale should be set to small values rather than disabled.
I've wondered about this myself. If I understand your recommendations, it is not necessary to leave a small value for shift and scale with a solid, centered rig. Indeed, I've seen some of my stacks improve by unchecking these options. But I could use a bit of clarification on this.

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?

Thanks,

--Chris

lauriek
Posts: 2402
Joined: Sun Nov 25, 2007 6:57 am
Location: South East UK
Contact:

Post by lauriek »

rjlittlefield wrote:Good point about hand held stacking needing relatively large limits. 20% is default though.

--Rik
Oh sorry I assumed 5% was the default as that's what mine always goes to, obviously something I set way back! ;)

realjax
Posts: 138
Joined: Wed May 19, 2010 12:22 pm
Location: Netherlands
Contact:

Post by realjax »

rjlittlefield wrote:In that case, I'm guessing that the smaller shift limit somehow changed the automatic decision about which end of the stack to start with.
Rik, once again you are spot on. I had also reversed the order of the stack. I never mentioned it because I thought it wouldn't really make a difference. I figured that aligning is aligning, be it from the top down or the other way around. Turns out I was wrong :)

I did run a new stack yesterday with a 10% setting and indeed some small artifacts appeared but nothing major.

I am stacking an image of a tiger beetle. Lot's of bristles, colours and hairs all over the place, not to mention an antler in a difficult position. Zerene has -understandably- quite some transparency issues with this image, (especially with the antler and changing the direction didn't improve it much) so I am now reverting to partial stacking which looks promising.

Thanks for all your help so far, much appreciated!
Jacco

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

Post by rjlittlefield »

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.

Image

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:

Image

Accumulating these incremental scale changes across the entire stack (167 frames) produces the following result:

Image

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

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

Post by rjlittlefield »

realjax wrote:I am stacking an image of a tiger beetle. Lot's of bristles, colours and hairs all over the place, not to mention an antler in a difficult position. Zerene has -understandably- quite some transparency issues with this image, (especially with the antler and changing the direction didn't improve it much) so I am now reverting to partial stacking which looks promising.

Thanks for all your help so far, much appreciated!
You're very welcome. Partial stacking is definitely the best way to attack the transparency problem. Changing the direction (reversing the stack) will have minimal effect because the software really doesn't understand about opaqueness and front-versus-back. It only understands about high contrast versus low.

--Rik

Post Reply Previous topicNext topic