#! /bin/bash
# lire http://www.lenaturaliste.net/portail/articles-des-membres/5-techniques-diverses/61-focus-stacking-en-ligne-de-commande-sous-gnulinux
IFORMAT=jpg
# sudo apt-get install imagemagick
echo "Conversion JPEG -> TIFF, correction flat field et netteté"
find *.$IFORMAT -execdir convert {} -unsharp 0x20 {}.tif \;
# sudo apt-get install hugin-tools
echo "Alignement des images à empiler"
align_image_stack -m -a zframe_ *.$IFORMAT.tif
# sudo apt-get install enfuse
echo "Empilement des images (focus stacking)"
enfuse -o output.tif \
--exposure-weight=0 \
--saturation-weight=0 \
--contrast-weight=1 \
--hard-mask \
--contrast-window-size=9 zframe_*.tif