[HDRI] raw2hdr
Jack de Valpine
jedev at visarc.com
Mon Jun 30 08:12:23 PDT 2008
Skipped content of type multipart/alternative-------------- next part --------------
#!/bin/csh -f
#
# Convert camera RAW file to HDR image
#
if ($#argv < 1) then
echo "Usage: $0 [hdrgen opts][-h][-w][-n nproc] -o output.hdr input1.raw .."
exit 1
endif
set bscale=1
set nprocs=1
set dcraw=(dcraw -t 0 -4)
set hdrgen=(hdrgen -m 400 -e -a -r /tmp/sqr.rsp)
while ($#argv > 1)
switch ($argv[1])
case -o:
shift argv
set outfile="$argv[1]"
set hdrgen=($hdrgen:q -o $outfile:q)
breaksw
case -q:
shift argv
set hdrgen=($hdrgen:q -q $argv[1])
breaksw
case -m:
shift argv
set hdrgen=($hdrgen:q -m $argv[1])
breaksw
case -a:
case -e:
case -f:
set hdrgen=($hdrgen:q $argv[1])
breaksw
case -r:
case -s:
echo "hdrgen $argv[1] option not supported"
exit 1
case -h:
case -w:
set dcraw=($dcraw:q $argv[1])
breaksw
case -b:
shift argv
set bscale=$argv[1]
set dcraw=($dcraw:q -b $bscale)
breaksw
case -n:
shift argv
set nprocs=$argv[1]
breaksw
default:
break
endsw
shift argv
end
if (! $?outfile) then
echo "Missing -o output file specification"
exit 1
endif
onintr quit
cat > /tmp/sqr.rsp << '_EOF_'
2 1 0 0
2 1 0 0
2 1 0 0
'_EOF_'
#NOTE: change of format
#due to changes in output of dcraw -i -v
cat > /tmp/rawinfo.fmt << '_EOF_'
Filename: $(img).$(ext)
Timestamp: $(date)
Camera: $(camera)
Owner: $(owner)
ISO speed: ${asa}
Shutter: ${speed} sec
Aperture: f/${aperture}
Focal length: ${flen} mm
Embedded ICC profile: $(eiccp)
Number of raw images: ${nori}
Thumb size: ${twidth} x ${theight}
Full size: ${fwidth} x ${fheight}
Image size: ${iwidth} x ${iheight}
Output size: ${owidth} x ${oheight}
Raw colors: ${nrcolors}
Filter pattern: $(filtpat)
Daylight multipliers: ${rdmult} ${gdmult} ${bdmult}
Camera multipliers: ${cm1} ${cm2} ${cm3} ${cm4}
'_EOF_'
$dcraw -i -v $argv > /tmp/rawinfo$$.txt
#NOTE: this fixes the following case -
#Shutter: 1/(1/shutter) sec
#which is output by dcraw for the case where 0 < shutter < 1
perl -pi -e 'if (my $test = /^Shutter: (.*)\/(.*) sec/) {my $speed = sprintf("%0.9f",$1/$2); s/^Shutter: $1\/$2 sec/Shutter: $speed sec/}' /tmp/rawinfo$$.txt
set capdate=`rcalc -i /tmp/rawinfo.fmt -o 'CAPDATE= $(date)' /tmp/rawinfo$$.txt | head -1`
#NOTE: change of quoting are at -s
set hdrgen=($hdrgen:q `rcalc -i /tmp/rawinfo.fmt -o '-s ${stonits} $(img)_2.tif' -e "stonits=161/$bscale*aperture*aperture/(speed*asa)" /tmp/rawinfo$$.txt`)
set np=$nprocs
foreach rawfile (`sed -n 's/^Filename: //p' /tmp/rawinfo$$.txt`)
if ($nprocs > 1) then
( echo $capdate ; $dcraw -c $rawfile \
| ra_ppm -r -g 1 ) \
| ra_tiff -g 2 - ${rawfile:r}_2.tif &
@ np--
if ($np <= 0) then
wait
set np=$nprocs
endif
else
( echo $capdate ; $dcraw -v -c $rawfile \
| ra_ppm -r -g 1 ) \
| ra_tiff -g 2 - ${rawfile:r}_2.tif
endif
end
if ($np != $nprocs) wait
$hdrgen
set res=$status
quit:
rm -f `rcalc -i /tmp/rawinfo.fmt -o '$(img)_2.tif' /tmp/rawinfo$$.txt`
rm /tmp/rawinfo.fmt /tmp/sqr.rsp /tmp/rawinfo$$.txt
exit $res
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jedev.vcf
Type: text/x-vcard
Size: 251 bytes
Desc: not available
Url : http://radiance-online.org/pipermail/hdri/attachments/20080630/594cac57/jedev.vcf
More information about the HDRI
mailing list