check if a tiff file is almost white

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: check if a tiff file is almost white

Post by fmw42 »

Look at string formats, in particular the mean. If the mean is near quantum range (65535 on Q16 IM), then it is near white.

http://www.imagemagick.org/script/escape.php

convert -size 100x100 xc:white white.png
convert white.png -format "%[mean]" info:
65535

alternate result if near 1
val=`convert white.png -format "%[mean]" info:`
convert xc: -format "%[fx:$val/quantumrange]" info:
1

or
alternate convert to gray, scale to 1x1 pixels and get graylevel value of the one pixel

convert white.png -colorspace gray -scale 1x1! -format "%[fx:u]" info:
1
Post Reply