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

#include <nrt/ImageProc/Color/ColorMap.H>

Simple colormaps with N colors.

ColorMap derives from Image< PixRGB<byte> > and hence inherits all the associated functions. Here we just provide a bunch of constructors. A ColorMap then is merely an Image< PixRGB<byte> > of width N and height 1.

Definition at line 49 of file ColorMap.H.

Inheritance diagram for nrt::ColorMap:
nrt::Image< PixRGB< byte > > nrt::Array2D< PixRGB< byte > >

Public Member Functions

 ColorMap ()
 Default constructor (empty colormap)
 
 ColorMap (const int n)
 Default constructor (uninitialized color values, n entries)
 
 ColorMap (const Image< PixRGB< byte > > &cmap)
 Build from an Image of pixels (used by the pseudo-constructors) More...
 
virtual ~ColorMap ()
 Destructor.
 
- Public Member Functions inherited from nrt::Image< PixRGB< byte > >
 Image ()
 Construct an empty (0 by 0) Image.
 
 Image (DimsType const &dims, ImageInitPolicy const p=ImageInitPolicy::None)
 Construct an Image of size dims using the given ImageInitPolicy. More...
 
 Image (int width, int height, ImageInitPolicy const p=ImageInitPolicy::None)
 Construct an Image of size width and height using given InitPolicy. More...
 
 Image (DimsType const &dims, PixRGB< byte >const val)
 Construct an Image of size Dims filled with val.
 
 Image (Image< PixRGB< byte >, OtherFlags > const &other)
 Copy constructor.
 
 Image (std::initializer_list< std::initializer_list< PixRGB< byte > >> vals)
 Construct from a 2D initializer list. More...
 
 Image (Image< U, OtherFlags > const &other)
 Color space conversion copy constructor. More...
 
 Image (PixRGB< byte > *data, DimsType const &dims)
 Construct an Image from a raw array. More...
 
Image< PixRGB< byte >, 0 > & operator= (Image< PixRGB< byte >, OtherFlags > const &other)
 Assignment operator.
 
Image< PixRGB< byte >, 0 > & operator= (Image< U, OtherFlags > const &other)
 Color space conversion assignment operator. More...
 
void clear (PixRGB< byte >const &val=PixRGB< byte >())
 Clear contents (or set to given value) without changing the size of the Image.
 
nrt::Range< PixRGB< byte > > const range () const
 Get the range (min,max) of pixel values contained in the image. If the image is empty then range is [0 .. 0]. More...
 
std::enable_if
< std::is_base_of
< PixelWithAlpha< U >
, ColorType< U > >::value,
void >::type 
draw (Point2D< int32 > const &p, ColorType< U > color)
 Draw the given color onto the Image pixel at point p. More...
 
void draw (Point2D< int32 > const &p, U color)
 Draw the given color onto the Image pixel at point p. More...
 
PixRGB< byte >const & at (int32 x, int32 y) const
 Read the pixel value at position (x, y) More...
 
PixRGB< byte >const & at (Point2D< int32 > p) const
 A convenient overload of at(int32 x, int32 y) const.
 
PixRGB< byte >const & at (uint32 idx) const
 A convenient overload of at(int32 x, int32 y) const for linear read-only access to the Image.
 
PixRGB< byte > interpolate (float x, float y) const
 Read the bilinearly interpolated value at position (x, y)
 
PixRGB< byte > interpolate (Point2D< float > p) const
 A convenient overload of interpolate(float x, float y) const.
 
PixRGB< byte > & operator() (int32 x, int32 y)
 Get a mutable reference to the value at position (x, y) More...
 
PixRGB< byte >const & operator() (int32 x, int32 y) const
 
PixRGB< byte > & operator() (Point2D< int32 > p)
 A convenient overload of operator()(int32 x, int32 y)
 
PixRGB< byte >const & operator() (Point2D< int32 > p) const
 
PixRGB< byte > & operator() (uint32 idx)
 A convenient overload of operator()(int32 x, int32 y) for linear write access to the Image.
 
