Page 1 of 1

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

Posted: 2019-01-08T07:48:18-07:00
by rohitlal
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.

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

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

Perhaps your quantized image has only 16 shades of gray.

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

Posted: 2019-01-08T21:06:47-07:00
by rohitlal
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.