iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::GenericImage Class Reference

#include <nrt/Core/Image/GenericImage.H>

A container that acts as a smart "union" of a few popular Image types.

The GenericImage class allows Image data to be passed around in a native format, thus deferring conversion. This is particuarly useful in the nrt::ImageSource and nrt::ImageSink classes:

  • The nrt::ImageSource returns a GenericImage from its in() method allowing users to receive and then transfer incoming images in their native format, thus incurring as few conversions as possible.
  • The nrt::ImageSink accepts a GenericImage in its out() method. This achieves the same effect as above, and also makes up for C++'s lack of virtual template functions.
Examples:
tests/test-GenericImage.C, tests/test-Geometry.C, tests/test-ImageReader.C, tests/test-PointCloud2OpenNI.C, tests/test-Pyramid.C, tests/test-stream.C, and tests/test-UKF.C.

Definition at line 69 of file GenericImage.H.

Public Types

typedef Array2DBase::DimsType DimsType
 

Public Member Functions

 GenericImage ()
 Construct an empty generic image.
 
template<class PixType >
 GenericImage (Image< PixType > const &img)
 Construct a generic image from an nrt::Image.
 
 GenericImage (GenericImage const &gimg)
 Construct from another GenericImage.
 
template<class PixType >
GenericImageoperator= (Image< PixType > const &img)
 Assign from an nrt::Image.
 
GenericImageoperator= (GenericImage const &gimg)
 Assign from another GenericImage.
 
Dims< int32 > const & dims () const
 Get the dimensions of the underlying Image.
 
Rectangle< int32 > bounds () const
 Get the dimensions of the underlying Image.
 
int32 width () const
 Get the width of the underlying Image.
 
int32 height () const
 Get the height of the underlying Image.
 
int32 size () const
 Is there any Image data stored in this GenericImage? If this is zero the image is empty / no image.
 
template<class Ima >
bool isa () const
 Is our underlying Image of type Ima? More...
 
template<class PixType >
bool hasPixels () const
 Has our underlying Image pixels of type PixType?
 
std::string typeStr () const
 Get the underlying Image type as a string, mostly for debugging messages and testing.
 
template<class PixType >
Image< PixType > & get ()
 Get the underlying nrt::Image, non-const version. More...
 
template<class PixType >
Image< PixType > const & get () const
 Get the underlying nrt::Image, const version. More...
 
void clear ()
 Reset to zero the contents of the GenericImage without changing the size.
 
template<class PixType >
Image< PixType > convertTo () const
 Convert to a specified nrt::Image<PixType> More...
 
template<class Visitor >
Visitor::result_type apply_visitor (Visitor &v) const
 Apply a unary visitor to GenericImage. More...
 
template<class Visitor >
Visitor::result_type apply_visitor (Visitor const &v) const
 Apply a unary visitor to GenericImage, const visitor version. More...
 
template<class Visitor >
void apply_inplace_visitor (Visitor &v)
 Apply a unary visitor in-place, i.e., the visitor may change our GenericImage content. More...
 
template<class Visitor >
void apply_inplace_visitor (Visitor const &v)
 Apply a unary visitor in-place, i.e., the visitor may change our GenericImage content, const visitor version. More...
 
template<class BinaryVisitor >
BinaryVisitor::result_type apply_visitor (BinaryVisitor &v, GenericImage const &gim2) const
 Apply a binary visitor to two GenericImage objects (this and gimg2) More...
 
template<class BinaryVisitor >
BinaryVisitor::result_type apply_visitor (BinaryVisitor const &v, GenericImage const &gim2) const
 Apply a binary visitor to two GenericImage objects (this and gimg2), const visitor version. More...
 
template<class PixType >
nrt::GenericImageoperator= (nrt::Image< PixType > const &img)
 
template<class PixType >
nrt::Image< PixType > & get ()
 
template<class PixType >
nrt::Image< PixType > const & get () const
 
template<class PixType >
nrt::Image< PixType > convertTo () const
 

Protected Member Functions

template<class Archive >
void serialize (Archive &ar)
 Serialize the GenericImage into/out-of an archive.
 

Friends

class cereal::access
 

Member Function Documentation

template<class Ima >
bool nrt::GenericImage::isa ( ) const
inline

Is our underlying Image of type Ima?

Ima should be an nrt::Image<sometype>

Examples:
tests/test-GenericImage.C.

Definition at line 92 of file GenericImageImpl.H.

template<class PixType >
Image<PixType>& nrt::GenericImage::get ( )

Get the underlying nrt::Image, non-const version.

Exceptions
boost::bad_getexception if PixType is not our underlying type; use isa<Image<sometype>>() or hasPixels<sometype> to find out the pixel type. Note that get() is not the preferred way of using GenericImage for processing, see apply_visitor() or convertTo() instead.
Examples:
tests/test-PointCloud2OpenNI.C.
template<class PixType >
Image<PixType> const& nrt::GenericImage::get ( ) const

Get the underlying nrt::Image, const version.

Exceptions
boost::bad_getexception if PixType is not our underlying type; use isa<Image<sometype>>() or hasPixels<sometype> to find out the pixel type. Note that get() is not the preferred way of using GenericImage for processing, see apply_visitor() or convertTo() instead.
template<class PixType >
Image<PixType> nrt::GenericImage::convertTo ( ) const

Convert to a specified nrt::Image<PixType>

If our underlying Image's pixel type is not the same as the desired one, an expensive pixel-by-pixel conversion will occur, otherwise this operation is very fast due to the copy-on-write mechanism of Image.

Examples:
tests/test-ImageReader.C.
template<class Visitor >
Visitor::result_type nrt::GenericImage::apply_visitor ( Visitor &  v) const
inline

Apply a unary visitor to GenericImage.

Use this to apply some Image processing function to a GenericImage

Definition at line 113 of file GenericImageImpl.H.

Referenced by nrt::crop(), and nrt::cropAndFill().

template<class Visitor >
Visitor::result_type nrt::GenericImage::apply_visitor ( Visitor const &  v) const
inline

Apply a unary visitor to GenericImage, const visitor version.

Use this to apply some Image processing function to a GenericImage

Definition at line 118 of file GenericImageImpl.H.

template<class Visitor >
void nrt::GenericImage::apply_inplace_visitor ( Visitor &  v)
inline

Apply a unary visitor in-place, i.e., the visitor may change our GenericImage content.

Use this to apply some in-place Image processing function to a GenericImage

Definition at line 123 of file GenericImageImpl.H.

template<class Visitor >
void nrt::GenericImage::apply_inplace_visitor ( Visitor const &  v)
inline

Apply a unary visitor in-place, i.e., the visitor may change our GenericImage content, const visitor version.

Use this to apply some in-place Image processing function to a GenericImage

Definition at line 132 of file GenericImageImpl.H.

template<class BinaryVisitor >
BinaryVisitor::result_type nrt::GenericImage::apply_visitor ( BinaryVisitor &  v,
nrt::GenericImage const &  gim2 
) const
inline

Apply a binary visitor to two GenericImage objects (this and gimg2)

Use this to apply some Image processing function that combines the present GenericImage with another

Definition at line 142 of file GenericImageImpl.H.

template<class BinaryVisitor >
BinaryVisitor::result_type nrt::GenericImage::apply_visitor ( BinaryVisitor const &  v,
nrt::GenericImage const &  gim2 
) const
inline

Apply a binary visitor to two GenericImage objects (this and gimg2), const visitor version.

Use this to apply some Image processing function that combines the present GenericImage with another

Definition at line 148 of file GenericImageImpl.H.


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