Can Zerene's scaling simulate focal length?

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

Moderators: rjlittlefield, ChrisR, Chris S., Pau

Beatsy
Posts: 2105
Joined: Fri Jul 05, 2013 3:10 am
Location: Malvern, UK

Can Zerene's scaling simulate focal length?

Post by Beatsy »

It's so I can composite an extreme macro of a foreground feature with a separate wide-angle 1:1 macro shot of the remainder of the subject and scene. The perspective (apparent focal length) of the extreme macro - done with objectives etc _ must match that of the 'normal' macro lens used (likely 15mm most often). I can match the lighting ok, but haven't cracked the focal length thing yet. Hence the speculation around (perhaps) scaling stack frames.

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

Post by rjlittlefield »

Zerene Stacker cannot do this directly, but you may be able to do what you want by "fudging in" appropriate Scale values for the RegistrationParameters.

I suggest the following process:
  1. File > New Project
  2. Load source images from the extreme macro stack.
  3. Stack > Align All Frames
  4. File > Save Other > Save Adjusted Input Images
  5. File > Close Project
  6. File > New Project
  7. Options > Preferences > Preprocessing, put a checkmark on "Add files to existing project as already aligned"
  8. Load the first adjusted input image as source file
  9. Load the remaining adjusted input images as source files
  10. File > Save Project As
  11. Outside Zerene Stacker, edit the newly saved .zsj project file as follows:
    • Search for a line that says <AlignmentControl.AlignmentSettingsChanged value="true" /> . If you find it, then change the value to "false" .
    • Copy the <RegistrationParameters>...</RegistrationParameters> block from the second source image into the first, replacing the <BrightnessCorrectionParameters null="true" />
      line that's already there.
    • In subsequent <RegistrationParameters> blocks, replace the <Scale value="1.0" /> lines with an appropriately increasing or decreasing set of values, for example 1.0001, 1.0002, 1.0003, etc.
    • Save the edited .zsj file.
    • Edited to add: see follow-up post below for an alternate method that avoid tedious line-by-line editing of Scale values in the .zsj project file.
  12. Inside Zerene Stacker again, File > Open Project to load the edited .zsj file.
  13. Stack > Align & Stack All
  14. File > Save Output Image and evaluate your work.
  15. Repeat steps 11-14 as necessary to match the perspective.
This should work OK if the DOF per slice of the extreme macro file is small enough that you do not get unpleasant artifacts as a result of the synthetic viewpoint causing features to not line up properly from one frame to the next.

If you have any problems, please contact me as support@zerenesystems.com so we can work out the bugs before reporting back here in the forum.

--Rik
Last edited by rjlittlefield on Sun Mar 01, 2020 9:52 am, edited 1 time in total.

Beatsy
Posts: 2105
Joined: Fri Jul 05, 2013 3:10 am
Location: Malvern, UK

Post by Beatsy »

Aha! I knew it! I was eyeballing the .zsj file and suspected the answer lay there. But it all appeared a bit, "no user serviceable parts inside", hence my question.

Thanks for the detailed answer Rik - really helpful and looks exactly what I need. I can't act on this immediately as I'm tweaking parts of the new rig for diatom work right now. Your instant comprehensive solution caught me on the hop, but I will tackle this next with studio-based tests/experiments.

Incidentally, I think my new, improved extreme rig will help some here. For the *very* small stuff of 250 microns or less (which this rig is particularly optimised for), I can get consistent 125nm steps when it's motorised (TBD) but can manage a fairly consistent 200nm manually already. This done by moving subject and local (not ambient diffused) lighting in unison. Larger subjects and deeper stacks are handled by moving the camera, with a minimum 1 micron step. The drive on the precision x,y,z stage stays straight to within 20nm across its full travel range of 2mm (positively agoraphobic dimensions :D ) so I could skip alignment and maybe dodge a few artefacts from that too. Anyway, all to be determined, and now I have a route to follow...

Thanks again for your help.
Cheers

Edit: regarding step size. I have had issues with stereos when using very wide angle lenses. Oversampling (silly small) step sizes helps, but only so far. At the more extreme short FLs - perspective becomes too strong and it falls apart no matter what the step size. I may have to settle for less wide than 15mm - maybe 25mm-35mm or so, but that's workable too...

Lou Jost
Posts: 5948
Joined: Fri Sep 04, 2015 7:03 am
Location: Ecuador
Contact:

Post by Lou Jost »

Can you find wide angle lenses which can be focused without changing the location of the entrance pupil? Those do exist, typically in small cameras like bridge cameras and point-and-shoot cameras. Maybe some reversed internal focusing wide angle lenses hold their exit pupil (now entrance pupil after reversing) fixed when focusing? Then you could focus by ring instead of moving the subject, this freezing perspective.

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

Post by ChrisR »

Steve would the result you're after, come from loading all the frames into photoshop and applying a Transform to each? Then stack with size adjustments turned off.
It certainly produces different perspectives.
I played with this a while ago with macros, & scripts in different image processors. Sorry too long ago to remember what worked best.
Things tended to get curvy :|
Chris R

mawyatt
Posts: 2497
Joined: Thu Aug 22, 2013 6:54 pm
Location: Clearwater, Florida

Post by mawyatt »

