Page 1 of 1

Grayscale image reads in as RGB: want it as Grayscale

Posted: 2006-07-26T09:32:16-07:00
by sanderton
I'm puzzled by the results that I'm getting when I run identify -verbose on the command line, and when calling colorSpace() from my C++ code.

The colorSpace() function returns RGBColorspace for a Greyscale image, but this is what I get from identify:

Code: Select all

Image: C:\Projects\testing\PSD\PSD_Greyscale.psd
  Format: PSD (Adobe Photoshop bitmap)
  Class: PseudoClass
  Geometry: 1070x839
  Type: Grayscale
  Endianess: Undefined
  Colorspace: Gray
  Channel depth:
    Gray: 8-bits
  Channel statistics:
    Gray:
      Min: 20 (0.0784314)
      Max: 254 (0.996078)
      Mean: 93.5203 (0.366746)
      Standard deviation: 48.7813 (0.191299)
  Colors: 256
  Histogram:
...
  Version: ImageMagick 6.2.8 06/30/06 Q8 http://www.imagemagick.org
What do I need to do in the C++ code to correctly identify the image as Grayscale?
Thanks,
sanderton

Posted: 2006-07-26T11:44:15-07:00
by magick
Use
  • image->type()
to return the image type. It will return GrayscaleType for a grayscale image.

colorspace?

Posted: 2006-07-27T08:17:44-07:00
by sanderton
Thanks, that helped.

But I'm still curious about the colorspace() function. I feel like I'm misunderstanding something here; why does the identify output indicate
Colorspace: Gray

when the colorspace() function returns RGBColorspace?