PixRGB< byte >const & operator() (uint32 idx) const
 
bool coordsOk (const U x, const U y) const
 Test whether point falls inside array boundaries.
 
bool coordsOk (const Point2D< U > &P) const
 Convenient overload of coordsOk(int32 x, int32 y)
 
bool rectangleOk (const Rectangle< U > rect) const
 Test whether a rectangle falls inside array boundaries.
 
DimsType const & dims () const
 Get the dimensions of the Image.
 
Rectangle< int32 > const bounds () const
 Get the bounding rectangle of the Image.
 
int32 const width () const
 Get the width of the Image.
 
int32 const height () const
 Get the height of the Image.
 
int32 const size () const
 Get the total number of pixels in the Image; if it is zero then the image is un-initialized.
 
bool const empty () const
 Let the caller know whether the image is empty (0x0 dimensions) More...
 
void reshape (Dims< int32 > const &newDims)
 Reshape an image to new dims without changing the underlying data. More...
 
void reshape (int32 newWidth, int32 newHeight)
 Reshape an image to new dims without changing the underlying data. More...
 
nrt::Image< nrt::PixGray
< PODType > > 
channel (size_t chan) const
 Create a new single-channel Image from the chan'th channel of this Image. More...
 
Image< PixRGB< byte >, 0 > const & cref () const
 Get a const reference to a (potentially non-const) Image. More...
 
const_iterator const_begin () const
 Get constant (read-only) iterators to the beginning of the Image. More...
 
const_iterator begin () const
 Get constant (read-only) iterators to the beginning of the Image. More...
 
iterator begin ()
 Gets a read-write iterator to the beginning of the Image. More...
 
const_iterator const_end () const
 Get constant (read-only) iterators to the end of the Image. More...
 
const_iterator end () const
 Get constant (read-only) iterators to the beginning of the Image. More...
 
iterator end ()
 Gets a read-write iterator to the end of the Image. More...
 
pod_iterator pod_begin ()
 Gets a read-write pod iterator to the first channel of the first Pixel of the Image. More...
 
const_pod_iterator pod_begin () const
 Gets a constant (read-only) pod iterator to the first channel of the first Pixel of the const Image. More...
 
pod_iterator pod_end ()
 Gets a read-write pod iterator to one place past the last channel of the lat Pixel of the Image. More...
 
const_pod_iterator pod_end () const
 
const_pod_iterator const_pod_begin () const
 Gets a constant (read-only) pod iterator to the first channel of the first Pixel of the Image. More...
 
const_pod_iterator const_pod_end () const
 Gets a constant (read-only) pod iterator to one place past the last channel of the lat Pixel of the Image. More...
 
const_row_iterator const_row_begin (int32 row) const
 Get a read-only iterator to the beginning of a row.
 
const_row_iterator const_row_end (int32 row) const
 Get a read-only iterator to the end of a row.
 
const_row_iterator row_begin (int32 row) const
 Gets a read-only iterator to the beginning of a row.
 
row_iterator row_begin (int32 row)
 Gets a read-write iterator to the beginning of a row.
 
const_row_iterator row_end (int32 row) const
 Gets a read-only iterator to the end of a row.
 
row_iterator row_end (int32 row)
 Gets a read-write iterator to the end of a row.
 
const_col_iterator const_col_begin (int32 col) const
 Get a read-only iterator to the beginning of a column.
 
const_col_iterator const_col_end (int32 col) const
 Get a read-only iterator to the end of a column.
 
const_col_iterator col_begin (int32 col) const
 Get a read-only iterator to the beginning of a column.
 
col_iterator col_begin (int32 col)
 Get a read-write iterator to the beginning of a column.
 
const_col_iterator col_end (int32 col) const
 Get a read-only iterator to the end of a column.
 
col_iterator col_end (int32 col)
 Get a read-write iterator to the end of a column.
 
const_rect_iterator const_rect_begin (Rectangle< int32 > const &rect) const
 Get a read-only iterator to the beginning of a rectangle.
 
const_rect_iterator const_rect_end (Rectangle< int32 > const &rect) const
 Get a read-only iterator to the end of a rectangle.
 
const_rect_iterator rect_begin (Rectangle< int32 > const &rect) const
 Get a read-only iterator to the beginning of a rectangle.
 
rect_iterator rect_begin (Rectangle< int32 > const &rect)
 Get a read-only iterator to the beginning of a rectangle.
 
const_rect_iterator rect_end (Rectangle< int32 > const &rect) const
 Get a read-only iterator to the end of a rectangle.
 
rect_iterator rect_end (Rectangle< int32 > const &rect)
 Get a read-only iterator to the end of a rectangle.
 
convex_poly_iterator convex_poly_begin (Polygon< int32 > const &poly)
 Get a read-write iterator to the beginning of a polygon.
 
const_convex_poly_iterator convex_poly_begin (Polygon< int32 > const &poly) const
 Get a read-only iterator to the beginning of a polygon.
 
convex_poly_iterator convex_poly_end (Polygon< int32 > const &poly)
 Get a read-write iterator to the end of a polygon.
 
const_convex_poly_iterator convex_poly_end (Polygon< int32 > const &poly) const
 Get a read-only iterator to the end of a polygon.
 
const_convex_poly_iterator const_convex_poly_begin (Polygon< int32 > const &poly) const
 Get a read-only iterator to the beginning of a polygon.
 
const_convex_poly_iterator const_convex_poly_end (Polygon< int32 > const &poly) const
 Get a read-only iterator to the end of a polygon.
 
- Public Member Functions inherited from nrt::Array2D< PixRGB< byte > >
 Array2D ()
 Create an empty Array2D (will have size 0x0)
 
 Array2D (DimsType const &dims)
 Allocate an uninitialized Array2D with the given size.
 
 Array2D (DimsType const &dims, PixRGB< byte >const &val)
 Allocate an uninitialized Array2D, and fill every element with a copy of val.
 
 Array2D (Array2D< PixRGB< byte > > const &other)
 Copy constructor. More...
 
 Array2D (Array2D &&other)
 Move constructor. More...
 
 Array2D (std::initializer_list< std::initializer_list< PixRGB< byte > >> vals)
 Construct from a 2D initializer list.
 
 Array2D (PixRGB< byte >const *data, DimsType const &dims)
 Construct a 2D array from foreign memory by making a deep copy of it.
 
Array2Doperator= (Array2D< PixRGB< byte > > const &other)
 Assignment operator. More...
 
Array2Doperator= (Array2D< PixRGB< byte > > &&other)
 Move assignment operator. More...
 
void clear (PixRGB< byte >const &val=PixRGB< byte >())
 Clear contents (or set to given value) without changing the size of the Array2D.
 
PixRGB< byte >const & at (int32 x, int32 y) const
 Read the value at position (x, y) More...
 
PixRGB< byte >const & at (Point2D< int32 > p) const
 A convenient overload of at(int32 x, int32 y) const.
 
PixRGB< byte >const & at (uint32 idx) const
 A convenient overload of at(int32 x, int32 y) const for linear read-only access to the Array2D.
 
PixRGB< byte > & operator() (int32 x, int32 y)
 Get a mutable reference to the value at position (x, y) More...
 
PixRGB< byte >const & operator() (int32 x, int32 y) const
 Get a const reference to the value at position (x, y)
 
PixRGB< byte > & operator() (Point2D< int32 > p)
 A convenient overload of operator()(int32 x, int32 y)
 
PixRGB< byte >const & operator() (Point2D< int32 > p) const
 A convenient overload of operator()(int32 x, int32 y)
 
PixRGB< byte > & operator() (uint32 idx)
 A convenient overload of operator()(int32 x, int32 y) for linear write access to the Image.
 
PixRGB< byte >const & operator() (uint32 idx) const
 A convenient overload of operator()(int32 x, int32 y) for linear write access to the Image.
 
bool coordsOk (const U x, const U y) const
 Test whether point falls inside array boundaries.
 
