Reducing aliasing in post using enfuse/hugin align_image_stack

Started by Danne, November 24, 2017, 01:44:03 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Danne

Decided to split the topic started by a1ex here:
http://www.magiclantern.fm/forum/index.php?topic=20999.0

Inspired by above thread I started exploring enfuse and hugin align_image_stack tool to be able to reduce aliasing and other artifacts when processing movie sequences. Early tests reveals that aliasing, grain and color artifacts can be reduced when stacking/enfusing groups of images producing new cleaned ones. For now I will provide a script which will multiprocess a folder containing dng or tiff files into cleaned tif files. The files will during the process be moved to a dngtmp or tifftmp folder.

Dependencies:
Install following:
brew install dcraw
brew cask install hugin


The provided script will go through a folder with dng or tiff files and build new files by stacking 6 files resulting into one new cleaned one. See to it that you have at least around 10 files in your folder when running the script.

Open up terminal and run following script inside a folder with dng or tiff files:
cat <<'EOF' > mac_ml.sh
#!/bin/sh
if ! grep 'tiff' <<< $(find . -maxdepth 1 -name '*.tiff'); then
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') & pid1=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') & pid2=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') & pid3=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') & pid4=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 5') & pid5=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 6') & pid6=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 7') & pid7=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 8') & pid8=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 9') & pid9=$!
echo > tmpfile
#wait for jobs to end
    wait < <(jobs -p)
mkdir -p dngtmp
mv $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 5') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 6') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 6') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 7') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 8') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 9') dngtmp
while grep -E "dng|DNG" <<< $(find . -maxdepth 1 -iname '*.dng')
do
if ! [ -f tmpfile ]; then
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') & pid1=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') & pid2=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') & pid3=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
mkdir -p dngtmp
mv $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') dngtmp
fi
if [ -f tmpfile ]; then
rm tmpfile 
fi
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 1' | cut -d "." -f1).tif aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 2' | cut -d "." -f1).tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 3' | cut -d "." -f1).tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 9') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 4' | cut -d "." -f1).tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
rm $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4')
done

rm $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6')
rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif

dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find dngtmp -iname '*.dng' | tail -10) & pid1=$!
#wait for jobs to end
    wait < <(jobs -p)
