34 #ifndef AIMS_IO_TIFFW_H 35 #define AIMS_IO_TIFFW_H 64 unsigned zfame,
unsigned tframe );
72 operator << ( TiffWriter<T> & writer,
const AimsData<T> & thing )
74 writer.write( thing );
83 unsigned t, z, dt = thing.
dimT(), dz = thing.
dimZ();
93 std::vector<std::string> files = hdr.outputFilenames();
95 hdr.setProperty(
"file_type", std::string(
"TIFF" ) );
96 hdr.setProperty(
"filenames", files );
101 for( t=0; t<dt; ++t )
102 for( z=0; z<dz; ++z, ++i ) {
107 + hdr.extension() +
".minf" );
113 const std::string & filename,
117 int bps, spp, photometric;
122 if((tif = TIFFOpen(filename.c_str(),
"w")) == NULL){
123 std::cout <<
"Could not open '" << filename <<
"' for writing." << std::endl;
128 uint16_t sampleformat = SAMPLEFORMAT_UINT;
134 photometric = PHOTOMETRIC_MINISBLACK;
136 else if ( name ==
"S8" )
140 photometric = PHOTOMETRIC_MINISBLACK;
141 sampleformat = SAMPLEFORMAT_INT;
143 else if ( name ==
"U16" )
147 photometric = PHOTOMETRIC_MINISBLACK;
149 else if ( name ==
"S16" )
153 photometric = PHOTOMETRIC_MINISBLACK;
154 sampleformat = SAMPLEFORMAT_INT;
156 else if ( name ==
"FLOAT" )
160 photometric = PHOTOMETRIC_MINISBLACK;
161 sampleformat = SAMPLEFORMAT_IEEEFP;
163 else if ( name ==
"DOUBLE" )
167 photometric = PHOTOMETRIC_MINISBLACK;
168 sampleformat = SAMPLEFORMAT_IEEEFP;
170 else if ( name ==
"CFLOAT" )
174 photometric = PHOTOMETRIC_MINISBLACK;
175 sampleformat = SAMPLEFORMAT_COMPLEXIEEEFP;
177 else if ( name ==
"CDOUBLE" )
181 photometric = PHOTOMETRIC_MINISBLACK;
182 sampleformat = SAMPLEFORMAT_COMPLEXIEEEFP;
184 else if ( name ==
"RGBA" )
188 photometric = PHOTOMETRIC_RGB;
194 photometric = PHOTOMETRIC_RGB;
204 TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, data.
dimX() );
205 TIFFSetField(tif, TIFFTAG_IMAGELENGTH, data.
dimY());
206 TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
207 TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, spp );
208 TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1 );
210 TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric);
211 TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
213 TIFFSetField(tif, TIFFTAG_XRESOLUTION, 10. / data.
sizeX());
214 TIFFSetField(tif, TIFFTAG_YRESOLUTION, 10. / data.
sizeY());
215 TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_CENTIMETER);
216 TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, sampleformat);
220 int y, ny = data.
dimY();
221 for( y=0; y<ny; ++y )
223 res = TIFFWriteEncodedStrip(tif, y, (
byte *)&data(0, y, z, t),
224 (bps / 8) * spp * data.
dimX() );
TiffWriter(const std::string &name)
The class for EcatSino data write operation.
static std::string removeExtension(const std::string &)
void write(const AimsData< T > &thing)
static std::string dirname(const std::string &)
const aims::Header * header() const
void writeFrame(const AimsData< T > &thing, const std::string &filename, unsigned zfame, unsigned tframe)
called by write(), but you can call it for single frame writing (axial slice)