bool coordsOk (const Point2D< U > &P) const
 Convenient overload of coordsOk(int32 x, int32 y)
 
bool rectangleOk (const Rectangle< U > rect) const
 Test whether a rectangle falls inside array boundaries.
 
DimsType const & dims () const
 Get the dimensions of the Array2D.
 
Rectangle< int32 > const bounds () const
 Get the bounding rectangle of the Array2D.
 
int32 const width () const
 Get the width of the Array2D.
 
int32 const height () const
 Get the height of the Array2D.
 
int32 const size () const
 Get the total number of elements in the Array2D; if it is zero then the image is un-initialized.
 
bool const empty () const
 Let the caller know whether the Array2D is empty (0x0 dimensions) More...
 
void reshape (Dims< int32 > const &newDims)
 Reshape an Array2D to new Dims without changing the number of elements in the underlying data. More...
 
void reshape (int32 newWidth, int32 newHeight)
 Reshape an image to new dims without changing the underlying data. More...
 
Array2D< PixRGB< byte > > const & cref () const
 Get a const reference to a (potentially non-const) Array2D. More...
 
const_iterator const_begin () const
 Get constant (read-only) iterators to the beginning of the Image. More...
 
const_iterator begin () const
 Get constant (read-only) iterators to the beginning of the Image. More...
 
iterator begin ()
 Gets a read-write iterator to the beginning of the Image. More...
 
const_iterator const_end () const
 Get constant (read-only) iterators to the end of the Image. More...
 
const_iterator end () const
 Get constant (read-only) iterators to the beginning of the Image. More...
 
iterator end ()
 Gets a read-write iterator to the end of the Image. More...
 
void deepCopy ()
 Make a deep copy of our Memory. More...
 

Static Public Member Functions

static ColorMap GREY (const int n=256)
 Pseudo-constructor for a greyscale with n entries.
 
static ColorMap GRADIENT (const PixRGB< byte > &from, const PixRGB< byte > &to, const int n=256)
 Pseudo-constructor for a transition from 'from' to 'to' with n entries.
 
static ColorMap JET (const int n=256)
 Pseudo-constructor for "jet" colormap a la matlab.
 
static ColorMap LINES (const int n=256)
 Pseudo-constructor for "lines" colormap a la matlab.
 

Additional Inherited Members

- Public Types inherited from nrt::Image< PixRGB< byte > >
typedef nrt_traits< PixRGB
< byte >
>::pixel_traits::pod_type 
PODType
 Convenient typedef for the POD type stored by our Pixel type.
 
typedef PixRGB< byte > PixelType
 Convenient typedef for our Pixel type.
 
typedef Array2DBase::DimsType DimsType
 Convenent typedef for our Dims type.
 
typedef PixRGB< byte > * iterator
 Read-write iterator over image pixels, scans in standard raster fashion (x varies fastest, then y) More...
 
typedef PixRGB< byte >const * const_iterator
 Constant iterator over image pixels, scans in standard raster fashion (x varies fastest, then y)
 
typedef PODTypepod_iterator
 Read-write iterator over the raw POD data stored in the Image. More...
 
typedef PODType const * const_pod_iterator
 Constant iterator over the raw POD data stored in the Image.
 
typedef iterator row_iterator
 Read-Write iterator onto a given row of the image.
 
typedef const_iterator const_row_iterator
 Constant iterator onto a given row of the image.
 
- Protected Member Functions inherited from nrt::Array2D< PixRGB< byte > >
void serialize (Archive &ar)
 
- Protected Attributes inherited from nrt::Array2D< PixRGB< byte > >
DimsType itsDims
 
Array< PixRGB< byte > > itsArray
 
 Initialization policy for the pixels inside an Image, used during construction of the Image. More...
 Flags to control the behavior of Images. More...

Constructor & Destructor Documentation

nrt::ColorMap::ColorMap ( const Image< PixRGB< byte > > &  cmap)

Build from an Image of pixels (used by the pseudo-constructors)

Will throw a fatal error if cmap has height != 1


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