libpniio
|
TIFF file reader. More...
#include <tiff_reader.hpp>
Public Member Functions | |
tiff_reader () | |
default constructor More... | |
tiff_reader (tiff_reader &&r) | |
move constructor More... | |
tiff_reader (const pni::core::string &fname) | |
standard constructor More... | |
tiff_reader (const tiff_reader &)=delete | |
copy constructor is deleted More... | |
~tiff_reader () | |
destructor More... | |
tiff_reader & | operator= (tiff_reader &&r) |
move assignment operator More... | |
tiff_reader & | operator= (const tiff_reader &r)=delete |
copy assignment operator is deleted More... | |
virtual size_t | nimages () const |
get number of images More... | |
virtual image_info | info (size_t i) const |
get ImageInfo More... | |
virtual void | open () |
open the file More... | |
virtual void | close () |
close the file More... | |
template<typename CTYPE > | |
CTYPE | image (size_t i, size_t c=0) |
read image data More... | |
template<typename CTYPE > | |
void | image (CTYPE &data, size_t i, size_t c=0) |
read image data More... | |
![]() | |
virtual | ~image_reader () |
destructor More... | |
template<typename ATYPE > | |
ATYPE | image (size_t, size_t) |
method to read a single channel More... | |
template<typename ATYPE > | |
void | image (ATYPE &, size_t, size_t) |
method to read a single image channel More... | |
![]() | |
virtual | ~data_reader () |
destructor More... | |
pni::core::string | filename () const |
get filename More... | |
void | filename (const pni::core::string &fname) |
set filename More... | |
Private Member Functions | |
void | _read_ifds () |
read IDF data from the file More... | |
template<typename CTYPE > | |
void | _read_data (size_t i, size_t c, CTYPE &data) |
read data from the file More... | |
Static Private Member Functions | |
static bool | _is_little_endian (std::ifstream &stream) |
check binary encoding More... | |
static void | _check_if_tiff (std::ifstream &stream) |
check if image is TIFF More... | |
static int32 | _read_ifd_offset (std::ifstream &stream) |
read IFD offset More... | |
static size_t | _read_ifd_size (std::ifstream &stream) |
read IFD size More... | |
static std::vector< size_t > | _get_bits_per_sample (std::ifstream &stream, const tiff::ifd &ifd) |
get bits per sample More... | |
static std::vector< size_t > | _get_sample_format (std::ifstream &stream, const tiff::ifd &ifd) |
get sample format More... | |
static type_id_t | _get_type_id (size_t bps, size_t sf) |
determine channel data type More... | |
Private Attributes | |
bool | _little_endian |
true if data is stored as little endian More... | |
std::vector< tiff::ifd > | _ifds |
IFD list. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const tiff_reader &r) |
output operator of an TIFFReader object More... | |
Additional Inherited Members | |
![]() | |
image_reader () | |
default constructor More... | |
image_reader (const image_reader &)=delete | |
copy constructor is deleted More... | |
image_reader (image_reader &&r) | |
move constructor More... | |
image_reader (const pni::core::string &fname, bool binary=false) | |
standard constructor taking the filename as string object More... | |
image_reader & | operator= (const image_reader &r)=delete |
copy assignment is deleted More... | |
image_reader & | operator= (image_reader &&r) |
move assignment operator More... | |
![]() | |
std::ifstream & | _get_stream () const |
get stream More... | |
void | _set_binary () |
set binary mode More... | |
data_reader () | |
default constructor More... | |
data_reader (const pni::core::string &fname, bool binary=false) | |
standard constructor More... | |
data_reader (data_reader &&r) | |
move constructor More... | |
data_reader (const data_reader &r)=delete | |
copy constructor is deleted More... | |
data_reader & | operator= (const data_reader &r)=delete |
copy assigment is deleted More... | |
data_reader & | operator= (data_reader &&r) |
move assignment More... | |
TIFFReader is an implementation of the Reader class for reading TIFF image files. Actually only uncompressed TIFF images are supported. The copy constructor and the copy assignment operator are deleted to prevent copy construction of this object.
pni::io::tiff_reader::tiff_reader | ( | ) |
pni::io::tiff_reader::tiff_reader | ( | tiff_reader && | r | ) |
r | reader from which to move data to the new instance |
|
explicit |
|
delete |
pni::io::tiff_reader::~tiff_reader | ( | ) |
|
staticprivate |
Checks if the stream belongs to a TIFF image. If the file is not a TIFF file an exception will be thrown. No assumption is made about the position of the stream. The methods adjusts the stream to the proper positions and resets it to its original position once finished.
stream | input stream from which to read data |
FileError | if stream is not a TIFF file |
|
staticprivate |
Returns a vector whose length corresponds to the number of channels in the image. Each element holds the number of bits used to store the data for the corresponding channel.
stream | image file stream |
ifd | IFD of the image |
|
staticprivate |
The sample format decides how to interpret the bits stored for each channel. Depending on its value the channel data will be interpreted as unsigned integer, signed integer, or IEEE floating point number.
stream | image file stream |
ifd | IFD of the image in the file |
|
staticprivate |
Static method to deduce the type of an image channel from the sample format and the number of bits used for the channel data. If the type could not be deduced an exception will be thrown.
type_error | if the type cannot be deduced from the data |
bps | number of bits per sample |
sf | sample format |
|
staticprivate |
This private method checks if the image is encoded as TIFF or not. The method makes no assumption about the position of the stream pointer. It moves it automatically to the correction position and reads the data from there. Afterwards the stream will be reset to the position where it originally was. True is returned when the TIFF file contains little endian encoded data and false otherwise.
stream | input stream from which to read data |
|
private |
Reads data form the file and stores it into a container of type CTYPE.
CTYPE | container type where to store the data |
i | image number |
c | channel number of the selected image |
data | instance of CTYPE which will hold the data |
|
staticprivate |
Method obtains the offset for an IFD from the actual stream position.
stream | input stream from which to read data |
|
staticprivate |
Reads the number of IFD entries from the actual stream position
stream | input stream from which to read data |
|
private |
Read all the IDF data from the file and store them in the _idfs private member variable.
|
virtual |
Reimplemented from pni::io::data_reader.
|
inline |
Template method to read image data from the file. The returns an instance of the the template Array<T,BT> and does all the configuration and memory allocation work for this object.
memory_allocation_error | if array allocation fails |
i | index of the image in the file |
c | index of the image channel to read |
|
inline |
Reads the image data from the file and stores it in a user suppliedb array object. The method checks if the arrays shape and allocation state fits the requirements of the image. The advantage of this method is that memory allocation must be done only once before this method is called. This increases performance dramatically in particular if many images of equal size should be read.
size_mismatch_error | if the size of the container does not match the number of pixels stored in the image |
data | instance of CTYPE where data will be stored |
i | index of the image in the file |
c | index of the image channel to read |
|
virtual |
Return an instance of ImageInfo for image i stored in the file.
i | index of the image |
Implements pni::io::image_reader.
|
virtual |
Return the number of images stored in the image file.
Implements pni::io::image_reader.
|
virtual |
Reimplemented from pni::io::data_reader.
tiff_reader & pni::io::tiff_reader::operator= | ( | tiff_reader && | r | ) |
|
delete |
|
friend |
|
private |
|
private |