annotate photo with average brightness
Posted: 2016-07-18T07:38:48-07:00
Hi all
I wrote a script below. It basically splits a photo into a 10x10 image and each components are measured for average brightness and annotated with
the brightness value. the components are then reassembled into a single image. An example output image is shown here https://www.flickr.com/gp/uberclacker/U6BL20
I was wondering if there was a better way to do this. I basically dont feel splitting is the right approach. Maybe there is a way to tell imagemagick to
work only on a certain region of a photo?
regards
prysm
---- start script ----
#!/bin/sh
awklib=/home/fernan/lib/awk
wff="awk -f $awklib/wf.awk"
tmpdir="/tmp"
if test $# -le 0
then
echo "usage: wf [command] [parameters]"
exit 1
fi
if test $1 = "z"
then
convert $2 -crop 10x10@ +repage +adjoin $tmpdir/tile_%02d.tiff
for FILE in $tmpdir/tile_*.tiff
do
d=`convert $FILE -colorspace gray -format %[fx:100*mean] info:`
z=`$wff z $d`
convert $FILE -fill white -undercolor '#00000080' -pointsize 70 -gravity South -annotate +0+5 $z $FILE
done
montage -mode concatenate -tile 10x $tmpdir/tile_*.tiff $3
rm $tmpdir/tile_*.tiff
fi
---- endscript -----
I wrote a script below. It basically splits a photo into a 10x10 image and each components are measured for average brightness and annotated with
the brightness value. the components are then reassembled into a single image. An example output image is shown here https://www.flickr.com/gp/uberclacker/U6BL20
I was wondering if there was a better way to do this. I basically dont feel splitting is the right approach. Maybe there is a way to tell imagemagick to
work only on a certain region of a photo?
regards
prysm
---- start script ----
#!/bin/sh
awklib=/home/fernan/lib/awk
wff="awk -f $awklib/wf.awk"
tmpdir="/tmp"
if test $# -le 0
then
echo "usage: wf [command] [parameters]"
exit 1
fi
if test $1 = "z"
then
convert $2 -crop 10x10@ +repage +adjoin $tmpdir/tile_%02d.tiff
for FILE in $tmpdir/tile_*.tiff
do
d=`convert $FILE -colorspace gray -format %[fx:100*mean] info:`
z=`$wff z $d`
convert $FILE -fill white -undercolor '#00000080' -pointsize 70 -gravity South -annotate +0+5 $z $FILE
done
montage -mode concatenate -tile 10x $tmpdir/tile_*.tiff $3
rm $tmpdir/tile_*.tiff
fi
---- endscript -----