-
Notifications
You must be signed in to change notification settings - Fork 1
imfuse: Workflow to find good parameter sets
Martin Viereck edited this page Jan 6, 2023
·
7 revisions
This page is out of date. Please check out the new guidance at https://github.com/mviereck/microscopy-tools/wiki/How-imfuse-works
Use already aligned stack images for imfuse
.
-
stackfuser
provides some options to align images. - For manual alignment with
align_image_stack
: A good parameter set isalign_image_stack -m -C --use-given-order IMAGES
- Option
-m
adjusts the magnification of the images. That normally makes sense for macroscopic stacks, but not for microscopic stacks. -
align_image_stack
can be incredibly slow with large numbers of images because it tries to compare all of them at once with a square effect of resource usage.stackfuser
usesalign_image_stack
with an iterative workaround making it much faster. - Check if the images are aligned well. It might help to increase the default number of control points from
-c 8
to a higher value like-c 32
. - Further hints for parameters of
align_image_stack
: https://photo.stackexchange.com/questions/83178/cannot-align-images-with-align-image-stack - You can align the aligned images again as well.
- Option
- Run with
--cache
to allow faster test runs with different parameter sets. - Run
imfuse --cache --background=enfuse IMAGES
to get a referenceenfuse
result for comparision. - To fasten the parameter finding process use a significant section of the image (crop all aligned images exactly in the same way).
- To resize all aligned images is not a good idea, because radius and sigma of mask generators are working with real number of pixels. The parameters found for a resized image will not fit the original size.
-
stackfuser
provides an interactive crop option. - To crop an image part manually see https://github.com/mviereck/microscopy-tools/issues/12#issuecomment-795434745
- Dark objects might give better results if the images are overexposed to get detail and contrast in dark areas. The final result can be darkened afterwards.
- Important option
--less
is very slow. Check out the other options first without--less
and add it finally. - These options can be changed at low cost after a build with
--cache
:--alpha
--background
--finalblur
--threshold
imfuse provides several mask generation options.
- Try with
--dog
,--log
or--wavelet
for macro images. - Try with
--diffstat
,--morphology
,--sobel
or--freichen
for micro images.
Most mask generators take a sigma or radius as an argument. This can be seen like a brush size. Greater values generater a thicker brush.
- The default sigma (or radius like in
--diffstat
) is very low to get as much detail as possible (fine brush), e.g.--dog=s0.3
. That can lead to noise. - To reduce noise, try with higher sigma (thicker brush), e.g.
--dog=s1
. A thick brush / high sigma looses some detail, but enhances contrast and reduces noise. - A thick brush also helps to close some gaps, e.g. inner areas of hairs.
- A very thick brush, e.g.
--dog=s2
can cause an unsharp halo around foreground objects. It can also cause closed gaps between hairs where this is not desired.
Try to find a brush size that shows enough detail and removes most of the noise. Increase sigma / brush size until moist of the noise in contrast rich areas is gone. Don't care for noise in bokeh yet.
- You can combine multiple brush sizes to get the best from them, e.g.
--dog=s0.3 --dog=s1
. This will generate two masks and merge them together.
- Try
--cutblur
for a softer cut. Makes the image a bit blurry, but more natural. Helps a bit to close gaps. - Strenghten mask contrast with
--maskblur
- Some issues of
--cutblur
can be outweighted with--maskblur
.
- Some issues of
- Use option
--less
to strenghten weak foreground objects that might be overwritten by strong contrast background.
After finding an appropriate brush size / sigma, some low contrast areas will still show noise.
- Check the percentual part of low contrast with option
--threshold
. - Default
--threshold=p50
cuts off areas with a contrast less significant than 50%. The transparent result gives you an idea where option--finalblur
will take effect. Sometimes a value less than50
is more appropriate.- A colored background might be more helpful to assess the threshold effect than the default transparency. Add
--background=red
.
- A colored background might be more helpful to assess the threshold effect than the default transparency. Add
- Proceed without
--threshold
after you found a value that removes noise without removing well done areas. - Try
--finalblur
to blur low contrast areas. Use the percent value you found wth--threshold
, e.g.--finalblur=p25
. Increase the blur if needed with--finalblur=p25,s10
.
If --finalblur
isn't enough to generate a nice bokeh:
- Make low contrast areas transparent with
--alpha
or--threshold
.- Prefer smooth
--alpha
over rude--threshold
. - Adjust transparency of
--alpha
if needed. Compare https://github.com/mviereck/microscopy-tools/issues/9
- Prefer smooth
- Put the transparent result on a background. Try
--background=ARG
withmin
,enfuse
orsaturation
. Compare https://github.com/mviereck/microscopy-tools/issues/11- To get an idea of the background, run it without any mask option to see the generated background image only. E.g.
imfuse --cache --background=min IMAGES
.
- To get an idea of the background, run it without any mask option to see the generated background image only. E.g.