Image Component Library (ICL)
|
Utility helper class for faster and more convenient access to single channel image data. More...
#include <Channel.h>
Public Types | |
typedef T * | iterator |
typedef for a normal iterator (just a pointer) More... | |
typedef const T * | const_iterator |
const iterator type (just a const pointer) More... | |
typedef ImgIterator< T > | roi_iterator |
type definition for ROI iterator More... | |
typedef const ImgIterator< T > | const_roi_iterator |
type definition for a const ROI iterator More... | |
Public Member Functions | |
Channel () | |
Empty constructor (create an invalid Channel object) More... | |
Channel (const Channel &other) | |
Copy an image channel (this could be exploited to violate const concept) More... | |
Channel< T > & | operator= (Channel< T > &other) |
assignmet operator More... | |
const Channel< T > & | operator= (const Channel< T > &other) const |
assign operator (also for const channels) More... | |
T & | operator() (int x, int y) |
main working function: returns a reference to the pixel at position (x,y) More... | |
T & | operator() (const utils::Point &p) |
convenience function for point-based index access More... | |
const T & | operator() (const utils::Point &p) const |
convenience function for point-based index access (const) More... | |
const T & | operator() (int x, int y) const |
main working function: returns const a reference to the pixel at position (x,y) More... | |
T & | operator[] (int idx) |
working function for linear pixel array access ( not const version) More... | |
const T & | operator[] (int idx) const |
working function for linear pixel array access (const version) More... | |
template<class Vec2D > | |
T | operator() (const Vec2D &p) const |
index operator with linear interpolation More... | |
iterator | begin () |
returns the image iterator (equal to getData(channel)) More... | |
const_iterator | begin () const |
returns the image iterator (equal to getData(channel)) (const) More... | |
iterator | end () |
returns the image end-iterator (equal to getData(channel)+getDim()) More... | |
const_iterator | end () const |
returns the image end-iterator (const) More... | |
roi_iterator | beginROI () |
returns the iterator for an images ROI More... | |
const_roi_iterator | beginROI () const |
returns the iterator for an images ROI (const) More... | |
roi_iterator | endROI () |
returns the end-iterator for an images ROI More... | |
const_roi_iterator | endROI () const |
returns the end-iterator for an images ROI (const) More... | |
bool | isNull () const |
int | getWidth () const |
returns the wrapped images width More... | |
int | getHeight () const |
returns the wrapped images height More... | |
const utils::Size & | getSize () const |
retusn the wrapped images size More... | |
int | getDim () const |
returns the wrapped images dim = width*height More... | |
const utils::Rect & | getROI () const |
returns the channel ROI More... | |
utils::Point | getROIOffset () const |
returns the channel ROI offset More... | |
utils::Size | getROISize () const |
returns the channel ROI size More... | |
int | getROIWidth () const |
returns the channel ROI width More... | |
int | getROIHeight () const |
returns the channel ROI height More... | |
int | getROIXOffset () const |
returns the channel ROI X-Offset More... | |
int | getROIYOffset () const |
returns the channel ROI Y-Offset More... | |
void | redefineROI (const utils::Rect &newROI) const |
Sets a new ROI to this image channel (this does not affect the underlying images ROI) More... | |
void | deepCopy (Channel< T > &other) const |
deeply copies the channel data (no roi support here) More... | |
template<class OtherT > | |
void | convert (Channel< OtherT > &other) const |
deeply converts the channel data (no roi support here) More... | |
Private Member Functions | |
Channel (const T *data, const utils::Size &size, const utils::Rect &roi) | |
private constructor More... | |
Channel (T *data, const utils::Size &size, const utils::Rect &roi) | |
Private Attributes | |
T * | m_data |
utils::Size | m_size |
utils::Rect | m_roi |
Friends | |
class | Img< T > |
mades Img<T> a friend to allow it construction of ImgChannels More... | |
Utility helper class for faster and more convenient access to single channel image data.
Yet, the (x,x,c)-operator of the Img<T> class is slow, because of hight computational overhead due to the necessity of a channel lookup The (x,y,c)-operator needs first to lookup for the channel c in the channel array of the image, before it can address a pixels value by dereferencing the shared pointers wrapped data pointer. In many cases, The user works on images with a fixed channel count (mostly 1 or 3), and needs a simple (x,y)-data access operator, which translates an (x,y) pixel address into the raw data pointer address dataPointer[x+width*y].
The Channel class was designed to facilitate this procedure. To avoid the arise of an The following code example shows how to replace the Imgs (x,y,c)-operator by using the Channel template class:
The lower function is about 6.5 times faster than the upper one!
When working on multi channel images with a fixed channel count, the advantage of using the ImgChannel class becomes even greater:
In The above example, the lower version of the copy function is even 7 times as fast as the upper version. At last, we want to examine the speed advantage for dynamic channel count and image size. The corresponding code is illustrated in the following code example:
In this example, the lower function is only 3 times faster, than the above one. Here, the advantage is not as large as in the above examples, but an acceleration factor of 3 should not be neglected.
The Channel<T> template class is typedef'd for all current Img<T> classes Channel8u, Channel16s, Channel32s, Channel32f, Channel64f.
typedef const T* icl::core::Channel< T >::const_iterator |
const iterator type (just a const pointer)
typedef const ImgIterator<T> icl::core::Channel< T >::const_roi_iterator |
type definition for a const ROI iterator
typedef T* icl::core::Channel< T >::iterator |
typedef for a normal iterator (just a pointer)
typedef ImgIterator<T> icl::core::Channel< T >::roi_iterator |
type definition for ROI iterator
|
inline |
|
inline |
Copy an image channel (this could be exploited to violate const concept)
|
inlineprivate |
private constructor
data | data pointer (image) wich's channel should be wrapped |
size | size of the data |
roi | roi of the data (image) |
|
inlineprivate |
|
inline |
returns the image iterator (equal to getData(channel))
|
inline |
returns the image iterator (equal to getData(channel)) (const)
|
inline |
returns the iterator for an images ROI
|
inline |
returns the iterator for an images ROI (const)
|
inline |
deeply converts the channel data (no roi support here)
|
inline |
deeply copies the channel data (no roi support here)
|
inline |
returns the image end-iterator (equal to getData(channel)+getDim())
|
inline |
returns the image end-iterator (const)
|
inline |
returns the end-iterator for an images ROI
the returned iterator must not be incremented or decremented!
|
inline |
returns the end-iterator for an images ROI (const)
|
inline |
returns the wrapped images dim = width*height
|
inline |
returns the wrapped images height
|
inline |
returns the channel ROI
|
inline |
returns the channel ROI height
|
inline |
returns the channel ROI offset
|
inline |
returns the channel ROI size
|
inline |
returns the channel ROI width
|
inline |
returns the channel ROI X-Offset
|
inline |
returns the channel ROI Y-Offset
|
inline |
retusn the wrapped images size
|
inline |
returns the wrapped images width
|
inline |
|
inline |
main working function: returns a reference to the pixel at position (x,y)
The data address is calculated by x+ImageWidth*y. Note: no checks are performed to ensure, that the position is valid!
x | x-Position |
y | y-Position |
|
inline |
convenience function for point-based index access
calls operator()(p.x,p.y)
|
inline |
convenience function for point-based index access (const)
calls operator()(p.x,p.y) const
|
inline |
main working function: returns const a reference to the pixel at position (x,y)
The data address is calculated by x+ImageWidth*y. Note: no checks are performed to ensure, that the position is valid!
x | x-Position |
y | y-Position |
|
inline |
index operator with linear interpolation
The given source type must provide an index operator (so does e.g. icl::Point, icl::Point32f, icl::FixedMatrix and icl::FixedVector). There is no internal check so take care yourself that the given position is within the image rectangle
|
inline |
assignmet operator
|
inline |
assign operator (also for const channels)
assign operator is const, as we use to const-ness to deny changes on the underlying image, but not on the Channel struct itself. Hence all class data is mutable
|
inline |
working function for linear pixel array access ( not const version)
idx | pixel array index |
|
inline |
working function for linear pixel array access (const version)
idx | pixel array index |
|
inline |
Sets a new ROI to this image channel (this does not affect the underlying images ROI)
newROI | new channel roi |
|
friend |
mades Img<T> a friend to allow it construction of ImgChannels
|
mutableprivate |
|
mutableprivate |
|
mutableprivate |