Page 1 of 1

Magick++, image.read() greyscale image from buffer?

Posted: 2010-06-24T15:49:20-07:00
by aseering
Hi,
I have an array of integers in memory, that I want to convert into a greyscale image. I'm trying to do this with image.read(), pointing it at the array as a buffer and giving it the appropriate width and height. The docs state that the "map_" argument to read() should be something like "RGB" or "CMYK" (or some re-ordering of these letters); but what should it be for greyscale images?

(I'm ultimately hoping to do 8-, 16- and 32-bit greyscale images this way. Fancy scientific imagery; long story. Not sure if the number of bits is relevant to this argument, though? I already specify it with "image.depth()".)

Adam

Re: Magick++, image.read() greyscale image from buffer?

Posted: 2010-06-24T15:58:17-07:00
by fmw42
(I'm ultimately hoping to do 8-, 16- and 32-bit greyscale images this way. Fancy scientific imagery; long story. Not sure if the number of bits is relevant to this argument, though? I already specify it with "image.depth()".)
To do that for grayscale images, you will have to recompile IM into Q8, Q16 and Q32 mode to get each of those bits per channel as the channel depth is a compile time issue. Or be at Q32 and then you can use -depth to decrease the depth to 16 and 8.

Note at Q32, those are 32 bit non-negative integers. If you want floats, (pos and/or neg) then you need to compile in HDRI mode.

Re: Magick++, image.read() greyscale image from buffer?

Posted: 2010-06-24T19:16:44-07:00
by aseering
Yep, thanks. I've already recompiled IM into Q32, and am using -depth (well, depth(); I'm using the C++ API, not the command line tools) as I mentioned. I don't have floats or negative integers right now; I might gain negative integers at some point, in which case I'll look into HDRI mode.

Do you have any idea what to put into the map_ field, though? I've tried just "K", but get errors saying that "K" doesn't work.

Re: Magick++, image.read() greyscale image from buffer?

Posted: 2010-06-24T19:24:17-07:00
by fmw42
Sorry, I only know command line and have not used the APIs

Re: Magick++, image.read() greyscale image from buffer?

Posted: 2010-06-24T20:00:02-07:00
by aseering
Ah, there we go: The string I want is "I" (for Intensity).

It seems that ImageMagick is downsampling to 16-bit for most image formats, though... Is there a list somewhere of image formats that support Q32?