PetteriAimonen / focus-stack

Fast and easy focus stacking
MIT License
328 stars 48 forks source link

Iterations do not converge #38

Open scholzri opened 1 year ago

scholzri commented 1 year ago

Hi, first of all, thank you for this great piece of software! It works good for most of my fluorescence microscopy images, but in some cases it fails to align the images of my z-stack properly. For example:

dataset: https://we.tl/t-q8NR38KeS1

command: focus-stack image*.tif --output=projection.tif --no-whitebalance --no-contrast --denoise=0 --consistency=0 --batchsize=8 --align-keep-size --full-resolution-align

error:

Task Align image1.tif to image10.tif on thread 23 failed with exception:
OpenCV(4.2.0) ../modules/video/src/ecc.cpp:572: error: (-7:Iterations do not converge) The algorithm stopped before its convergence. The correlation is going to be minimized. Images may be uncorrelated or non-overlapped in function 'findTransformECC'

Do you have an idea what the cause of the problem could be?

Thanks!

PetteriAimonen commented 1 year ago

It appears that the files are stored as 16-bit TIFF, but the values in the files are only 8-bit. This causes the files to appear almost completely black when opened in e.g. GIMP.

Focus-stack doesn't currently support 16-bit processing (issue #34), so it converts the files to 8-bit mapping 65535->255, which causes black images. The processing then fails because there is no information in the images.