Page 1 of 1

Black and white with magick++

Posted: 2008-08-11T09:12:57-07:00
by imagetester
Hi, well i have a small problem: I need to transform ANY image to black and white AND I want each pixel to take a (0,0,0) or a (255,255,255) value !!!
The normal monochrome image ( 1 bit for each pixel ) is disturbing me (can't use it in my database !)
So is there any way that i can achieve that ?!
PS: I'm using C++ with Magick++.


Thanks in advance,

Re: Black and white with magick++

Posted: 2008-08-11T10:07:42-07:00
by fmw42
If you are starting with grayscale, then use -threshold to convert to b/w, then -depth 8. If you are starting with 1-bit and want 8-bit, try -depth 8 to force it to 0-255 range, b/w only 0 or 255.

Sorry I do not know the C++ / Magick++ commands

Re: Black and white with magick++

Posted: 2008-08-13T17:21:06-07:00
by anthony
Basically you will need to get the output image format coder to generate a 8 bit per color image. There are ways to do it, but you never specified the image file format you are generating for storing in your database (presumably by a API 'blob').