Detecting color moire in document scans

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jonrescca
Posts: 8
Joined: 2011-11-09T00:25:50-07:00
Authentication code: 8675308

Detecting color moire in document scans

Post by jonrescca »

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?

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_1.tif
moire_2.tif
jonrescca
Posts: 8
Joined: 2011-11-09T00:25:50-07:00
Authentication code: 8675308

Re: Detecting color moire in document scans

Post by jonrescca »

Does Anyone know a trick to detect color moire blobs in images like the attachment above?

Best,
Jon
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Detecting color moire in document scans

Post by anthony »

All I can suggest if to convert the image to FFT space and look for a specific bold pattern in the resulting image.

See http://www.imagemagick.org/Usage/fourier/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply