Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align: heavy distortion #33

Open
mviereck opened this issue Dec 16, 2022 · 4 comments
Open

align: heavy distortion #33

mviereck opened this issue Dec 16, 2022 · 4 comments

Comments

@mviereck
Copy link

Hello,

I have issues with the alignment of focus-stack. (I use it regulary with --align-only).
Some image stacks, notably those from microscopic capture, become heavily distorted.
If I add option --global-align, it becomes better, but still not good.
I've uploaded an example that is even better aligned if I don't align at all: https://e1.pcloud.link/publink/show?code=XZHmdYZlHYAeNKEzCX4sNhMuLJBIzcJfsY7

I assume one reason for the distortion is that regular macro images need some size adjustment due to different camera or lens positions.
However, microscopic captures would not need that.

I want to ask you if you could check this. My issue might already be solved if there is an option to disable distortion at all.

focus-stack 1.3-18-g92ec4a2, built Nov  3 2022 17:05:15
Compiled with OpenCV version 4.5.1
@PetteriAimonen
Copy link
Owner

Hmm, I get the same problem with that image set.
One thing that I notice is that there is quite a bit of dust on the sensor that moves in relation to the actual image content, but even that shouldn't cause such large errors.

I noticed that if I comment out the pre-alignment step on task_align.cc line 76, it works better for some reason:

 /* match_transform(256, true); */

That should be pretty much no-op when the stack is quite well aligned to start with, but it ends up messing up the alignment instead.

I'll try to find out why this happens.

PetteriAimonen added a commit that referenced this issue Dec 16, 2022
The OpenCV default setting of 5 would end up stripping too much
detail from low-contrast images, resulting in bad alignments.
@PetteriAimonen
Copy link
Owner

OpenCV had a quite heavy blur in findTransformECC() by default, which blurred away all the detail in these images. After that the rough alignment was quite random, and that messed up the fine alignment also.

I adjusted the parameters a bit, which seems to have fixed this case and still works well for other image stacks also.

PetteriAimonen added a commit that referenced this issue Dec 16, 2022
The OpenCV default setting of 5 would end up stripping too much
detail from low-contrast images, resulting in bad alignments.
@PetteriAimonen
Copy link
Owner

(Sorry, had a small mistake first time I pushed that commit, should work now)

@mviereck
Copy link
Author

This looks very good now, thank you very much!
And thanks for your quick reply and fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants