22 # include <vcl_msvc_warnings.h> 37 static unsigned nimg(TIFF* tif)
41 TIFFSetDirectory(tif, 0);
42 unsigned int dircount = 0;
45 }
while (TIFFReadDirectory(tif));
56 auto read = (unsigned)is->
read(hdr,
sizeof hdr);
57 if (read <
sizeof hdr)
71 if (hdr[0]==0x4D && hdr[1]==0x4D &&
72 hdr[2]==0x00 && (hdr[3]==0x2A || hdr[3] == 0x2B) )
75 else if (hdr[0]==0x49 && hdr[1]==0x49 &&
76 (hdr[2]==0x2A || hdr[2] == 0x2B) && hdr[3]==0x00)
79 else if ( ((hdr[0]==0x4D && hdr[1]==0x4D) || (hdr[0]==0x49 && hdr[1]==0x49)) &&
80 ((hdr[2]==0x00 && hdr[3]==0x2A) || (hdr[2]==0x2A && hdr[3]==0x00)) ) {
81 std::cerr << __FILE__
": suspicious TIFF header\n";
102 static tsize_t vil_tiff_readproc(thandle_t h, tdata_t buf, tsize_t n)
105 if (n > p->filesize) p->filesize= n;
108 auto ret = (tsize_t)p->vs->read(buf, n);
112 static tsize_t vil_tiff_writeproc(thandle_t h, tdata_t buf, tsize_t n)
117 auto ret = (tsize_t)p->vs->write(buf, n);
124 static toff_t vil_tiff_seekproc(thandle_t h, toff_t offset,
int whence)
127 if (whence == SEEK_SET) p->vs->seek(offset);
128 else if (whence == SEEK_CUR) p->vs->seek(p->vs->tell() + offset);
129 else if (whence == SEEK_END) p->vs->seek(p->filesize + offset);
136 static int vil_tiff_closeproc(thandle_t h)
145 static toff_t vil_tiff_sizeproc(thandle_t)
149 std::cerr <<
"Warning: vil_tiff_sizeproc() not yet implemented\n";
154 static int vil_tiff_mapfileproc(thandle_t, tdata_t*, toff_t*)
158 std::cerr <<
"Warning: mmap support not yet in vil_tiff_mapfileproc()\n";
163 static void vil_tiff_unmapfileproc(thandle_t, tdata_t, toff_t)
172 TIFF* tiff = XTIFFClientOpen(
"unknown filename",
175 vil_tiff_readproc, vil_tiff_writeproc,
176 vil_tiff_seekproc, vil_tiff_closeproc,
178 vil_tiff_mapfileproc, vil_tiff_unmapfileproc);
179 #else // this file is only included if HAS TIFF is defined vil_file_format.cxx 180 TIFF* tiff = TIFFClientOpen(
"unknown filename",
183 vil_tiff_readproc, vil_tiff_writeproc,
184 vil_tiff_seekproc, vil_tiff_closeproc,
186 vil_tiff_mapfileproc, vil_tiff_unmapfileproc);
187 #endif // HAS_GEOTIFF 201 tss->
tif = open_tiff(tss,
"rC");
207 if (!h->format_supported)
210 XTIFFClose(tss->
tif);
213 #endif // HAS_GEOTIFF 217 unsigned n = nimg(tss->
tif);
228 TIFF* in = TIFFOpen(file,
"rC");
231 bool open_for_reading =
true;
233 std::cerr <<
"make_input_pyramid_image::opening multi-image tiff pyramid resource\n";
237 if (pyr->nlevels()<=1)
243 static std::string level_filename(std::string& directory, std::string& filename,
253 std::stringstream cs;
255 return directory + slash + filename + cs.str();
262 char const* temp_dir)
266 pyr->put_resource(base_image);
269 std::string d = temp_dir;
270 std::string fn =
"tempR";
272 for (
unsigned L = 1; L<nlevels; ++L)
274 std::cout <<
"Decimating Level " << L << std::endl;
275 std::string full_filename = level_filename(d, fn, L) +
".tif";
284 std::vector<vil_image_resource_sptr> rescs = il.
resources();
285 for (
auto & resc : rescs)
286 pyr->put_resource(resc);
294 std::cout <<
"Warning: In vil_tiff::make_pyramid_from_base(..) -" 295 <<
" temporary directory not cleaned\n";
306 unsigned size_block_i,
307 unsigned size_block_j,
310 if (size_block_i%16!=0||size_block_j%16!=0)
312 std::cerr <<
"In vil_tiff_file_format - Block dimensions must be a multiple of 16\n";
318 std::string mode(
"w");
320 bool const bigtiff_needed = size_needed >= vxl_uint_64(0x7FFFFFFF);
323 tss->
tif = open_tiff(tss, mode.c_str());
331 format, size_block_i, size_block_j);
332 if (!h->format_supported)
335 XTIFFClose(tss->
tif);
338 #endif // HAS_GEOTIFF 360 TIFF* out = TIFFOpen(filename,
"w");
363 bool open_for_reading =
false;
381 t_(tif_sptr), h_(th), index_(0), nimages_(nimages)
416 TIFF*
const tif =
t_.
tif();
419 int status = TIFFSetField(tif, TIFFTAG_COMPRESSION,
int(cm));
428 TIFF*
const tif =
t_.
tif();
431 int status = TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality);
442 if (gtif->gtif_number_of_keys() == 0) {
469 static void tif_swap16(vxl_byte *a,
unsigned n)
471 for (
unsigned i = 0; i < n * 2; i += 2)
472 std::swap( a[i+0], a[i+1] );
475 static void tif_swap32(vxl_byte *a,
unsigned n)
477 for (
unsigned i = 0; i < n * 4; i += 4)
479 std::swap( a[i+0], a[i+3] );
480 std::swap( a[i+1], a[i+2] );
484 static void endian_swap( vxl_byte* a,
unsigned n_bytes,
485 unsigned bytes_per_sample)
487 switch ( bytes_per_sample ) {
489 case 2: tif_swap16( a, n_bytes / 2 );
break;
490 case 4: tif_swap32( a, n_bytes / 4 );
break;
491 default: assert(!
"Unsupported number of bytes per sample.");
497 switch (
sizeof(
bool))
503 tiff_byte_align_data((vxl_uint_16*)in_data, num_samples, in_bits_per_sample, (vxl_uint_16*)out_data);
506 tiff_byte_align_data((vxl_uint_32*)in_data, num_samples, in_bits_per_sample, (vxl_uint_32*)out_data);
509 assert(!
"Unsupported size of bool in tiff file format.");
517 switch (bits_per_sample)
521 case 32:
return true;
530 unsigned num_samples,
531 unsigned in_bits_per_sample,
532 unsigned bytes_per_block)
538 std::cout <<
"Debug tiff_byte_align_data:" 539 <<
" Num Samples = " << num_samples
540 <<
" Input Bits/Sample = " << in_bits_per_sample
541 <<
" Bytes/Block = " << bytes_per_block
545 T* out_ptr = reinterpret_cast<T*>(new_memory->data());
546 T* in_ptr = reinterpret_cast<T*>(in_data->data());
549 std::cout <<
" .\n" << std::flush;
615 unsigned size = bps/bpl;
659 auto* c_data = reinterpret_cast<vxl_byte*>(cnk->data());
660 std::memcpy(c_data, data, nbytes);
668 unsigned samples_per_block,
unsigned bits_per_sample
676 #define GET_BLOCK_CASE(FORMAT, T) \ 678 vil_image_view_base_sptr view; \ 679 buf_out = tiff_maybe_byte_align_data<T>(buf, samples_per_block, \ 681 samples_per_block*vil_pixel_format_sizeof_components(fmt)); \ 682 view = new vil_image_view<T>(buf_out, reinterpret_cast<T*>(buf_out->data()), \ 683 size_block_i(), size_block_j(), \ 684 spp, spp, size_block_i()*spp, 1); \ 699 #undef GET_BLOCK_CASE 701 assert(!
"Unknown vil data type in tiff file format");
711 unsigned block_index_j )
const 736 assert(encoded_block_size>0);
740 unsigned blk_indx = this->
block_index(block_index_i, block_index_j);
753 auto* data =
new vxl_byte[encoded_block_size];
754 if (TIFFReadEncodedTile(
t_.
tif(), blk_indx, data, (tsize_t) -1)<=0)
762 endian_swap( reinterpret_cast<vxl_byte*>(buf->data()),
764 expanded_sample_bytes);
770 auto* data =
new vxl_byte[encoded_block_size];
771 if (TIFFReadEncodedStrip(
t_.
tif(), blk_indx, data, (tsize_t) -1)<=0)
779 endian_swap( reinterpret_cast<vxl_byte*>(buf->data()),
781 expanded_sample_bytes);
794 size_t strip_data_size = encoded_block_size/
nplanes;
797 size_t strips_per_plane = n_rows/rows_per_strip;
798 if(strips_per_plane*rows_per_strip < n_rows)
800 size_t bytes_per_row = encoded_block_size/rows_per_strip;
802 size_t bytes_per_row_per_sample = bytes_per_row/samples_per_pixel;
804 size_t bytes_per_pixel = bytes_per_row/
ni;
808 std::vector<vxl_byte*> strip_plane_data(
nplanes);
811 for(
size_t s = 0; s<samples_per_pixel; ++s){
812 strip_plane_data[s] =
new vxl_byte[strip_data_size];
813 size_t strip_indx = blk_indx + s*strips_per_plane;
814 size_t strip_size = TIFFReadEncodedStrip(
t_.
tif(), strip_indx, strip_plane_data[s], (tsize_t) -1);
817 for(
size_t d = 0; d<=s; ++d)
818 delete [] strip_plane_data[d];
819 std::cout <<
"Error in reading tiff strip - " << strip_size
820 <<
" bytes returned instead of " << strip_data_size << std::endl;
825 auto* buf_adr = reinterpret_cast<vxl_byte*>(buf->data());
832 for(
size_t r = 0; r< rows_per_strip; ++r){
833 size_t rb_off = r*bytes_per_row, rs_off =r*bytes_per_row_per_sample;
834 for(
size_t i = 0; i<
ni; ++i){
835 size_t ib_off = i*bytes_per_pixel, is_off = i*bytes_per_sample;
836 for(
size_t s =0; s<samples_per_pixel; ++s){
837 size_t sb_off = s*bytes_per_sample;
838 for(
size_t b = 0; b<bytes_per_sample; ++b){
839 size_t buf_off = rb_off + ib_off + sb_off + b;
840 size_t strip_off = rs_off + is_off +b;
841 *(buf_adr + buf_off) = *(strip_plane_data[s] + strip_off);
847 for(
size_t p = 0; p<
nplanes; ++p)
848 delete [] strip_plane_data[p];
852 endian_swap( reinterpret_cast<vxl_byte*>(buf->data()), encoded_block_size, expanded_sample_bytes);
891 unsigned lines_per_strip = bytes_per_strip/bpl;
893 unsigned expanded_bytes_per_sample =
896 unsigned bytes_expanded_line = spl*expanded_bytes_per_sample;
899 unsigned expanded_bytes_per_strip = tl*bytes_expanded_line;
902 auto* buf_ptr = reinterpret_cast<vxl_byte*>(buf->data());
909 auto* zero_ptr = reinterpret_cast<vxl_byte*>(zero_buf->data());
910 for (
unsigned i = 0; i<bytes_expanded_line; ++i)
916 auto* block_ptr = reinterpret_cast<vxl_byte*>(block_buf->data());
918 for (
unsigned j = 0; j<tl; ++j, buf_ptr+=bpl,
919 block_ptr+=bytes_expanded_line)
921 if (j<lines_per_strip)
928 #define GET_LINE_CASE(FORMAT, T) \ 931 tiff_maybe_byte_align_data<T>(line_buf,\ 932 spl, h_->bits_per_sample.val,\ 933 bytes_expanded_line); \ 950 assert(!
"Unknown vil data type in tiff file format");
955 auto* out_line_buf_ptr =
956 reinterpret_cast<vxl_byte*>(out_line_buf->data());
958 std::memcpy(block_ptr, out_line_buf_ptr, bytes_expanded_line);
961 std::memcpy(block_ptr, zero_ptr, bytes_expanded_line);
963 return this->
view_from_buffer(fmt, block_buf, spl*tl, expanded_bytes_per_sample*8);
967 unsigned iclip,
unsigned jclip,
968 unsigned bytes_per_pixel,
972 unsigned row_start = ioff*bytes_per_pixel;
976 for (
unsigned j = 0; j<joff-1; ++j)
978 unsigned row_ptr = row_start;
979 for (
unsigned i = 0; i<ioff-1; ++i)
981 for (
unsigned p = 0; p<
nplanes(); ++p)
982 *(block_buf + bptr + row_ptr + p) = 0;
983 row_ptr += bytes_per_pixel;
988 row_start = iclip*bytes_per_pixel;
989 if (iclip>0||jclip>0)
992 unsigned row_ptr = row_start;
995 for (
unsigned p = 0; p<
nplanes(); ++p)
996 *(block_buf + bptr + row_ptr + p) = 0;
997 row_ptr += bytes_per_pixel;
1004 unsigned i0,
unsigned j0,
1005 unsigned ioff,
unsigned joff,
1006 unsigned iclip,
unsigned jclip,
1008 vxl_byte*& block_buf)
1011 unsigned bytes_per_pixel = bytes_per_sample*
nplanes();
1013 unsigned bytes_per_block=bytes_per_pixel*sbi*sbj;
1014 unsigned view_i0 = bi*sbi-i0, view_j0 = bj*sbj-j0;
1015 unsigned block_jstep = sbi*bytes_per_pixel;
1018 unsigned view_istep = 1, view_jstep = im.
ni()*bytes_per_pixel, view_pstep = 1;
1020 std::ptrdiff_t view_istep, view_jstep, view_pstep;
1025 #define GET_VIEW_PTR(FORMAT, T) \ 1027 vil_image_view<T> view = static_cast<const vil_image_view<T>& >(im);\ 1028 view_istep = view.istep(); view_jstep = view.jstep(); view_pstep = view.planestep(); \ 1029 view_buf = reinterpret_cast<vxl_byte*>(view.top_left_ptr());\ 1046 assert(!
"Unknown vil data type.");
1050 unsigned bptr = joff*block_jstep;
1051 unsigned ibstart = ioff*bytes_per_pixel;
1052 std::ptrdiff_t vistp = view_istep*bytes_per_sample;
1053 std::ptrdiff_t vjstp = view_jstep*bytes_per_sample;
1054 std::ptrdiff_t vpstp = view_pstep*bytes_per_sample;
1058 std::ptrdiff_t vptr = (view_j0 + joff)*vjstp;
1059 unsigned ivstart = (view_i0 + ioff)*bytes_per_pixel;
1060 for (
unsigned j = joff; j<jclip; ++j)
1062 std::ptrdiff_t vrow_ptr = ivstart;
1063 std::ptrdiff_t brow_ptr = ibstart;
1064 for (
unsigned i = ioff; i<iclip; ++i)
1066 std::ptrdiff_t bpptr = 0, vpptr = 0;
1067 for (
unsigned p = 0; p<
nplanes(); ++p)
1069 for (
unsigned b = 0; b<bytes_per_sample; ++b)
1070 *(block_buf + bptr + brow_ptr + bpptr + b) =
1071 *(view_buf + vptr + vrow_ptr + vpptr + b);
1072 bpptr += bytes_per_sample; vpptr += vpstp;
1074 brow_ptr += bytes_per_pixel; vrow_ptr += vistp;
1076 bptr += block_jstep; vptr += vjstp;
1082 unsigned outsize = (bytes_per_block+7*
sizeof(bool))/(8*
sizeof(bool));
1083 auto* outbuf =
new vxl_byte[outsize];
1085 delete [] block_buf;
1091 unsigned block_size_bytes,
1092 vxl_byte* block_buf)
1096 return TIFFWriteEncodedTile(
t_.
tif(), blk_indx, block_buf,
1097 block_size_bytes)>0;
1099 return TIFFWriteEncodedStrip(
t_.
tif(), blk_indx, block_buf,
1100 block_size_bytes ) > 0;
1107 const vxl_byte* in_block_buf,
1108 vxl_byte* out_block_buf)
1110 unsigned bytes_per_bool =
sizeof(bool);
1111 auto* bl =
new vxl_byte[bytes_per_bool];
1112 unsigned bitctr = 0;
1113 unsigned outctr = 0;
1114 vxl_byte packed_byte=0;
1115 for (
unsigned i = 0; i<bytes_per_block; )
1121 out_block_buf[outctr] = packed_byte;
1126 for (
unsigned b = 0; b<bytes_per_bool; ++b)
1127 bl[b] = *(in_block_buf + i + b);
1128 bool blv = *(reinterpret_cast<bool*>(bl));
1130 packed_byte |= vxl_byte(1<<(7-bitctr));
1132 packed_byte &= vxl_byte(~(1<<(7-bitctr)));
1136 if (i>=bytes_per_block)
1137 out_block_buf[outctr] = packed_byte;
1154 unsigned ioff =0, joff = 0;
1156 unsigned iclip =sbi , jclip = sbj;
1158 if (bi*sbi<i0&&(bi+1)*sbi>i0)
1162 if (bj*sbj<j0&&(bj+1)*sbj>j0)
1170 if ( (bi+1)*sbi > (im.
ni()+i0) )
1172 iclip = (i0+im.
ni())-bi*sbi;
1178 if ( (bj+1)*sbj > (im.
nj()+j0) )
1180 jclip = (j0+im.
nj())-bj*sbj;
1185 unsigned bytes_per_pixel = bps*
nplanes();
1187 unsigned bytes_per_block = bytes_per_pixel*sbi*sbj;
1191 auto* block_buf =
new vxl_byte[bytes_per_block];
1194 bytes_per_pixel, block_buf);
1201 delete [] block_buf;
1206 unsigned i0,
unsigned j0)
1217 unsigned bi_start = i0/tw, bi_end = (i0+im.
ni()-1)/tw;
1218 unsigned bj_start = j0/tl, bj_end = (j0+im.
nj()-1)/tl;
1219 for (
unsigned bi = bi_start; bi<=bi_end; ++bi)
1220 for (
unsigned bj = bj_start; bj<=bj_end; ++bj)
1221 if (!this->
put_block(bi, bj, i0, j0, im))
1228 unsigned block_index_j,
1231 if (blk.
ni()==0||blk.
nj()==0)
1235 unsigned bytes_per_pixel = bps*
nplanes();
1237 unsigned bytes_per_block = bytes_per_pixel*sbi*sbj;
1240 auto* block_buf =
new vxl_byte[bytes_per_block];
1245 bool good_write =
write_block_to_file(block_index_i, block_index_j, bytes_per_block, block_buf);
1246 delete [] block_buf;
1254 return l1->
ni_ > l2->
ni_;
1266 auto ni0 = static_cast<float>(
levels_[0]->ni_);
1267 for (
unsigned i = 1; i<
nlevels; ++i)
1279 float mind = 1.0e08f;
1281 for (
unsigned i = 0; i<
nlevels; ++i)
1283 float ds = std::fabs(scale -
levels_[i]->scale_);
1297 : read_(true), t_(nullptr)
1303 : read_(read), t_(t)
1313 std::cerr <<
"In vil_tiff_pyramid_resource constructor" 1314 <<
" constructed header\n" 1315 <<
"n-levels = " << this->
nlevels() <<
'\n';
1323 std::cerr <<
"In vil_tiff_pyramid_resource constructor" 1324 <<
" constructed level\n";
1325 int status = TIFFReadDirectory(
t_.
tif());
1327 std::cerr <<
"In vil_tiff_pyramid_resource constructor" 1328 <<
" Read new directory\n";
1334 std::cerr <<
"In vil_tiff_pyramid_resource constructor" 1335 <<
" Begin sorting\n";
1344 for (
unsigned L = 0; L<this->
nlevels(); ++L)
1351 unsigned j0,
unsigned n_j,
1352 unsigned level)
const 1354 unsigned nl = this->
nlevels();
1359 float scale =
levels_[level]->scale_;
1360 float fi0 = std::floor(scale*i0), fj0 = std::floor(scale*j0);
1361 float fni = std::floor(scale*n_i), fnj = std::floor(scale*n_j);
1362 auto si0 = static_cast<unsigned>(fi0);
1363 auto sj0 = static_cast<unsigned>(fj0);
1364 auto sni = static_cast<unsigned>(fni);
1365 if (sni == 0) sni = 1;
1366 auto snj = static_cast<unsigned>(fnj);
1367 if (snj == 0) snj = 1;
1369 #if 0 //DON'T NEED CLEAR? 1381 unsigned j0,
unsigned n_j,
1383 float& actual_scale)
const 1389 actual_scale = pl->
scale_;
1397 unsigned level = this->
nlevels();
1398 unsigned ni = ir->ni(),
nj = ir->nj();
1399 unsigned nplanes = ir->nplanes();
1402 unsigned sbi = 0, sbj = 0;
1403 if (bir) { sbi = bir->size_block_i(); sbj = bir->size_block_j(); }
1409 TIFFSetField(
t_.
tif(), TIFFTAG_SUBFILETYPE, FILETYPE_PAGE);
1411 TIFFSetField(
t_.
tif(), TIFFTAG_PAGENUMBER,level, 3);
1416 #if 0 //DON'T NEED CLEAR? 1421 int status = TIFFWriteDirectory(
t_.
tif());
1422 return status == 1 ;
1427 unsigned nl = this->
nlevels();
1431 unsigned header_index =
levels_[level]->header_index_;
1433 if (TIFFSetDirectory(
t_.
tif(), header_index)<=0)
1437 i->set_index(header_index);
unsigned nlevels() const override
number of pyramid levels.
float scale_
scale associated with level.
std::vector< vil_image_resource_sptr > resources()
finds all the image files in the directory, regardless of extension.
vil_image_view_base_sptr fill_block_from_tile(vil_memory_chunk_sptr const &buf) const
the key methods for decoding the file data.
Stream interface for VIL image loaders.
An abstract base class of smart pointers to actual image data in memory.
virtual bool view_fits(const vil_image_view_base &im, unsigned i0, unsigned j0)
Check that a view will fit into the data at the given offset.
tif_stream_structures(vil_stream *vs_)
vil_smart_ptr< vil_image_view_base > vil_image_view_base_sptr
unsigned n_block_j() const override
Number of blocks in image height.
void normalize_scales()
normalize the scale factors so that the base image scale = 1.0.
char const * file_format() const override
returns "tiff".
bool get_property(char const *tag, void *prop=nullptr) const override
Return true if the property given in the first argument has been set.
bool block_i_offset(unsigned block_i, unsigned i, unsigned &i_offset) const
Get the offset from the start of the block row for pixel position i.
void fill_block_from_view(unsigned bi, unsigned bj, unsigned i0, unsigned j0, unsigned ioff, unsigned joff, unsigned iclip, unsigned jclip, const vil_image_view_base &im, vxl_byte *&block_buf)
fill the block with view data.
vil_image_view_base_sptr view_from_buffer(vil_pixel_format &fmt, vil_memory_chunk_sptr const &buf, unsigned samples_per_block, unsigned bits_per_sample) const
convert a packed block to an expanded view.
vil_memory_chunk_sptr tiff_maybe_byte_align_data< float >(vil_memory_chunk_sptr in_data, unsigned, unsigned, unsigned)
static bool vil_is_directory(char const *)
utility functions.
enum vil_pixel_format pixel_format() const override
Pixel Format.
unsigned nj() const override
The number of pixels in each column.
unsigned int nimages_
number of images in the file.
static vil_image_resource_sptr decimate(vil_image_resource_sptr const &resc, char const *filename, char const *format="tiff")
Utility for decimating a resource to create a new pyramid level.
bool clean_directory()
cleans the directory, i.e. removes all the files.
vil_image_resource_sptr get_resource(const unsigned level) const override
returns the image resource at the specified pyramid level.
void copy_byte_block(vxl_byte *data, const vxl_uint_32 nbytes, vil_memory_chunk_sptr &cnk) const
Transfer data from block to memory chunk, row by row.
------— Representation of Pyramid Images by multi-image TIFF ----—
virtual void seek(vil_streampos position)=0
Goto file pointer.
unsigned block_index(unsigned block_i, unsigned block_j) const
virtual vil_streampos read(void *buf, vil_streampos n)=0
Read n bytes into buf. Returns number of bytes read.
Exceptions thrown by vil, and a mechanism for turning them off.
unsigned samples_per_block() const
the number of samples in a block.
#define GET_BLOCK_CASE(FORMAT, T)
bool block_j_offset(unsigned block_j, unsigned j, unsigned &j_offset) const
Get the offset from the start of the block column for pixel position j.
bool integral_type(unsigned bits_per_sample)
vil_tiff_pyramid_resource()
default constructor.
#define GET_LINE_CASE(FORMAT, T)
#define vil_property_quantisation_depth
The quantisation depth of pixel components.
T * tiff_byte_align_data(T *in_data, unsigned num_samples, unsigned in_bits_per_sample, T *out_data)
This function will byte align the data in in_data and store the result in out_data.
std::vector< tiff_pyramid_level * > levels_
tif_smart_ptr t_
the tiff handle.
unsigned ni() const
Width.
Stream interface for VIL image loaders.
tiff_pyramid_level * closest(const float scale) const
find the image resource with scale closest to specified scale.
unsigned nj() const
Height.
unsigned size_block_j() const override
Block size in rows (must be a multiple of 16).
Indicates that some reference was made to pixels beyond the bounds of an image.
vil_tiff_header * h_
the TIFF header information.
unsigned size_block_i() const override
Block size in columns (must be a multiple of 16).
vil_blocked_image_resource_sptr blocked_image_resource(const vil_image_resource_sptr &ir)
cast to blocked resource if possible.
unsigned n_block_i() const override
Number of blocks in image width.
bool set_compression_quality(int quality)
Pyramid resource built on the multi-image capability of the TIFF format.
bool put_view(const vil_image_view_base &im, unsigned i0, unsigned j0) override
Put the data in this view back into the image source.
#define vil_property_size_block_i
For unblocked images, the following properties are not implemented.
vil_tiff_image(tif_smart_ptr const &tif, vil_tiff_header *th, const unsigned nimages=1)
Various image copying functions.
unsigned cur_level_
temporary variable for current level.
bool * tiff_byte_align_data< bool >(bool *in_data, unsigned num_samples, unsigned in_bits_per_sample, bool *out_data)
void ref()
up/down the reference count.
vil_image_view_base_sptr get_copy_view() const
Create a read/write view of a copy of all the data.
A base class reference-counting view of some image data.
vil_memory_chunk_sptr tiff_maybe_byte_align_data(vil_memory_chunk_sptr in_data, unsigned num_samples, unsigned in_bits_per_sample, unsigned bytes_per_block)
Generic image interface for image TIFF image files (could have multiple images).
There is no class or function called vil_property.
An image resource list reader. Finds all resources of a type in the given directory.
Ref. counted block of data on the heap.
char const * vil_tiff_format_tag
void pad_block_with_zeros(unsigned ioff, unsigned joff, unsigned iclip, unsigned jclip, unsigned bytes_per_pixel, vxl_byte *block_buf)
fill out the block with leading zeros or trailing zeros if necessary.
vil_memory_chunk_sptr tiff_maybe_byte_align_data< double >(vil_memory_chunk_sptr in_data, unsigned, unsigned, unsigned)
#define GET_VIEW_PTR(FORMAT, T)
bool put_block(unsigned block_index_i, unsigned block_index_j, const vil_image_view_base &blk) override
put the block into the resource at the indicated location.
unsigned ni_
the image width.
unsigned ni() const override
Dimensions: Planes x ni x nj.
#define vil_property_size_block_j
Block size in rows.
unsigned nplanes() const override
Dimensions: planes x width x height x components.
void vil_exception_warning(T exception)
Throw an exception indicating a potential problem.
~vil_tiff_pyramid_resource() override
vil_image_view_base_sptr fill_block_from_strip(vil_memory_chunk_sptr const &buf) const
bool set_compression_method(compression_methods cm)
bool put_resource(vil_image_resource_sptr const &resc) override
Caution! The resource is assigned a header and the data is permanently written into the file.
unsigned nplanes() const override
The number of planes (or components) of the image.
bool vil_copy_deep(const vil_image_resource_sptr &src, vil_image_resource_sptr &dest)
Copy src to dest.
vil_image_view_base_sptr get_block(unsigned block_index_i, unsigned block_index_j) const override
Block access.
bool vil_tiff_file_format_probe(vil_stream *is)
unsigned ni() const override
The number of pixels in each row.
TIFF * tif() const
Convenient get TIFF* for header construction; assumes temporary use.
T * ptr() const
These methods all return the raw/dumb pointer.
void bitpack_block(unsigned bytes_per_block, const vxl_byte *in_block_buf, vxl_byte *out_block_buf)
unsigned int index_
the default image header index.
~vil_tiff_image() override
unsigned nj() const override
Dimensions: Planes x ni x nj.
bool write_block_to_file(unsigned bi, unsigned bj, unsigned block_size_bytes, vxl_byte *block_buf)
tif_smart_ptr t_
the TIFF handle to the open resource file.