libpniio
Public Member Functions | Protected Member Functions
pni::io::image_reader Class Referenceabstract

base class for image readers More...

#include <image_reader.hpp>

Inheritance diagram for pni::io::image_reader:
Inheritance graph
[legend]
Collaboration diagram for pni::io::image_reader:
Collaboration graph
[legend]

Public Member Functions

virtual ~image_reader ()
 destructor More...
 
virtual size_t nimages () const =0
 get number of images More...
 
virtual image_info info (size_t i) const =0
 get image info 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...
 
- Public Member Functions inherited from pni::io::data_reader
virtual ~data_reader ()
 destructor More...
 
pni::core::string filename () const
 get filename More...
 
void filename (const pni::core::string &fname)
 set filename More...
 
virtual void close ()
 close the file More...
 
virtual void open ()
 open file More...
 

Protected Member Functions

 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_readeroperator= (const image_reader &r)=delete
 copy assignment is deleted More...
 
image_readeroperator= (image_reader &&r)
 move assignment operator More...
 
- Protected Member Functions inherited from pni::io::data_reader
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_readeroperator= (const data_reader &r)=delete
 copy assigment is deleted More...
 
data_readeroperator= (data_reader &&r)
 move assignment More...
 

Detailed Description

The image_reader class provides the basic functionality for all other image readers. It opens the file and provides a stream from which to read data. ImageReader objects cannot be copied or copy-assigned. However, they can be moved using std::move.

Like data_reader (from which it is derived) an ImageReader object cannot be instantiated using this class. All constructors and assignment operators are thus protected making them only available to derived classes.

Constructor & Destructor Documentation

pni::io::image_reader::image_reader ( )
protected
pni::io::image_reader::image_reader ( const image_reader )
protecteddelete
pni::io::image_reader::image_reader ( image_reader &&  r)
protected
pni::io::image_reader::image_reader ( const pni::core::string &  fname,
bool  binary = false 
)
explicitprotected
pni::io::image_reader::~image_reader ( )
virtual

Member Function Documentation

template<typename ATYPE >
ATYPE pni::io::image_reader::image ( size_t  ,
size_t   
)
inline

This method returns an object determined by ArrayType holding the data from channel c (default is 0) of image i in the file. This method must be implemented by all child classes of ImageReader. It is assumed that the method will allocate enough memory and configure the returning object appropriately.

Parameters
iindex of the image in the file
c(default = 0) image channel to read
Returns
instance of ArrayType holding the channel data
template<typename ATYPE >
void pni::io::image_reader::image ( ATYPE &  ,
size_t  ,
size_t   
)
inline

This method reads the data from channle c (default = 0) of image i in the file and stores it in an Array template supplied by the user. The array must provide enough space to hold the data otherwise exceptions will be thrown. The addvantage of this method is that it does not waste time with memory allocation. It is thus useful in cases where data from many files of same size must be read.

Parameters
arrayarray where to store the data
iindex of the image in the file
c(default = 0) index of the channel from which to read data.
virtual image_info pni::io::image_reader::info ( size_t  i) const
pure virtual

Return an instance of ImageInfo with the information of image i in the image stack. This is a virtual function which must be implemented by the concrete reader classes.

Parameters
iindex of the image
Returns
vector with ImageInfo objects

Implemented in pni::io::tiff_reader, and pni::io::cbf_reader.

virtual size_t pni::io::image_reader::nimages ( ) const
pure virtual

Returns the number of images stored in the file. This methods reflects the fact that many image formats can hold more than one image in a single file (CBF, TIFF). Although this feature is hardly used for experiments it should be taken into account. This is a virtual function which must be implemented by the concrete reader classes.

Returns
number of images

Implemented in pni::io::tiff_reader, and pni::io::cbf_reader.

image_reader& pni::io::image_reader::operator= ( const image_reader r)
protecteddelete
image_reader & pni::io::image_reader::operator= ( image_reader &&  r)
protected

The documentation for this class was generated from the following files: