Is it better to turn off all alignments in Zerene?

Have questions about the equipment used for macro- or micro- photography? Post those questions in this forum.

Moderators: Pau, rjlittlefield, ChrisR, Chris S.

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Is it better to turn off all alignments in Zerene?

Post by mjkzz »

Not able to get those test slides from Germany, I got some slides with grid and scale pattern in an attempt to test my 50X objectives (Nikon CFI ELWD 50x with NA of 0.45) because my last one was pretty bad and I am not very sure if this one is good enough. The test subject is a piece of round glass with grid on it, grid width is 200um, seems well made with clear lines. The tube lens is Raynox 250,so actual magnification is 31.25x.

The setup is a quick and dirty one, and I know the surface where the subject is placed on is not level so I did a stack of 34 images at 1.25um apart, you can obtain these images here .

I got some surprise observations from this stack of images.

First, if I turn all alignment options on, and run PMax on all 34 images, the result is kind of fuzzy, low contrast, and worst of all, severe chromatic aberration. Strange thing is, none of the image in the stack has such severe CA issue and even stranger, the lower part of the final image are mostly pink/purple where images in the stack have cyan/greenish color at same area. Please see the first image.

Second of all, the final stacked image with alignments on shows some alignments evidenced by sensor dusts, but the stacked image with alignment turned off does NOT show such "severe" misalignments, else the stacked image without alignment would be blurry.

Third of all, if I remove some of the images at the beginning, say only include images starting 20 to 41, the stacked image with alignments are less severe and stacked image with alignments turned off are better, too.

So, it is obvious that it is better to include only those images that have in focus part and discard all blurry images if possible.

But can the same be said about it that it is better to turn off all alignments if possible? From my others test images at 50x, it seems so, but because the subject has a lot of textures, it is hard to tell. But with subject with known pattern, this seems to be so.

Stacked Image With Alignments On
Image

Stacked Image With ALL Alignments Off
Image

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

Post by rjlittlefield »

Short answer: at 50X you should turn off all possible alignment options. In the ideal case that means all of them. If the stage is not stable enough (as seems to be the case here), then Shift X and Shift Y may still need to be selected. But rotate, scale, and brightness should definitely be turned off.

Here is what http://www.zerenesystems.com/cms/stacke ... nt_options says:
How should I set the Alignment options?

The best settings at Options > Preferences > Alignment depend on what you're doing.

The default settings are to correct for every common issue:
  • scale changes due to perspective and focusing;
  • X- and Y-shifts due to handholding, or due to jitter or misalignment of a focus rail;
  • rotation due to handholding; and
  • brightness changes typically due to flash variation.
However, in many cases one or more of those issues is ruled out by hardware when the stack is shot. If you're using a focus rail or a microscope, then it's unlikely that there's any rotation to deal with. If you're using continuous illumination instead of flash, then it's probably quite consistent from frame to frame. In some microscopy work, none of these issues are important.

The basic guideline is to turn off any alignment option that you don't need. That will make the alignment process go faster. In some cases, particularly at high magnification such as through a microscope, turning off unnecessary options will also give a better result image. This issue is discussed in a lot more detail in the forum thread at http://www.photomacrography.net/forum/v ... 9878#79878.
Your test case is unusual, especially the increase of CA. The increase in CA is mostly being caused by brightness "correction", which in this case is not correcting at all but instead is corrupting all frames after the first as it tries to adjust their contrast and brightness to match the completely OOF first image. Offhand I don't know why this adjustment has the effect of greatly increasing saturation (and thus increasing longitudinal CA), but by selecting "Show as adjusted" and looking at the source frames, that is clearly what's happening.

I downloaded your images and ran some experiments myself. To my eye the result image appears significantly sharper with Shift X and Shift Y turned on. With those turned off, small features end up slightly smeared, with the output looking as if there were motion blur.

--Rik

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Post by mjkzz »

Thanks Rik, yeah, there are definitely shifts for the first few images because the rail is changing direction which could have some jittery. I should have moved the rail higher up (lower down) and that should reduce that direction change effect -- all gears will get engaged. Surprisingly, it does not have much backlash, just some jitter, it should have little rotation shifts as it is dove-tailed with tight tolerance.

Yes, I turned on "Show as adjusted", for some reason the last image (source window) seems to be completely pink/purple.

I am including setup picture, just in case it is due to lighting. The lights are two 2W 4500K LEDs with CRI of 98+ (claimed), the third light was not turned on.

Image

ray_parkhurst
Posts: 2836
Joined: Sat Nov 20, 2010 10:40 am
Location: Santa Clara, CA, USA
Contact:

Post by ray_parkhurst »

I leave X and Y as it's rare that I see even two consecutive frames with acceptable alignment. But I never see significant rotation, so I turn that off. I also learned long ago when comparing telecentric with non-telecentric that the micro-scaling done to align frames for magnification causes a bit of blurriness in the scaled frames. The telecentric lens result, while the lens itself had lower NA than the non-telecentric ones, was sharper. After that learning, I have generally turned off frame scaling, and get a sharper output. Interestingly, this creates micro-distortions during frame transitions, so there is a tradeoff. It's wacky to compare a scaled vs non-scaled stack taken with a non-telecentric objective, with small movements in the regions between sharp frames. I suppose that's what I'd see if I turned off X and Y as well but I often see multiple-pixel misalignments, even at lower mag, so I don't want to see this level of wackiness in the final image.

Davids
Posts: 184
Joined: Sun Jan 31, 2016 2:20 pm

Post by Davids »

mkjzz,
I don't mean to move this thread off topic but could you describe the diffusers in your photo.
Thanks

lolhonk
Posts: 39
Joined: Sun Jan 11, 2015 4:58 am

Post by lolhonk »

OT2: This Setup looks very nice i love it @mjkzz!!

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

Post by rjlittlefield »

mjkzz wrote:the last image (source window) seems to be completely pink/purple
That's because it's all on one side of focus -- the side for which LCA gives pink/purple in the dark areas because red and blue are less focused than green is.

If you pull the last frame into Photoshop and slap on a hue/saturation adjustment layer that does about a +80 on saturation, you'll see the same thing. To make it more dramatic, add a Levels adjustment layer that pulls black up to a middle gray.

Do the same thing to your IMG_0032 that's focused in the middle of the target, and you'll see pink/purple on one side and green on the other. Here's what that looks like, after adjustment layers in Photoshop and "Show as adjusted" in Zerene Stacker:

Image

Image

It's an interesting question why the adjustment method used by Zerene Stacker appears to increase saturation in this case. In a quick investigation, it looks like the calculation in ZS is correctly preserving saturation as a number, but then the problem is that light gray at say 35% saturation looks a lot more colorful than dark gray at the same 35% does. I'm using 35% as an example because that's one of Photoshop's numbers for the OOF dark gray near the top of IMG_0032, before any adjustments. In Photoshop, the reason that two adjustment layers are required is that, by itself, Photoshop's levels adjustment actually reduces the saturation when lightening the dark grays in this image.

I've put this on the long list of stuff to think about in more depth if time becomes available. But it probably won't. As a matter of practice, the cure is to realize that brightness correction should not be used in this sort of situation, and just turn it off.

--Rik

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Post by mjkzz »

ray_parkhust: I am sure there are mechanical shifts due to change of direction, but as I said, if you discard some images from the beginning, ie, from img_0008 on, you can remove this type of thing.

In the following case, img_0020 to img_0041 were used (you can download them in my previous post). These are two images that are part of two stacked images from same set. These images are the second 1000x1000 block cut from upper left corner of the original respectively.

The first one has both X and Y alignment turned on per Rik's suggestion, and the second one without any alignment turned on. As you can see, the one with alignment shows larger sensor dust spot, this is due to alignment. The second one has smaller sensor dust spot, and in my eyes, they are identical to any of the same spot in all images in the stack, which it should be because they are dust spots that should not change.

The one without any alignment have less purple than the one with alignment and the lines are seemingly thinner.

The "motion blur" in the image without alignments is very pronounced, however, and this is where alignment can improve final result.


With X and Y Shift Alignments
Image

Without Alignments
Image
Last edited by mjkzz on Thu Jan 26, 2017 11:41 pm, edited 1 time in total.

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Post by mjkzz »

@Davids: they are cut from LED bulb and then I used fine sand paper to make it less shiny. But for this particular experiment, I am not using them.

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Post by mjkzz »

@lolhonk, yeah, when I started doing macro last year, I have no idea about it and bought a "digital microscope" stand, it was in my closet for a year and I finally found a use for it -- putting it on a granite stand (instead of its light base) and it seems to be very convenient to use, just like a microscope :-) The trick is how to mount the camera onto it, I will write something up on doing that :-)

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Post by mjkzz »

Thanks Rik, I am not very good at PS, I believe your word for it.

It seems even X and Y shift alignment can result some purple edge (please see my reply to ray_parkhurst) compared to image without alignment, that is the puzzling part.

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

Post by rjlittlefield »

mjkzz wrote:It seems even X and Y shift alignment can result some purple edge (please see my reply to ray_parkhurst) compared to image without alignment, that is the puzzling part.
It's hard to tell for sure just by looking at these images, but here is my best guess.

First some background...

With wide-aperture lenses, there is an issue that we have come to call "utilized aperture". What it means is that due to directional reflections from the subject, only part of the lens sees a subject feature. If this part of the lens happens to be off-center, then effectively the feature is being seen from the side, not straight down the optical axis. As a result, when the lens moves straight along the optical axis to step focus, the feature appears to move -- we might say it "virtually moves" -- a small distance laterally in addition to changing focus.

With very diffuse lighting and a subject that has complex geometry, this sort of virtual movement is what causes the "squirmy" effect with moth scales that I have described elsewhere.

