Skip to content

Instantly share code, notes, and snippets.

@whatsim
Last active May 17, 2021 19:20
Show Gist options
  • Save whatsim/9b503edeb0fa34fc5c42 to your computer and use it in GitHub Desktop.
Save whatsim/9b503edeb0fa34fc5c42 to your computer and use it in GitHub Desktop.
Remove Color Cast on Negatives

Takes an input Tiff of a color negative, and subtracts the film backing color contamination per http://www.dpreview.com/forums/post/499854

Requires Image Magick with libtiff. Easy way to get that on OSX is with homebrew. Just run

brew install --with-libtiff imagemagick

with brew installed. Then you use the script like

./remove_color_cast filename.tif

Easy peasy. To do a batch of tifs you'd do something like the following.

mkdir out
for i in *.tif; do remove_color_cast $i && mv out.tif out/$i; done
#!/bin/bash
if [ $# -eq 0 ]
then
echo "No arguments supplied"
else
convert $1 -set colorspace CMY -separate %d.tif
convert -page +0+0 0.tif -alpha on -channel a -evaluate set 20% -background black -layers flatten YELLOW.tif
convert -page +0+0 1.tif -alpha on -channel a -evaluate set 40% -background black -layers flatten RED.tif
composite 2.tif -compose plus YELLOW.tif 2.tif
composite 2.tif -compose plus RED.tif 2.tif
composite 1.tif -compose plus RED.tif 1.tif
convert 0.tif 1.tif 2.tif -set colorspace CMY -combine -set colorspace sRGB out.tif
convert out.tif -negate out.tif
rm YELLOW.tif RED.tif 0.tif 1.tif 2.tif
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment