iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Container-style Image algorithms resembling those of std::algorithm

These methods provide convenient wrappers to the std::algorithm library for working with Images. In general, it is faster and cleaner to use these methods rather than explicitely looping through all of the pixels with a (pair of) for loop(s) around Image::at() or Image::operator().

See Also
Image class template and related classes and functions

Functions

template<class PixType , class BinaryOperation >
PixType nrt::accumulate (nrt::Image< PixType > const &img, PixType init=PixType(0), BinaryOperation op=std::plus< PixType >())
 Accumulate the values of all pixels in the Image. More...
 
template<class PixType , class UnaryOperator >
void nrt::transformInPlace (nrt::Image< PixType > &lhs, UnaryOperator op)
 Apply the given unary operator to each pixel in lhs, storing the returned value back into that pixel. More...
 
template<class PixType1 , class PixType2 , class BinaryOperator >
void nrt::transformInPlace (nrt::Image< PixType1 > &lhs, nrt::Image< PixType2 > const &rhs, BinaryOperator op)
 Apply the given binary operator to each pixel in lhs and rhs, and store the result in lhs's pixel. More...
 
template<class PixType , class UnaryOperator >
nrt::Image< PixType > nrt::transform (nrt::Image< PixType > const &lhs, UnaryOperator op)
 Apply the given unary operator to each pixel in lhs, storing the result in a new Image. More...
 
template<class PromoteType , class PixType , class UnaryOperator >
nrt::Image< PromoteType > nrt::transform (nrt::Image< PixType > const &lhs, UnaryOperator op)
 Apply the given unary operator to each pixel in lhs, storing the result in a new Image of type PixelType. More...
 
template<class PixType1 , class PixType2 , class BinaryOperator >
std::enable_if< nrt_traits
< PixType1, PixType2 >
::has_arithmetic, nrt::Image
< typename nrt_traits
< PixType1, PixType2 >
::promote_type > >::type 
nrt::transform (nrt::Image< PixType1 > const &lhs, nrt::Image< PixType2 > const &rhs, BinaryOperator op)
 Apply the given binary function to each pixel in lhs and rhs, storing the result in a new Image. More...
 
template<class PixType , class UnaryOperator >
nrt::Image< PixType > nrt::channel_transform (nrt::Image< PixType > const &lhs, UnaryOperator op)
 Apply the given unary operator to each channel of each pixel in lhs, storing the result in a new Image. More...
 
template<class PromoteType , class PixType , class UnaryOperator >
nrt::Image< PromoteType > nrt::channel_transform (nrt::Image< PixType > const &lhs, UnaryOperator op)
 Apply given unary operator to each channel of each pixel in lhs, storing result in a new Image of type PixelType. More...
 
template<class PixType1 , class PixType2 , class BinaryOperator >
std::enable_if< nrt_traits
< PixType1, PixType2 >
::has_arithmetic, nrt::Image
< typename nrt_traits
< PixType1, PixType2 >
::promote_type > >::type 
nrt::channel_transform (nrt::Image< PixType1 > const &lhs, nrt::Image< PixType2 > const &rhs, BinaryOperator op)
 Apply the given binary function to each channel of each pixel in lhs and rhs, storing the result in a new Image. More...
 
template<class PixType , class UnaryFunction >
void nrt::for_each (nrt::Image< PixType > const &img, UnaryFunction op)
 Run the given unary function on each pixel in img. More...
 

Function Documentation

template<class PixType , class BinaryOperation >
PixType nrt::accumulate ( nrt::Image< PixType > const &  img,
PixType  init = PixType(0),
BinaryOperation  op = std::plus< PixType >() 
)
inline

Accumulate the values of all pixels in the Image.

Parameters
imgThe Image on which to perform the accumulation
initThe initial value of the accumulation. The default is PixType(0).
opThe binary operation to perform on the running accumulation tally and each new pixel in img. The default is the plus operator, but you may supply whatever custom operator you wish.
Examples:
tests/test-Image.C.

Definition at line 45 of file ImageAlgorithmsImpl.H.

References nrt::Image< T, Flags >::const_begin(), and nrt::Image< T, Flags >::const_end().

template<class PixType , class UnaryOperator >
void nrt::transformInPlace ( nrt::Image< PixType > &  lhs,
UnaryOperator  op 
)
inline

Apply the given unary operator to each pixel in lhs, storing the returned value back into that pixel.

Parameters
lhsThe image on which to perform the transformation, as well as the destination for the results of op
opThe unary operator which is applied to each pixel
Examples:
tests/test-Image.C.

Definition at line 54 of file ImageAlgorithmsImpl.H.

References nrt::Image< T, Flags >::begin(), nrt::Image< T, Flags >::const_begin(), nrt::Image< T, Flags >::const_end(), and nrt::transform().

template<class PixType1 , class PixType2 , class BinaryOperator >
void nrt::transformInPlace ( nrt::Image< PixType1 > &  lhs,
nrt::Image< PixType2 > const &  rhs,
BinaryOperator  op 
)
inline

Apply the given binary operator to each pixel in lhs and rhs, and store the result in lhs's pixel.

Parameters
lhsThe left-hand-side image whose pixels are fed as the first parameter to op, as well as the destination for the result of op.
rhsthe right-hand-side image whose pixels are fed as the second parameter to op.
opThe binary operator which is applied to each pair of pixels

Definition at line 61 of file ImageAlgorithmsImpl.H.

References nrt::Image< T, Flags >::begin(), nrt::Image< T, Flags >::const_begin(), nrt::Image< T, Flags >::const_end(), and nrt::transform().

template<class PixType , class UnaryOperator >
nrt::Image< PixType > nrt::transform ( nrt::Image< PixType > const &  lhs,
UnaryOperator  op 
)
inline

Apply the given unary operator to each pixel in lhs, storing the result in a new Image.

Parameters
lhsThe source of pixels to be fed into op
opThe unary operator to apply to each pixel of lhs. The returned value is stored in the corresponding location of a new Image.
Examples:
tests/test-Geometry.C, tests/test-Image.C, tests/test-ImagePerformance.C, tests/test-PointCloud2Registration.C, and tests/test-TransformManager.C.

Definition at line 70 of file ImageAlgorithmsImpl.H.

References nrt::Image< T, Flags >::const_begin(), nrt::Image< T, Flags >::const_end(), and nrt::Image< T, Flags >::dims().

Referenced by nrt::Image< T, Flags >::channel(), nrt::channel_transform(), nrt::imageToEigenMatrix(), nrt::imageToEigenVector(), nrt::Point< T, Dimensions >::Point(), nrt::transform(), and nrt::transformInPlace().

template<class PromoteType , class PixType , class UnaryOperator >
nrt::Image< PromoteType > nrt::transform ( nrt::Image< PixType > const &  lhs,
UnaryOperator  op 
)
inline

Apply the given unary operator to each pixel in lhs, storing the result in a new Image of type PixelType.

The only difference between this method and the one above is that the returned Image will be of type PromoteType, rather than PixType.

Parameters
lhsThe image on which to perform the transformation.
opThe unary operator which is applied to each pixel. The returned value is converted to PromoteType and stored in the corresponding location of a new Image.
Template Parameters
PromoteTypeThe pixel type for the new Image

Definition at line 79 of file ImageAlgorithmsImpl.H.

References nrt::Image< T, Flags >::const_begin(), nrt::Image< T, Flags >::const_end(), nrt::Image< T, Flags >::dims(), and nrt::transform().

template<class PixType1 , class PixType2 , class BinaryOperator >
std::enable_if< nrt_traits< PixType1, PixType2 >::has_arithmetic, nrt::Image< typename nrt_traits< PixType1, PixType2 >::promote_type > >::type nrt::transform ( nrt::Image< PixType1 > const &  lhs,
nrt::Image< PixType2 > const &  rhs,
BinaryOperator  op 
)
inline

Apply the given binary function to each pixel in lhs and rhs, storing the result in a new Image.

Parameters
lhsThe left-hand-side image whose pixels are fed as the first parameter to op.
rhsThe right-hand-side image whose pixels are fed as the second parameter to op.
opThe binary operator which is applied to each pair of pixels. The returned value is converted to the promoted value of PixType1 and PixType2, and stored in the corresponding location of a new Image.

Definition at line 90 of file ImageAlgorithmsImpl.H.

References nrt::Image< T, Flags >::const_begin(), nrt::Image< T, Flags >::const_end(), nrt::Image< T, Flags >::dims(), and nrt::transform().

template<class PixType , class UnaryOperator >
nrt::Image< PixType > nrt::channel_transform ( nrt::Image< PixType > const &  lhs,
UnaryOperator  op 
)

Apply the given unary operator to each channel of each pixel in lhs, storing the result in a new Image.

Parameters
lhsThe source of pixels to be fed into op
opThe unary operator (which takes in a single PixType::PODType) to apply to each channel of each pixel of lhs. The returned value is stored in the corresponding location of a new Image.

Definition at line 100 of file ImageAlgorithmsImpl.H.

References nrt::transform().

template<class PromoteType , class PixType , class UnaryOperator >
nrt::Image< PromoteType > nrt::channel_transform ( nrt::Image< PixType > const &  lhs,
UnaryOperator  op 
)

Apply given unary operator to each channel of each pixel in lhs, storing result in a new Image of type PixelType.

The only difference between this method and the one above is that the returned Image will be of type PromoteType, rather than PixType.

Parameters
lhsThe image on which to perform the transformation.
opThe unary operator (which takes in a single PixType::PODType) which is applied to each channel of each pixel.

The returned value is converted to PromoteType and stored in the corresponding location of a new Image.

Template Parameters
PromoteTypeThe pixel type for the new Image

Definition at line 112 of file ImageAlgorithmsImpl.H.

References nrt::transform().

template<class PixType1 , class PixType2 , class BinaryOperator >
std::enable_if< nrt_traits< PixType1, PixType2 >::has_arithmetic, nrt::Image< typename nrt_traits< PixType1, PixType2 >::promote_type > >::type nrt::channel_transform ( nrt::Image< PixType1 > const &  lhs,
nrt::Image< PixType2 > const &  rhs,
BinaryOperator  op 
)

Apply the given binary function to each channel of each pixel in lhs and rhs, storing the result in a new Image.

Parameters
lhsThe left-hand-side image whose pixels are fed as the first parameter to op.
rhsThe right-hand-side image whose pixels are fed as the second parameter to op.
opThe binary operator (which takes in a two PixType::PODType's) which is applied to each channel of each pair of pixels.

The returned value is converted to the promoted value of PixType1 and PixType2, and stored in the corresponding location of a new Image.

Definition at line 126 of file ImageAlgorithmsImpl.H.

References nrt::transform().

template<class PixType , class UnaryFunction >
void nrt::for_each ( nrt::Image< PixType > const &  img,
UnaryFunction  op 
)
inline

Run the given unary function on each pixel in img.

Parameters
imgThe Image on which to apply the unary function.
opA unary function that is run with each pixel as a parameter.
Examples:
tests/test-Image.C.

Definition at line 142 of file ImageAlgorithmsImpl.H.

References nrt::Image< T, Flags >::const_begin(), and nrt::Image< T, Flags >::const_end().