2019.12.09 20:55 "Re: [Tiff] help writing RGB TIFF", by Bob Friesenhahn
I'm combining two 16bit grayscale images into a single RGB image (using OpenCV) to do the combination and coloring, but using LibTIFF to save it.
If I use OpenCV's imwrite function (which uses LibTIFF internally) and open the resulting TIFF file in ImageJ, it looks correct and is treated as an RGB image (info shows isRGB=true).. That is, ImageJ does not try to present 3 separate channels.
If instead I use LibTIFF and save it (using relevant fields below, note it is a tiled-tiff), and open the image in ImageJ, it looks correct (takes longer to open) but ImageJ seems to treat it as 3 independent channels and when I look at the image info, it shows isRGB=false.
What do I have to include or change to treat this as a simple RGB image?
Is your 'samples_per_pixel' value 3?
What libtiff APIs are you using to write your file?
Can you post the output of tiffdump for your RGB file?
Bob
Thanks!
TIFFSetField(tiff_handle, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tiff_handle, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
TIFFSetField(tiff_handle, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel);
TIFFSetField(tiff_handle, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField(tiff_handle, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
TIFFSetField(tiff_handle, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
TIFFSetField(tiff_handle, TIFFTAG_TILEWIDTH, 256);
TIFFSetField(tiff_handle, TIFFTAG_TILELENGTH, 256);
TIFFSetField(tiff_handle, TIFFTAG_RESOLUTIONUNIT, 3);
TIFFSetField(tiff_handle, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt