Explaining Zerene Stacker alignment parameters

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

Moderators: rjlittlefield, ChrisR, Chris S., Pau

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

Explaining Zerene Stacker alignment parameters

Post by rjlittlefield »

This post is to answer occasional questions about what the various registration values mean in Zerene Stacker (ZS).

We're talking here about the values tagged as <RegistrationParameters> and <BrightnessCorrectionParameters> in a .zsj file, and the corresponding values printed into the console log.

Registration Parameters

The parameters describe a scale+rotate+shift transformation that converts the corresponding source image from its original form to its form as aligned within the stack.

Scale is a ratio: 1.181 would turn a 2000 pixel line into a 2362 pixel line (because 1.181*2000 = 2362).
Rotate is in radians clockwise: 0.080247 gives 4.6 degrees (because 0.080247*180/pi = 4.6 [approximately]).
XOffset and YOffset are shifts (offsets) expressed as a fraction of frame dimension: 0.006 with 2500 pixels gives a 15 pixels shift (because 0.006*2500 = 15).

Scale and rotation are done around the image center, followed by the shifts.

A good way to confirm what these values mean is to use Photoshop to transform an image by specific numeric amounts, then feed into ZS the original and transformed images, have ZS do an Align All Frames, and see what parameter values ZS ends up recovering. Appropriate Photoshop operations are Image > Image Size... with Resample and Percent for scale, Image > Canvas Size... with a corner selected for shift, and Image > Image Rotation > Arbitrary for rotate.

In doing these tests, there are three things to watch out for.
1) You have to make sure that the final transformed image has the same pixel dimensions as the original, or ZS will refuse to process them. Image > Canvas Size... is a convenient way to do this.
2) Corrupted border regions can mess up the alignment. A good way to avoid this is to scale up and then crop to the center of the enlarged image.
3) If you test with multiple transformations at once then be aware that for some parameter values Photoshop may produce unexpected partial pixel shifts. These are due to Photoshop's adjustment of canvas size when rotating and resizing. They are difficult to avoid, so just expect them to be there and don't agonize over say a half-pixel discrepency between the shifts you intended to create and the ones recovered by ZS.

Limit flags indicate whether the final parameter values ended up being constrained by the associated limits. The value is the sum of 1, 2, 4, 8 for xoffset, yoffset, rotation, and scale respectively. Non-zero limit flags should be considered an error condition because the associated registration parameters will not bring the source image into best alignment.

Brightness Correction Parameters

The adjusted pixel value is computed as

Code: Select all

result = Math.pow(pixelValue*mScale,mGammaAdjustment);
The scale and gamma adjustment values are chosen for each image so as to give constant mean and variance of intensity values across all images.

--Rik

Edit 9/27/2020: to fix formula that got HTML encoded in forum software upgrade earlier this year.

TheLostVertex
Posts: 320
Joined: Thu Sep 22, 2011 9:55 am
Location: Florida

Post by TheLostVertex »

Thank you for the detailed information here.

So would my math be correct in calculating frame movement as:

(Sensor Dimension / Magnification) * ZS Offset

Since we are looking to figure out the captured field size's movement. Also, I assume based on observation that a positive fraction is to the right/up, and negative left/down?

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

Post by rjlittlefield »

TheLostVertex wrote:So would my math be correct in calculating frame movement as:

(Sensor Dimension / Magnification) * ZS Offset

Since we are looking to figure out the captured field size's movement.
That looks correct to me.
Also, I assume based on observation that a positive fraction is to the right/up, and negative left/down?
Take another look, please. I'm seeing positive fraction as meaning the image gets shifted right/down, not right/up. Right/down is consistent with a column/row coordinate system with rows increasing downward, as typical for images.

--Rik

TheLostVertex
Posts: 320
Joined: Thu Sep 22, 2011 9:55 am
Location: Florida

Post by TheLostVertex »

rjlittlefield wrote:
Also, I assume based on observation that a positive fraction is to the right/up, and negative left/down?
Take another look, please. I'm seeing positive fraction as meaning the image gets shifted right/down, not right/up. Right/down is consistent with a column/row coordinate system with rows increasing downward, as typical for images.

--Rik
You are correct. I must have read the wrong file's alignment info when looking at it before. :oops:

