From 65f404a54b31e6e65f57e6a09b4a898db10d2db6 Mon Sep 17 00:00:00 2001 From: Thomas Jacquin Date: Tue, 22 Dec 2020 20:58:31 -0700 Subject: [PATCH] Fixed dark frame subtraction --- scripts/darkSubtract.sh | 37 ++++++++++++++++++++----------------- scripts/saveImageNight.sh | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/scripts/darkSubtract.sh b/scripts/darkSubtract.sh index 7a7f8c55b..4132cbe8f 100755 --- a/scripts/darkSubtract.sh +++ b/scripts/darkSubtract.sh @@ -3,23 +3,26 @@ cd $ALLSKY_HOME # Subtract dark frame if there is one defined in config.sh -# Find the closest dark frame temperature wise -CLOSEST_TEMP=0 -DIFF=100 -for file in darks/* -do - if [[ -f $file ]]; then - DARK_TEMP=$(echo $file | awk -F[/.] '{print $2}') - DELTA=$(expr $TEMP - $CLOSEST_TEMP) - ABS_DELTA=${DELTA#-} - if [ "$ABS_DELTA" -lt "$DIFF" ]; then - DIFF=$DELTA - CLOSEST_TEMP=$DARK_TEMP - fi - fi -done +if [ "$DARK_FRAME_SUBTRACTION" == "true" ]; then + # Find the closest dark frame temperature wise + CLOSEST_TEMP=0 + DIFF=100 + for file in darks/* + do + if [[ -f $file ]]; then + DARK_TEMP=$(echo $file | awk -F[/.] '{print $2}') + DELTA=$(expr $TEMP - $CLOSEST_TEMP) + ABS_DELTA=${DELTA#-} -if [ -e "darks/$CLOSEST_TEMP.$EXTENSION" ] ; then - convert "$FULL_FILENAME" "darks/$CLOSEST_TEMP.$EXTENSION" -compose minus_src -composite -type TrueColor "$FILENAME-processed.$EXTENSION" + if [ "$ABS_DELTA" -lt "$DIFF" ]; then + DIFF=$DELTA + CLOSEST_TEMP=$DARK_TEMP + fi + fi + done + + if [ -e "darks/$CLOSEST_TEMP.$EXTENSION" ] ; then + convert "$FULL_FILENAME" "darks/$CLOSEST_TEMP.$EXTENSION" -compose minus_src -composite -type TrueColor "$FILENAME-processed.$EXTENSION" + fi fi diff --git a/scripts/saveImageNight.sh b/scripts/saveImageNight.sh index b902fde18..2b30a7de3 100755 --- a/scripts/saveImageNight.sh +++ b/scripts/saveImageNight.sh @@ -22,7 +22,7 @@ mkdir -p images/$CURRENT/thumbnails # Create image to use (original or processed) for liveview in GUI IMAGE_TO_USE="$FULL_FILENAME" -if [ "$DARK_FRAME_SUBTRACTION" = true ] ; then +if [ "$DARK_FRAME_SUBTRACTION" = "true" ] ; then IMAGE_TO_USE="$FILENAME-processed.$EXTENSION" fi