But with more directional lighting and a subject that has simpler geometry, the virtual movements can be very much the same for every shiny feature on the subject. In this case it can be difficult to distinguish between a physical movement of the stage and virtual movement of all the bright features moving as a group.

My best guess is that with this subject and this illumination, we're seeing virtual movement of all the bright spots as a group, due to the utilized aperture effect. Meanwhile the dark lines and light surround are not moving, or are virtually moving in a different direction due to their different geometry in depth. In this scenario, the alignment computation is apparently locking onto the small bright spots and correcting for their virtual movement, which then causes the less well defined lines to shift, which in turn exposes the CA that is present in the source images.

Yes, this is a complicated and subtle problem. It is intrinsic to the way the light works. I do not know how to avoid it in general.

In some cases, using DMap instead of PMax will help, because DMap never merges information from more than two frames at any one pixel position. With high mag wide aperture objectives, there are persistent reports that best results are obtained by using DMap in combination with very small focus steps, maybe 1/4 or less of what you would think based on the nominal DOF.

But this is not foolproof. One difficulty with your grid target is that the features we want to lock onto for determining focus are quite sparse, so it is not obvious how to set the contrast threshold. Working with your images, I get best results with a slider setting of 95%, at which point almost the entire image is "black in preview", with just the edges of the lines and the white spots showing. I am used to setting such thresholds and I understand why they work, but to less experienced users it would look crazy. Another complicating factor is that when images are not shifted, either physically or virtually, then PMax is likely to reduce color fringing in the output, compared to what is actually present in the input.

As an example, compare the following crops:

PMax output, without shifting:
Image

Source image IMG_0026
Image

DMap output, without shifting:
Image

As you can see, the DMap output is faithful to the source image, and both of them have a lot more color fringing than the PMax output.

But then compare to the PMax output with shifting:
Image

To my eye this is a little sharper than the PMax without shifting, and has less color fringing than the original source, but more than the PMax without shifting.

So which one is best? Beats me -- choice of the consumer, I guess. Among the images above, there is no solution that gives the combination of sharpness and lack of CA that we would really like -- and which is not present in the input!

It's worth noting that the color fringing being shown here is lateral CA, not longitudinal CA that varies with focus. It quite possible that the best solution would be to preprocess the source images to remove lateral CA, then stack PMax with alignment.

That's a bit too much trouble for me to try right now. Instead, I show the result of postprocessing the output to remove lateral CA, using Photoshop's filter for Lens Correction with Fix Red/Cyan Fringe setting to -60 (determined by watching the image at 200% while moving the slider).

PMax with shifting, post-processed to remove lateral CA.
Image

I hope this helps. Thanks for the exercise.

--Rik

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Post by mjkzz »

Thanks a lot, Rik. Very interesting and a lot to digest, particularly the utilized aperture part, very interesting.

I measured the height of the big dust spot (upper middle) in both with and without alignment final images, they are about 32 pixels and 21 pixels (roughly) respectively, so the vertical shift is about 11 pixels (and seems to be upwards shift). My sensor has 4.4um pixels, so 11 pixels means 48.4um, and since magnification is 31.25, this means the shift would be about 1.55um if it were physical shift caused by the rail. Over total 27.5um depth of stack (22 images at 1.25um in previous post), this is quite large for a dove-tailed rail, so I believe maybe the virtual movment is in play.
In this scenario, the alignment computation is apparently locking onto the small bright spots and correcting for their virtual movement, which then causes the less well defined lines to shift, which in turn exposes the CA that is present in the source images.
I believe this is right because I used my stacking software that does NOT do anything to images in terms of color, contrast, etc and it yields the same CA issue, so the alignment algorithm "exposes the CA that is present in the source images" and might I add that the fusing algorithm is also doing something. [edited]

I have not used DMap features yet, but now, I will learn to use it.

Thanks again.

mjkzz
Posts: 1237
Joined: Wed Jul 01, 2015 3:38 pm
Location: California/Shenzhen
Contact:

Post by mjkzz »

Took another set of images, this time with diffuser and 3 2W LED lights. now I am totally convinced that it is the utilized aperture/virtual movement, analysis by Rik!!! The first image is done with XY shift adjustment and the second image is without any alignments, both uses IMG_0011 to IMG_0039 (not from beginning). Here are the images.

As can be seen, these two images are almost identical, just a little shift indicated by SLIGHTLY larger/wider dust spot. But this time, the lighting is very diffused vs original post where two lights shined onto the grid subject.

[Added]Also the grid lines have less spots inside them, this is because I used alcohol to clean it before use. Same objective, same tube lens, same camera, same rail as original post[/Added]

With XY alignment
Image

No Alignment
Image

Lighting setup in action
Image

Lighting setup
Image

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

Post by mawyatt »

Peter,

Curious about the diffusers you show.

Mike

Post Reply Previous topicNext topic