Bill Eldridge
Posts: 161
Joined: Thu May 23, 2013 6:46 am
Location: Richmond, Virginia, USA

Post by Bill Eldridge »

Thanks for this post. And the remaining parameter?

<LimitFlags value="0" />

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

Post by rjlittlefield »

Bill Eldridge wrote:Thanks for this post. And the remaining parameter?

<LimitFlags value="0" />
rjlittlefield wrote:Limit flags indicate whether the final parameter values ended up being constrained by the associated limits. The value is the sum of 1, 2, 4, 8 for xoffset, yoffset, rotation, and scale respectively. Non-zero limit flags should be considered an error condition because the associated registration parameters will not bring the source image into best alignment.
In other words, <LimitFlags value="0" /> means that none of the alignment parameters were constrained by the limits, so the alignment is at least locally optimal.

--Rik

Bill Eldridge
Posts: 161
Joined: Thu May 23, 2013 6:46 am
Location: Richmond, Virginia, USA

Post by Bill Eldridge »

Hello, Rik and TheLostVertex,

I'm posting this here because something's wrong with messaging on my account: I replied to a request from TheLostVertex for Bugslabber five hours ago, but the message is still
sitting in my Outbox, along with a message I sent to a fellow Richmonder which has been idling for the last ten days (Dwight, if you're reading this, hello!).

I'll delete this post after you both have read this. Send me a message, but don't expect a reply via PM!
-----------------------
Rik: Stimulated by this post, "Ant" and "Tiny focus steps", I've programmed ZS Data Digger. Aside from a few small fixes in the chart labeling, I believe it's pretty much ready to go
except for one minor detail:

When graphing alignment parameters, I'm showing units to the right of the chart:

XOffset/YOffset:
frame ratio, pixils, mm or µm

Scale:
frame ratio or percentage

Rotate:
radians or degrees

Can you suggest unit names to be displayed for BrightnessScale and GammaAdjustment? Any other suggestions?

ZS Data Digger 0.9.5 for Mac is here [edit: link deleted -- stay tuned for v1.0]. The Windows version is here [edit: link deleted].
---------------------
TheLostVertex: The fully functional and stable Bugslabber 0.9.6 for Mac is here [edit: link deleted. Forum members, message me and I'll send it].
The Windows version is here [edit: link deleted. Message me.].
---------------------------------------------------------------------
ZS Data Digger screen captures scaled down to 1024 pixils wide:

(By the way, the "Limits reached" display is fake: I put some limit flags in the .zsj file for testing. The optional Magnification field, which allows conversion of XOffset and YOffset
values from frame ratio to mm or µm, should contain a value less than 1 for this image.)

Image

Image
Last edited by Bill Eldridge on Sat Sep 21, 2013 7:14 am, edited 5 times in total.

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

Post by rjlittlefield »

Bill Eldridge wrote:I'm posting this here because something's wrong with messaging on my account...the message is still sitting in my Outbox...
There's probably nothing at all wrong with messaging on your account. It is normal behavior for messages to sit in the sender's Outbox until the recipient logs in and reads them. At that time, and not earlier, the message will also migrate from the sender's Outbox to the sender's Sentbox.

There may or may not be something wrong with messaging on the recipients' accounts. If they have notifications turned off or have specified an unusable email address or notification emails are being filtered as spam, and/or their browser is running a popup blocker, then they may have no idea that a message is waiting for them.
Rik...Can you suggest unit names to be displayed for BrightnessScale and GammaAdjustment? Any other suggestions?
BrightnessScale and GammaAdjustment sound fine for parameter names. As for naming the units, I have no idea other than pointing to the formula.

I'm curious about the shooting setup that produced the sample data. The large and consistent scale change from frame to frame is typical of low magnification stacks shot with mechanical assistance. The offset and rotate curves are intriguing, however, particularly the high correlation in up/down jogs between XOffset and Rotate. I'm wondering if those accurately reflect physical movements, or if they're somehow due to changes in image appearance with focus.

--Rik

Bill Eldridge
Posts: 161
Joined: Thu May 23, 2013 6:46 am
Location: Richmond, Virginia, USA

Post by Bill Eldridge »

Hi, Rik, thanks for the speedy response.

I chose this stack because it has only 18 images, handy for testing. I'm embarrassed to post it here: it's one of my earliest efforts. But I'll be deleting this and my previous post
later tonight or tomorrow, so what the heck [edit: well, I guess I'll leave it here since it's part of the discussion. For a more successful stack of this Painted Lady from the same
shooting session, see this].

Canon 100mm USM macro lens, automated focusing with Magic Lantern. Subject on table, camera on tripod shooting down at maybe a 45 degree angle.

Image
Last edited by Bill Eldridge on Sat Sep 21, 2013 5:51 am, edited 2 times in total.

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

Post by Chris S. »

rjlittlefield wrote:I'm curious about the shooting setup that produced the sample data. The large and consistent scale change from frame to frame is typical of low magnification stacks shot with mechanical assistance. The offset and rotate curves are intriguing, however, particularly the high correlation in up/down jogs between XOffset and Rotate. I'm wondering if those accurately reflect physical movements, or if they're somehow due to changes in image appearance with focus.
(Italics added by me.)

I must be missing something in Bill's screen grabs. I think I'm seeing offset and rotation results only--nothing for scaling. Where are the scale changes shown?

Thanks,

--Chris

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

Post by rjlittlefield »

Chris S. wrote:I must be missing something in Bill's screen grabs. I think I'm seeing offset and rotation results only--nothing for scaling. Where are the scale changes shown?
The images have changed since I looked at them. The ones displaying at this instant do not show scale. (Looks like Admin is going to have a series of posts to delete!)

Looking back in my browser history, I see that I was looking at this image:

Image

--Rik

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

Post by Chris S. »

Thanks, Rik, for solving that mystery. While it might seem trivial, it was bugging me quite a bit. I kept looking at the graphic and back at your comments, trying to figure out what I was missing.

Feel free, of course, to delete my posts here when the time comes. Or, if Bill is cool with the idea, maybe move the pertinent bits to another thread? There are some interesting and useful elements.

As for the correlation between x-offset and rotation, could the camera be jiggling a bit where the bayonet mount joins the lens? (This presumes that the image stack was shot with a collar-mounted lens.) My D200 body used to have a bit of play, at this junction, when mounted on my tube lens assembly. After a random number of shots, during some stacks, there would occur a small, sudden rotation; after another random number of shots, there would occur a counter-rotation to the original point. Suspecting a bit of looseness at the camera/tube lens junction, I added a pair of Arca-Swiss style clamps that hold the camera very firmly in place relative to the tube lens assembly. With this addition, the random rotation vanished. Interestingly, these clamps are not needed with my D700 body. I've wondered if this may be an issue for other folks. (BTW, Zerene Stacker handled this rotation with ease--but my preference is to turn all such adjustments off, whenever possible.)

--Chris

Bill Eldridge
Posts: 161
Joined: Thu May 23, 2013 6:46 am
Location: Richmond, Virginia, USA

Post by Bill Eldridge »

Wow, Chris S., what a beamish boy you are! Yes, I had the the Canon 100mm in a tripod collar, with the camera (Canon 60D) free to dance to the beat. Hats off to Rik for spotting this issue
in the data, and to you for coming up with a plausible diagnosis.

As to the changed screen grabs, I posted the version showing four parameters, then decided that I wanted to depict the fact that [none] is an option for the parameter popup menus.
While preparing the new grabs, Rik beat me to the punch. No flies on him!

Rik, you can leave all this here if you like or move it as you wish. I've got a small issue with the variable layout of the chart labels misbehaving, but I should be able to run that to ground today
and officially announce the (free) app in this Technique forum, with a link to the announcement from this FAQish post of yours. For now, though, I'm deleting the download links.

This idea for this app came while reading TheLostVortex's Ant post. He used Rik's Tiny focus steps: how to make them, how to measure them approach to graph the action of his brother's wooden
focus rail contraption. I wondered if he'd had to laboriously copy and paste each bit of alignment data from the Zerene Stacker project file by hand and wanted to provide an easy way to extract it.
Then I figured that as long as I was extracting it, I might as well graph it... This led me down quite a rabbit hole, as I had to build a custom graphing engine from scratch.

Post Reply Previous topicNext topic