I work with floating point textures in the form of textures for 3D models and holography images. LibTiff has support for reading and writting this format, as does ImageJ or Matlab. On a Windows system (and Adobe PS) float point tiffs appear as an image scaled to the [0,1] range. Can we have this? Reproducible: Always
Attach a file and how is supposed to look. That way if someone wants to implement it, he'll have something to work over.
Created attachment 91138 [details] floating point tiff in [0 to 1.0] range
Created attachment 91139 [details] floating point tiff (low resolution blood cells, taken with a holographic microscope)
I read them where T=float: static TIFFImage<T> readBuffer(const char* fname)//deallocate with { TIFF* tif = TIFFOpen(fname, "r");//tiff open catch error? assert(tif); int imgH, imgW; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imgH); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imgW); int rowsize = imgW*sizeof(T); auto mydata = (unsigned char*)malloc(rowsize*imgH); for (int row = 0; row < imgH; row++) { auto toMe = (void*)&mydata[rowsize*row]; TIFFReadScanline(tif, toMe, row); } TIFFClose(tif); TIFFImage<T> s; s.c = imgW; s.r = imgH; s.img = (T*)mydata; return s; } write them like static void writeTiffFast(const char* name, const void* buffer, unsigned int w, unsigned int h, bool isfloat, bool fast=false, const TiffExtraMetaData* meta = nullptr) { assert((w>0) && (h > 0)); TIFF* tif = TIFFOpen(name, "w");//quality error correcting code TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, w); // set the width of the image TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h); // set the height of the image TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); // set number of channels per pixel TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); TIFFSetField(tif, TIFFTAG_SOFTWARE, "QLI SLIM5"); TIFFSetField(tif, TIFFTAG_MAKE, "Mikhail Kandel"); if (meta!=nullptr) { TIFFSetField(tif, TIFFTAG_DATETIME, meta->datetime); } else { //get default meta data; TiffExtraMetaData defaulto; TIFFSetField(tif, TIFFTAG_DATETIME, defaulto.datetime); } TIFFSetField(tif, TIFFTAG_MODEL, __DATE__); int rowsize = 0; if (isfloat) { //todo write a LUT //TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8 * sizeof(float)); // set the size of the channels TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); // set number of channels per pixel rowsize = w*sizeof(float); } else { TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8 * sizeof(unsigned short)); // set the size of the channels TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); // set number of channels per pixel rowsize = w*sizeof(unsigned short); } if (fast) //if (0) //todo make this work ? { TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, h); int bytesize = rowsize*h; TIFFWriteRawStrip(tif, 1, (void*)buffer, bytesize); } else { TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); for (unsigned int r = 0; r < h; r++)//'r' for row { auto aschar = (unsigned char*)buffer; auto data = &aschar[rowsize*r]; TIFFWriteScanline(tif, data, r); } } TIFFClose(tif); }
Errr, this already works?
Created attachment 91140 [details] that file open with okular
Comment on attachment 91140 [details] that file open with okular That would be nice. This is what I see when I open the tif file. fruitcake@gentoo ~/Desktop $ okular file.tif okular(10268)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig: okular(10268)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig: okular(10268)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig: okular(10268)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig: okular(10268)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig: 47949_BEST.tif: Sorry, can not handle images with 32-bit samples. 47949_BEST.tif: Sorry, can not handle images with 32-bit samples. 47949_BEST.tif: Sorry, can not handle images with 32-bit samples. daniel@cortana ~/Desktop $ okular -v Qt: 4.8.5 KDE Development Platform: 4.14.3 Okular: 0.20.3
Well since it works for me with the stock Ubuntu packages, it's seems to me its something that the gentoo packagers are doing different/wrong. I suggest bringing the issue to their attention in their bug tracker.
Ignore me, i messed up and was opening the jpeg you attached.
You seem to have some code and ideas how to do it, why not download okular's source code and play with it?
When closing a bug, please put an explanation.
Created attachment 182045 [details] attachment-2251835-0.html I read the guidelines and went to your corrected bug reports but in the majority of cases i would make the same decision. Anyway i reverted all changes i made to projects that are still maintained. In the near future i will not bother bug triagers again With regards Στις Πέμ 5 Ιουν 2025 στις 12:52 μ.μ., ο/η Luigi Toscano < bugzilla_noreply@kde.org> έγραψε: > https://bugs.kde.org/show_bug.cgi?id=344287 > > Luigi Toscano <luigi.toscano@tiscali.it> changed: > > What |Removed |Added > > ---------------------------------------------------------------------------- > Ever confirmed|0 |1 > Status|RESOLVED |REOPENED > Resolution|FIXED |--- > > -- > You are receiving this mail because: > You are on the CC list for the bug.
Created attachment 183277 [details] TIFF loaded on Okular (Qt6)
(In reply to Mirco Miranda from comment #13) > Created attachment 183277 [details] > TIFF loaded on Okular (Qt6) Qt 6 natively supports float images (including the TIFF plugin). The only note I can make is that an unprofiled float TIFF should be displayed with a linear color profile (so it appears darker).