Detecting color moire in document scans
Posted: 2011-11-15T08:53:25-07:00
Hi all,
I would like to know a trick to detect color moiré in scanned documents of newspapers and alike. I've attached two cropped examples (tif) with one slide with small dots in green and purple, and the other slide with bigger dots.
I'd like to only detect images with colordots above a certain size (+10 pixels radius). I came up with the following solution that detects the purple and greens in the scanned images, but now I want to extend it with the radius of the dots. Or maybe there's an better solution unknown by me?
moire_1.tif
moire_2.tif
I would like to know a trick to detect color moiré in scanned documents of newspapers and alike. I've attached two cropped examples (tif) with one slide with small dots in green and purple, and the other slide with bigger dots.
I'd like to only detect images with colordots above a certain size (+10 pixels radius). I came up with the following solution that detects the purple and greens in the scanned images, but now I want to extend it with the radius of the dots. Or maybe there's an better solution unknown by me?
Code: Select all
for UniqueColor in $(convert $ImageFile -colorspace rgb -colors 20 -unique-colors txt:- | grep -v enumeration | grep -Eo "rgb\([0-9]*,[0-9]*,[0-9]*" | sed s"/rgb//"|sed s"/(//"); do
red=`echo $UniqueColor | sed s"/,/ /" | sed s"/,/ /" | awk '{ print $1 }'`
green=`echo $UniqueColor | sed s"/,/ /" | sed s"/,/ /" | awk '{ print $2 }'`
blue=`echo $UniqueColor | sed s"/,/ /" | sed s"/,/ /" | awk '{ print $3 }'`
# moiré detection for purple
# red 150 <> 185, green 40 <> 100, blue 150 <> 180
if [ $red -ge '150' -a $red -le '195' ] && [ $green -ge '40' -a $green -le '100' ] && [ $blue -ge '150' -a $blue -le '190' ]; then
ImageMoire="moire"
fi
# moiré detection for green
# red 0 <> 50, green 155 <> 175, blue 50 <> 80
if [ $red -ge '0' -a $red -le '50' ] && [ $green -ge '155' -a $green -le '195' ] && [ $blue -ge '50' -a $blue -le '90' ]; then
ImageMoire="moire"
fi
done
moire_2.tif