Page 1 of 1

"See" if a picture is BW

Posted: 2011-07-05T09:37:19-07:00
by xpt
Hi,

Is it possible to use any tool to detect whether a picture is black-and-white?

I guess the first level is to find all gray-tone images, and the second would be to find all images that has color pallets yet still are black-and-white. The problem is how.

Thanks

Re: "See" if a picture is BW

Posted: 2011-07-05T10:38:56-07:00
by fmw42
by black/white do you mean bi-level or just grayscale. In the verbose info it should say either bilevel, bilevelmatte or grayscale, grayscalematte depending upon the situation. identify -verbose yourimage

convert rose: -colorspace gray -verbose info:
...
Type: Grayscale
...


convert rose: -monochrome -verbose info:
...
Type: Bilevel
...



or use string formats:

convert rose: -colorspace gray -format "%r" info:
DirectClassGray

convert rose: -monochrome -format "%r" info:
PseudoClassGray

convert rose: -colorspace gray -format "%[colorspace]" info:
Gray

convert rose: -monochrome -format "%[colorspace]" info:
Gray



convert rose: -colorspace gray -format "%k" info:
2884

convert rose: -monochrome -format "%k" info:
2

Re: "See" if a picture is BW

Posted: 2011-07-05T17:30:59-07:00
by xpt
PERFECT!

Re: "See" if a picture is BW

Posted: 2011-07-05T17:41:04-07:00
by anthony
There is a section in IM Examples, Comparing Images, whcih looks at trying to group images by type (as part of a pre-processing step for comparision). On of those types is a measure of how close to pure 'Black and White' or more likely what you want, how close to 'Grayscale' the image is.

One of my other tests whcih is only mentioned in passing is determining if the colors in a colorful image is actually linear colors, That is, test weather the image is really a linearly colored greyscale image!

Re: "See" if a picture is BW

Posted: 2011-07-05T18:03:36-07:00
by fmw42
xpt wrote:PERFECT!

Just curious, but you never really said whether you are distinguishing between grayscale and bilevel?