Beatsy wrote: Incidentally, I think my new, improved extreme rig will help some here. For the *very* small stuff of 250 microns or less (which this rig is particularly optimised for), I can get consistent 125nm steps when it's motorised (TBD) but can manage a fairly consistent 200nm manually already. This done by moving subject and local (not ambient diffused) lighting in unison. Larger subjects and deeper stacks are handled by moving the camera, with a minimum 1 micron step. The drive on the precision x,y,z stage stays straight to within 20nm across its full travel range of 2mm (positively agoraphobic dimensions :D ) so I could skip alignment and maybe dodge a few artefacts from that too
Steve,

Impressive optical bench based setup!! What type of precision motorized xyz stage are you using to get reliable 125nm steps with 20nm alignment across 2mm. I consider the THK KR20 1mm pitch rails under Trinamic control good to maybe ~300nm, the piezo stages might be good to ~30nm but only have a ~300um range, so 125nm across 2mm with 20nm alignment is impressive indeed :D

Best,
Research is like a treasure hunt, you don't know where to look or what you'll find!
~Mike

Beatsy
Posts: 2105
Joined: Fri Jul 05, 2013 3:10 am
Location: Malvern, UK

Post by Beatsy »

mawyatt wrote:
Beatsy wrote: Incidentally, I think my new, improved extreme rig will help some here. For the *very* small stuff of 250 microns or less (which this rig is particularly optimised for), I can get consistent 125nm steps when it's motorised (TBD) but can manage a fairly consistent 200nm manually already. This done by moving subject and local (not ambient diffused) lighting in unison. Larger subjects and deeper stacks are handled by moving the camera, with a minimum 1 micron step. The drive on the precision x,y,z stage stays straight to within 20nm across its full travel range of 2mm (positively agoraphobic dimensions :D ) so I could skip alignment and maybe dodge a few artefacts from that too
Steve,

Impressive optical bench based setup!! What type of precision motorized xyz stage are you using to get reliable 125nm steps with 20nm alignment across 2mm. I consider the THK KR20 1mm pitch rails under Trinamic control good to maybe ~300nm, the piezo stages might be good to ~30nm but only have a ~300um range, so 125nm across 2mm with 20nm alignment is impressive indeed :D

Best,
It's not a rail, it's a Prior/Martock x,y,z stage with a 3.5Kg load capacity. It has "coarse" adjustments that travel the full 2mm each direction, then secondary fine adjustments (on the end of the same shaft) that do near 10:1 reduction and only allow 245 microns of travel. Bit like a fine focus. Ticks are marked in microns on the scale and I've got quite adept at manually taking 5 steps for each tick (hence 200nm). A stepper attached to that fine control would easily achieve 8 steps per tick (400 steps/revolution) hence 125nm. There is no detectable backlash either (at the typical mags I use). A very precise piece of machinery. That's the "TBD" part - a new thing for me, but I won't go into detail here - will discuss on another thread later. Normal stacking is handled in the usual way by moving camera and lens on a wemacro rail in front of all that.

Here's the stage before I bolted it all into the rig - black box with knobs on in the bottom left corner. Silver gubbins on top is a probe positioner. That serves other purposes in the rig (as well as specimen holder) but that to be discussed another time.
Image

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

Post by rjlittlefield »

Beatsy wrote:Thanks for the detailed answer Rik - really helpful and looks exactly what I need.
You're very welcome.

With recent versions of Zerene Stacker, there's another trick that can make the process more convenient.

At Options > Preferences > Alignment, there's a checkbox titled "Automatically maintain export file inside project folder".

If you select that option, then when the project is saved, Zerene Stacker will automatically save registration parameters to a tab-separated-values text file named "RegistrationParameters.txt", in the project folder.

In addition, when re-opening the project, it will automatically read that same file, using its current contents to replace whatever is contained in the .zsj project file.

Because the tab-separated-value format can be easily read and written by Excel and other spreadsheet programs, using this feature can make it a lot simpler to alter the Scale values by just altering the RegistrationParameters.txt file instead of editing the .zsj project file.

Note that you still need to make sure that in the .zsj file, <AlignmentControl.AlignmentSettingsChanged value="true" /> gets converted to false, and that the first source image has a valid RegistrationParameters block. If the first image does not have a valid RP block, then re-alignment will be done automatically and all your externally computed Scale values will get ignored.

--Rik

dhmiller
Posts: 256
Joined: Mon Nov 11, 2019 7:42 am
Contact:

Post by dhmiller »

Do you happen to know if the Prior Martok XYZ Stage is still being manufactured? Couldn’t find it on a quick Google search.

Beatsy
Posts: 2105
Joined: Fri Jul 05, 2013 3:10 am
Location: Malvern, UK

Post by Beatsy »

Pretty sure this model isn't made any more. When I got it, it had been sat unused in a cupboard for 30 years. The grease on the probe positioner parts had hardened, as had the grease on one of the stage controls, but it all cleaned up nicely and runs good as new now.

I think ElliotScientific might have some existing partnership with Martock - x,y,z positioner stuff there.

dhmiller
Posts: 256
Joined: Mon Nov 11, 2019 7:42 am
Contact:

Post by dhmiller »

Thanks much - I did see a few of theirs.

Post Reply Previous topicNext topic