mv dngtmp/*.tiff ./
while grep 'tiff' <<< $(find . -maxdepth 1 -iname '*.tiff')
do
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 10') $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 10' | cut -d "." -f1).tif aligned.tiff0005.tif aligned.tiff0004.tif aligned.tiff0003.tif aligned.tiff0002.tif aligned.tiff0001.tif aligned.tiff0000.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned1.tiff $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 9' | cut -d "." -f1).tif aligned1.tiff0005.tif aligned1.tiff0004.tif aligned1.tiff0003.tif aligned1.tiff0002.tif aligned1.tiff0001.tif aligned1.tiff0000.tif && rm aligned1.tiff0000.tif aligned1.tiff0001.tif aligned1.tiff0002.tif aligned1.tiff0003.tif aligned1.tiff0004.tif aligned1.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 8' | cut -d "." -f1).tif aligned2.tiff0005.tif aligned2.tiff0004.tif aligned2.tiff0003.tif aligned2.tiff0002.tif aligned2.tiff0001.tif aligned2.tiff0000.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 7' | cut -d "." -f1).tif aligned3.tiff0005.tif aligned3.tiff0004.tif aligned3.tiff0003.tif aligned3.tiff0002.tif aligned3.tiff0001.tif aligned3.tiff0000.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 1') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 6' | cut -d "." -f1).tif aligned4.tiff0005.tif aligned4.tiff0004.tif aligned4.tiff0003.tif aligned4.tiff0002.tif aligned4.tiff0001.tif aligned4.tiff0000.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
rm $(find . -maxdepth 1 -name '*.tiff' | head -10)
done
exit 0

else
while grep 'tiff' <<< $(find . -maxdepth 1 -name '*.tiff')
do
mkdir -p tifftmp
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 1' | cut -d "." -f1).tif aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 2' | cut -d "." -f1).tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 3' | cut -d "." -f1).tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 9') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 4' | cut -d "." -f1).tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
mv $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') tifftmp
done

mv $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') tifftmp
rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif

mv $(find tifftmp | tail -10) ./

while grep 'tiff' <<< $(find . -maxdepth 1 -iname '*.tiff')
do
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 10') $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 10' | cut -d "." -f1).tif aligned.tiff0005.tif aligned.tiff0004.tif aligned.tiff0003.tif aligned.tiff0002.tif aligned.tiff0001.tif aligned.tiff0000.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned1.tiff $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 9' | cut -d "." -f1).tif aligned1.tiff0005.tif aligned1.tiff0004.tif aligned1.tiff0003.tif aligned1.tiff0002.tif aligned1.tiff0001.tif aligned1.tiff0000.tif && rm aligned1.tiff0000.tif aligned1.tiff0001.tif aligned1.tiff0002.tif aligned1.tiff0003.tif aligned1.tiff0004.tif aligned1.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 8' | cut -d "." -f1).tif aligned2.tiff0005.tif aligned2.tiff0004.tif aligned2.tiff0003.tif aligned2.tiff0002.tif aligned2.tiff0001.tif aligned2.tiff0000.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 7' | cut -d "." -f1).tif aligned3.tiff0005.tif aligned3.tiff0004.tif aligned3.tiff0003.tif aligned3.tiff0002.tif aligned3.tiff0001.tif aligned3.tiff0000.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 1') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 6' | cut -d "." -f1).tif aligned4.tiff0005.tif aligned4.tiff0004.tif aligned4.tiff0003.tif aligned4.tiff0002.tif aligned4.tiff0001.tif aligned4.tiff0000.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
mv *.tiff tifftmp
done

fi
EOF
bash mac_ml.sh && rm mac_ml.sh &
clear
"


Your script is now working


Original


Cleaned


Original(crop)


Cleaned(crop)


Original(crop) Check the grain


Cleaned(crop) Check the cleaned grain


Original(brightened)


Cleaned(brightened)



Original(crop) Check the grain


Cleaned(crop) Check the cleaned grain


Levas

Curious how this script is in aligning the images, did you test it against the optical flow script ?
The optical flow script is good, but when much movement is involved you get contrasty lines around object edges.
But the more frames you combine, the better it gets.

Probably gonna test your build too, but maybe you already tested it against the script in Alex post ?


12georgiadis

Impressive ! As it turns files into tiff, do you think we can also import tiff as input ? For example : we color grade the DNG, export tiff then goes processing with your command line.

Danne

@12georgiadis
try this script if processing tiff files as input(make sure the file extension is .tiff and not .tif):
while grep 'tiff' <<< $(find . -maxdepth 1 -iname '*.tiff')
do
mkdir tifftmp
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 1' | cut -d "." -f1).tif aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 2' | cut -d "." -f1).tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 3' | cut -d "." -f1).tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 9') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 4' | cut -d "." -f1).tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
mv $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') tifftmp
done

mv $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') tifftmp
rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif



@Levas
Only had time to test briefly with ffmpeg minterpolate filter and that was giving me some trouble with mushy interpolation parts here and there. Aligning/stacking seems more robust. Please share any testing/comparisons with optical flow if doing them.

bpv5P

I'll suggest it again, just to be sure someone reads it (I know you guys are just experimenting for now, and I know SR is not a new thing): it would be great to put SR in HDRMerge.
Most images need 3 different expositions (-2/0/+2) for near full dynamic range. The SR you presented uses 6 images, so we would need 18 photos to start working. Not practical for many applications, but it would be very useful for landscape or low-light static scenes, for example. Imagine you get a low-end camera and produce images with the quality of a hasselblad. No noise, +16 f-stop DR, no color artifacts, no aliasing. No need for denoising or deconvolution. It would also be good for scientific community, to generate more close to the real images.
HDRMerge already has a align algorithm built in. The SR implementation you are working needs a debayered image to work? Because HDRMerge does everything on DNG, that's the ideal.

Danne

HDRmerge is not useful for movie seqences. Flicker. For still image hdr work it's ok most of the time.
About your 18 photos suggestion I think you missed the point with this post. It's mainly aimed to reduce aliasing which it does. However including too many images will surely cause ghosting and other types of corruption.
I suggest you actually do some testing with your own footage to get a feel for what is possible and not with this experiment.

bpv5P

Quote from: Danne on November 24, 2017, 09:38:08 PM
HDRmerge is not useful for movie seqences.

And where exactly I have said it is?

Quote
For still image hdr work it's ok most of the time.
About your 18 photos suggestion I think you missed the point with this post.

I don't. You haven't understood my comment. The 18 images are not meant to be used for one single SR, it's meant to be 6 images for each of the 3 different exposures, then the 3 results from SR be merged again with the Ceronoice technique, to generate a nearly ideal image (excluding optical errors).
If you're biased towards only one application for SR, fine, but it doesn't mean it's not useful for other applications.

ps. I'm out, sorry.

12georgiadis

[quote author=Danne link=topic=21089.msg193629#msg193629 date=1511531930]
[b]@12georgiadis[/b]
try this script if processing tiff files as input(make sure the file extension is .tiff and not .tif):

[/quote]


Thank you Danne ! very useful ! ;-)

Stathman

Hi,
new blood here...

Very nice results!

I tried to run the script in a folder with 20 dng files but something went wrong.
Here is the terminal export if anyone can help.
https://www.dropbox.com/s/q0cdvn9mrocg7pe/Terminal%20Output?dl=0

Thanks
70D

Danne

@Stathman
Are you getting any output files after the script has ended?
When applying the script also hit enter after it´s been pasted into terminal, even though it started to process.

Stathman

Hitting enter did the trick.
Didn't think about it because it started to process immediately...
It was creating some files but it didn't complete the process.
Now it completes the process and it is making a folder with the original files as a backup.
Thanks!!!
70D

Danne


Stathman

Very good!

Check the attached files if you like.
Moire on the roof is much more visible in motion.
After the process i can't see it anymore.

This time i tried to export tiff files from Resolve and then i applied the script.
I tried with 24 tiffs but the script exported 19.
Is this a limitation of the script or am i doing something wrong?

Thanks!

https://we.tl/TilY74GU0Y

70D

Danne

Cool. Will check later. Limitation is due to needing minimum 6 files to transcode. Can fix this so that it transcode less files when coming to the end of the sequence.

Danne

Updated the script in first post to following:

cat <<'EOF' > mac_ml.sh
#!/bin/sh
if ! grep 'tiff' <<< $(find . -maxdepth 1 -name '*.tiff'); then
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') & pid1=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') & pid2=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') & pid3=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') & pid4=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 5') & pid5=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 6') & pid6=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 7') & pid7=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 8') & pid8=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 9') & pid9=$!
echo > tmpfile
#wait for jobs to end
    wait < <(jobs -p)
mkdir -p dngtmp
mv $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 5') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 6') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 6') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 7') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 8') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 9') dngtmp
while grep -E "dng|DNG" <<< $(find . -maxdepth 1 -iname '*.dng')
do
if ! [ -f tmpfile ]; then
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') & pid1=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') & pid2=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') & pid3=$!
dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
mkdir -p dngtmp
mv $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 1') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 2') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 3') $(find . -maxdepth 1 -iname '*.dng' | awk 'FNR == 4') dngtmp
fi
if [ -f tmpfile ]; then
rm tmpfile 
fi
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 1' | cut -d "." -f1).tif aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 2' | cut -d "." -f1).tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 3' | cut -d "." -f1).tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 9') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 4' | cut -d "." -f1).tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
rm $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4')
done

rm $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6')
rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif

dcraw -H 2 -b 1 +M -6 -w -q 3 -T $(find dngtmp -iname '*.dng' | tail -10) & pid1=$!
#wait for jobs to end
    wait < <(jobs -p)
mv dngtmp/*.tiff ./
while grep 'tiff' <<< $(find . -maxdepth 1 -iname '*.tiff')
do
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 10') $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 10' | cut -d "." -f1).tif aligned.tiff0005.tif aligned.tiff0004.tif aligned.tiff0003.tif aligned.tiff0002.tif aligned.tiff0001.tif aligned.tiff0000.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned1.tiff $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 9' | cut -d "." -f1).tif aligned1.tiff0005.tif aligned1.tiff0004.tif aligned1.tiff0003.tif aligned1.tiff0002.tif aligned1.tiff0001.tif aligned1.tiff0000.tif && rm aligned1.tiff0000.tif aligned1.tiff0001.tif aligned1.tiff0002.tif aligned1.tiff0003.tif aligned1.tiff0004.tif aligned1.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 8' | cut -d "." -f1).tif aligned2.tiff0005.tif aligned2.tiff0004.tif aligned2.tiff0003.tif aligned2.tiff0002.tif aligned2.tiff0001.tif aligned2.tiff0000.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 7' | cut -d "." -f1).tif aligned3.tiff0005.tif aligned3.tiff0004.tif aligned3.tiff0003.tif aligned3.tiff0002.tif aligned3.tiff0001.tif aligned3.tiff0000.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 1') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 6' | cut -d "." -f1).tif aligned4.tiff0005.tif aligned4.tiff0004.tif aligned4.tiff0003.tif aligned4.tiff0002.tif aligned4.tiff0001.tif aligned4.tiff0000.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
rm $(find . -maxdepth 1 -name '*.tiff' | head -10)
done
exit 0

else
while grep 'tiff' <<< $(find . -maxdepth 1 -name '*.tiff')
do
mkdir -p tifftmp
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 1' | cut -d "." -f1).tif aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 2' | cut -d "." -f1).tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 3' | cut -d "." -f1).tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 9') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 4' | cut -d "." -f1).tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
mv $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') tifftmp
done

mv $(ls *.tiff | awk 'FNR == 1') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 6') tifftmp
rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif

mv $(find tifftmp | tail -10) ./

while grep 'tiff' <<< $(find . -maxdepth 1 -iname '*.tiff')
do
/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned.tiff $(ls *.tiff | awk 'FNR == 10') $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 10' | cut -d "." -f1).tif aligned.tiff0005.tif aligned.tiff0004.tif aligned.tiff0003.tif aligned.tiff0002.tif aligned.tiff0001.tif aligned.tiff0000.tif && rm aligned.tiff0000.tif aligned.tiff0001.tif aligned.tiff0002.tif aligned.tiff0003.tif aligned.tiff0004.tif aligned.tiff0005.tif & pid=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned1.tiff $(ls *.tiff | awk 'FNR == 9') $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 9' | cut -d "." -f1).tif aligned1.tiff0005.tif aligned1.tiff0004.tif aligned1.tiff0003.tif aligned1.tiff0002.tif aligned1.tiff0001.tif aligned1.tiff0000.tif && rm aligned1.tiff0000.tif aligned1.tiff0001.tif aligned1.tiff0002.tif aligned1.tiff0003.tif aligned1.tiff0004.tif aligned1.tiff0005.tif & pid1=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned2.tiff $(ls *.tiff | awk 'FNR == 8') $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 8' | cut -d "." -f1).tif aligned2.tiff0005.tif aligned2.tiff0004.tif aligned2.tiff0003.tif aligned2.tiff0002.tif aligned2.tiff0001.tif aligned2.tiff0000.tif && rm aligned2.tiff0000.tif aligned2.tiff0001.tif aligned2.tiff0002.tif aligned2.tiff0003.tif aligned2.tiff0004.tif aligned2.tiff0005.tif & pid2=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned3.tiff $(ls *.tiff | awk 'FNR == 7') $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 7' | cut -d "." -f1).tif aligned3.tiff0005.tif aligned3.tiff0004.tif aligned3.tiff0003.tif aligned3.tiff0002.tif aligned3.tiff0001.tif aligned3.tiff0000.tif && rm aligned3.tiff0000.tif aligned3.tiff0001.tif aligned3.tiff0002.tif aligned3.tiff0003.tif aligned3.tiff0004.tif aligned3.tiff0005.tif & pid3=$!

/Applications/Hugin/Hugin.app/Contents/MacOS/align_image_stack -a aligned4.tiff $(ls *.tiff | awk 'FNR == 6') $(ls *.tiff | awk 'FNR == 5') $(ls *.tiff | awk 'FNR == 4') $(ls *.tiff | awk 'FNR == 3') $(ls *.tiff | awk 'FNR == 2') $(ls *.tiff | awk 'FNR == 1') && /Applications/Hugin/tools_mac/enfuse -o $(ls *.tiff | awk 'FNR == 6' | cut -d "." -f1).tif aligned4.tiff0005.tif aligned4.tiff0004.tif aligned4.tiff0003.tif aligned4.tiff0002.tif aligned4.tiff0001.tif aligned4.tiff0000.tif && rm aligned4.tiff0000.tif aligned4.tiff0001.tif aligned4.tiff0002.tif aligned4.tiff0003.tif aligned4.tiff0004.tif aligned4.tiff0005.tif & pid4=$!
#wait for jobs to end
    wait < <(jobs -p)
mv *.tiff tifftmp
done

fi
EOF
bash mac_ml.sh && rm mac_ml.sh &
clear
"


Your script is now working


The script will start immediately once it has been pasted into terminal and it will work on both dng and tiff files. It also adressed the issue where the last files weren´t being processed. Now all files should be processed.