Summary: | Open floating point tiffs | ||
---|---|---|---|
Product: | [Applications] okular | Reporter: | Mikhail Kandel <kandel3> |
Component: | TIFF backend | Assignee: | Okular developers <okular-devel> |
Status: | REPORTED --- | ||
Severity: | wishlist | CC: | aacid |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
floating point tiff in [0 to 1.0] range
floating point tiff (low resolution blood cells, taken with a holographic microscope) that file open with okular |
Description
Mikhail Kandel
2015-02-17 17:31:57 UTC
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? |