2007.02.27 19:02 "Re: [Tiff] convert grey-scale to RGB image", by Thierry Pierron
I have a black&white tiff image.
I read this image with TIFFReadScanline and I show pixels value, I obtain values since 0 until 255. I don't know why because like I have said before is a black&white image.
To be sure, just check the TIFF tag TIFFTAG_BITSPERSAMPLE (run tiffinfo on it). If it is 8, you have a grayscale image, if it is 1, it is black and white.
And, well, if you look at 1bit data as a chunk of 8bit,... you'll have any value between 0 and 255. TIFFReadScanline won't convert magically 1bit data into 8bit.
I have opened the image with the GIMP and I have seen that the image was in grey-scale, then I have saved it as RGB image.
GIMP does not support 1bit TIFF, they are automatically converted into 8bit. At least with version I have (2.2.13).
I have read this last image with TIFFReadScanline and now the pixels value are 0 or 255, that it's ok because the image always has been a black&white image.
Is there a method that converts a grey-scale image to RGB image?
ImageMagick has certainly a tool for that, or you can write your own. Using libtiff, it can be done around 20 lines of C. But, well, what waste of space! Converting 1bit B'nW into RGB 24bits, will obviously give you raw data 24 times bigger, with no added quality.