#!/bin/sh USAGE='Usage: brewbadpixels [-unixtime ] raw-file Locate indices of bad pixels in a darkframe raw-image and store them with current or specified unixtime as _badpixels.txt. ' UNIXTIME=`perl -e 'print time,"\n";'` function namename() { local name=${1##*/} local name0="${name%.*}" echo "${name0:-$name}" } while [ $# -gt 0 ] do case "$1" in -unixtime) UNIXTIME=$2; shift 1 ;; -*) echo "$USAGE" 1>&2 exit 2 ;; *) break ;; esac shift 1 done for FILE do if [ -f "$FILE" ]; then BASE=`namename $FILE` # Check the histogram: #dcraw -P null -v -D -4 -c -j -t 0 $FILE | pnmgamma -lineartobt709 | #ppmhist -sort=rgb dcraw -P null -v -D -4 -c -j -t 0 $FILE | pnmgamma -lineartobt709 | pnmnorm -colorvalue -wpercent 0.000008 -bpercent 0.000008 | pnmdepth 255 | convert ppm:- -threshold 50% -write "${BASE}_badpixels.ppm" txt:- | egrep 'white' | sed "s/:.*/ ${UNIXTIME}/g" | sed 's/,/ /g' > "${BASE}_badpixels.txt" # 1/nr.of pixels = 1/12.8e6 *100 = 8e-8 *100 = 8e-6 in percentage makes exactly 1 pixel # What does -monochrome do? It is wrong to use - randomized! Use -threshold instead. # Pre 091211: #dcraw -v -D -4 -c -j -t 0 $FILE | pnmgamma -lineartobt709 | #pnmnorm -colorvalue -wpercent 0.00010 -bpercent 99 | pnmdepth 255 | #convert ppm:- -monochrome -write "${BASE}_badpixels.ppm" txt:- | #egrep 'white' | sed "s/:.*/ ${UNIXTIME}/g" | sed 's/,/ /g' > "${BASE}_badpixels.txt" fi done