Hotspot fixing

Hotspot fixing

You can see in the header image that there is a much brighter area around the middle of the photo. This is a known issue with some lenses when used to take IR photos. Ideally you'd pick a lens that doesn't suffer from the issue, but that's harder if you're using a phone camera. There are ways to try to compensate for the uneven exposure & that's what I've tried to build into the main script.

The process requires an image that has a gradient which will let us darken the central area of the image. How big, how much & using what process to apply that gradient are going to be somewhat variable. I can share what I've tried (we'll touch on how to identify photos taken with the lens that needs this fix later on).

This is the kind if image that we need to apply to fix the hotspot

You'll need to make some gradients in order to be able to use them. I've written a script to run in termux, that uses imagemagick to create the images. It will prompt you for the size, darkness of the grey & the degree of transparency. It also asks for the "gamma" for the gradient & the half way point of the "S" curve. No error checking, of course, so don't try whacky numbers & expect a reasonable outcome!
It's probably worth pointing out that these images are not added to the gallery using termux-media-scan so don't be surprised if they aren't visible. The script generates the hotspot fixes in the current directory, so either cd to there & run the script using ~/.shortcuts/hotspotmask.sh or cd ~/.shortcuts followed by ./hotspotmask.sh then cp newhotspotmask {location used in your settings folder}

#! /bin/bash
echo -n "0. X size in pixels? = "
read x
case $x in
    ''|*[!0-9]*) echo "not an integer"
    exit 1;;
    *) arr=($x) ;;
esac
echo -n "1. Y size in pixels? = "
read x
case $x in
    ''|*[!0-9]*) echo "not an integer"
    exit 1;;
    *) arr+=($x) ;;
esac
echo -n "2. Gray level (1-255)? = "
read x
case $x in
    ''|*[!0-9]*) echo "not an integer"
    exit 1;;
    *) arr+=($x) ;;
esac
echo -n "3-4. % transparency for gray mask? = "
read x
case $x in
    ''|*[!0-9]*) echo "not an integer"
    exit 1;;
    *) arr+=($x)
       arr+=("0."$x) ;;
esac
echo -n "5. Sigmoid intensity (3 is typical, 20 is lots)? = "
read x
case $x in
    ''|*[!0-9]*) echo "not an integer"
    exit 1;;
    *) arr+=($x) ;;
esac
echo -n "6. % where sigmoid intensity is half way? = "
read x
case $x in
    ''|*[!0-9]*) echo "not an integer"
    exit 1;;
    *) arr+=($x) ;;
esac

if [[ "${arr[1]}" -lt "${arr[0]}" ]] ; then
  magick -size "${arr[1]}"x"${arr[1]}" radial-gradient:graya\("${arr[2]}","${arr[4]}"\)-none -sigmoidal-contrast "${arr[5]}","${arr[6]}"% -background white -gravity center -extent "${arr[0]}"x"${arr[1]}" \) -compose Copy gradient"${arr[1]}"_"${arr[2]}"-"${arr[3]}"_sigmoid_"${arr[5]}"-"${arr[6]}".png
  echo "gradient"${arr[1]}"_"${arr[2]}"-"${arr[3]}"_sigmoid_"${arr[5]}"-"${arr[6]}".png"
else
  magick -size "${arr[0]}"x"${arr[0]}" radial-gradient:graya\("${arr[2]}","${arr[4]}"\)-none -sigmoidal-contrast "${arr[5]}","${arr[6]}"% -background white -gravity center -extent "${arr[0]}"x"${arr[1]}" \) -compose Copy gradient"${arr[0]}"_"${arr[2]}"-"${arr[3]}"_sigmoid_"${arr[5]}"-"${arr[6]}".png
  echo "gradient"${arr[0]}"_"${arr[2]}"-"${arr[3]}"_sigmoid_"${arr[5]}"-"${arr[6]}".png"
fi
sleep 1
exit 0

As usual, don't run shell scripts if you don't know what they do - & don't forget to make this executable (chmod +x) before you try to run it.

PhotoScript/script/hotspotmask.sh at main · Linecutterx/PhotoScript
Bash scripting for use of dcraw & Imagemagick in termux - for processing RAW photos - Linecutterx/PhotoScript

I think that's everything set up - we have options ready to go & a command line version that we could use "Longhand". Next comes the scripting that takes those settings & the script name & converts it all into the processing instructions for us. Of course it does need a little setting up with its own defaults.