Can't change bit depth of image in magick++

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
rohitlal
Posts: 6
Joined: 2019-01-08T07:33:51-07:00
Authentication code: 1152

Can't change bit depth of image in magick++

Post by rohitlal » 2019-01-08T07:48:18-07:00

I'm generating an image from the Pixel data array in magick++ :

Code: Select all

    image.read(4096,4096, "R", CharPixel, pixelArrayPointer);
    image.read(4096,4096, "G", CharPixel, pixelArrayPointer);
    image.read(4096,4096, "B", CharPixel, pixelArrayPointer);
Then, converting it to grayscale :

Code: Select all

    image.quantizeColorSpace(GRAYColorspace);
    image.quantizeColors(256);
    image.quantize();
Then, writing the image :

Code: Select all

    
    image.write("my_image.bmp");
On measuring the image, it shows bit-depth of 4 Pixel.

I tried,

Code: Select all

image.channelDepth(ChannelType:GrayChannel, 8); 
after the quantization steps, but still Bit-depth remains 4 bit.

Can anyone please tell me, where I'm going wrong.

snibgo
Posts: 11705
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Can't change bit depth of image in magick++

Post by snibgo » 2019-01-08T08:24:03-07:00

What version of IM?

Perhaps your quantized image has only 16 shades of gray.
snibgo's IM pages: im.snibgo.com

rohitlal
Posts: 6
Joined: 2019-01-08T07:33:51-07:00
Authentication code: 1152

Re: Can't change bit depth of image in magick++

Post by rohitlal » 2019-01-08T21:06:47-07:00

snibgo wrote:
2019-01-08T08:24:03-07:00
What version of IM?

Perhaps your quantized image has only 16 shades of gray.
IM version : 7.0.8-23 Q16 x64 2019-01-02

My image in pixel data is 8-bit grayscale image. But, magick++ is writing it as 4-bit image from the above code. Please tell me where I'm going wrong.

Post Reply