Skip to content

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

Prerequisite: Align images

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 is
     align_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 uses align_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.

General recommendations

  • Run with --cache to allow faster test runs with different parameter sets.
  • Run imfuse --cache --background=enfuse IMAGES to get a reference enfuse 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).
  • 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

Choose a mask generation method

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.

Adjust brush size (sigma or radius)

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.

Improve high contrast areas

  • 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.
  • Use option --less to strenghten weak foreground objects that might be overwritten by strong contrast background.

Bokeh / low contrast areas

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 than 50 is more appropriate.
    • A colored background might be more helpful to assess the threshold effect than the default transparency. Add --background=red.
  • 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: