Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Attributes | Private Member Functions | Friends
icl::core::Img< Type > Class Template Reference

The Img class implements the ImgBase Image interface with type specific functionalities \. More...

#include <Img.h>

Inheritance diagram for icl::core::Img< Type >:
icl::core::ImgBase

List of all members.

Public Member Functions

 Img (const ImgParams &params=ImgParams::null)
 creates a new image specified by the given param struct
 Img (const utils::Size &size, int channels)
 Creates an image with specified number of channels and size.
 Img (const utils::Size &s, format fmt)
 Creates an image with specified size, number of channels and format.
 Img (const utils::Size &s, int channels, format fmt)
 Crates an image with given size, channel count and format.
 Img (const utils::Size &size, format format, const std::vector< Type * > &vptData, bool passOwnerShip=false)
 Creates an image with specified size and format, using shared data pointers as channel data.
 Img (const utils::Size &size, int channels, const std::vector< Type * > &vptData, bool passOwnerShip=false)
 Creates an image with specified size and channel count, using shared data pointers as channel data.
 Img (const utils::Size &size, int channels, format fmt, const std::vector< Type * > &vptData, bool passOwnerShip=false)
 Crates an image with given size, channel count and format.
 Img (const Img< Type > &tSrc)
 Copy constructor WARNING: Violates const concept.
 Img (const math::DynMatrix< Type > &c1, const math::DynMatrix< Type > &c2=math::DynMatrix< Type >(), const math::DynMatrix< Type > &c3=math::DynMatrix< Type >(), const math::DynMatrix< Type > &c4=math::DynMatrix< Type >(), const math::DynMatrix< Type > &c5=math::DynMatrix< Type >()) throw (math::InvalidMatrixDimensionException)
 This constructor provides tight integration with DynMatrix template class.
 ~Img ()
 Destructor.
bool isNull () const
 null check : null images have 0-Channels and null-size

Static Public Attributes

static const Img< Type > null
 null sized and null channel image

Private Member Functions

Img< Type > & shallowCopy (const Img< Type > &tSource)
 Private assign operator (internally used)
void append (const Img< Type > *src, int iChannel=-1)
 private append function for a specified image channel
void append (const Img< Type > *src, const std::vector< int > &vChannels)
 private append function for a specified image channel

Friends

template<class ImgType >
const ImgType * combineImages (const std::vector< const ImgType * > &vec, ImgBase **ppoDst)

data

std::vector< utils::SmartArray
< Type > > 
m_vecChannels
 internally used storage for the image channels

auxiliary functions

utils::SmartArray< Type > createChannel (Type *ptDataToCopy=0) const
 Internally creates a new deep copy of a specified Type*.
int getStartIndex (int iIndex) const
 returns the start index for a channel loop
int getEndIndex (int iIndex) const
 returns the end index for a channel loop

basic image manipulation

void normalize (int iChannel, const utils::Range< Type > &srcRange, const utils::Range< Type > &dstRange)
 Scales pixel values from given min/max values to new min/max values (for internal use)
void mirror (axis eAxis, int iChannel, const utils::Point &oOffset, const utils::Size &oSize)
 in-place mirror operation on the given image rect (for internal use)

operators

 operator Img< Type > & ()
 implicit cast to it's own reference (?)
 operator const Img< Type > & () const
 implicit cast to it's own reference (?) (const)
Img< Type > & operator= (const Img< Type > &tSource)
 Assign operator (flat copy of channels) WARNING: Violates const concept.
Type & operator() (int iX, int iY, int iChannel)
 pixel access operator
const Type & operator() (int iX, int iY, int iChannel) const
 as above, but const
PixelRef< Type > operator() (int x, int y)
 extracts a pixels channel values at once
const PixelRef< Type > operator() (int x, int y) const
 as above, but const
Channel< Type > operator[] (int channel)
 extracts an image channel
const Channel< Type > operator[] (int channel) const
 extracts an image channel
float subPixelNN (float fX, float fY, int iChannel) const
 sub-pixel access using nearest neighbor interpolation
float subPixelLIN (float fX, float fY, int iChannel) const
 sub-pixel access using linear interpolation
float subPixelRA (float fX, float fY, float w, float h, int iChannel) const
 sub-pixel access using region average interpolation
float subPixelRA (const unsigned int xB, const unsigned int xE, const unsigned int yB, const unsigned int yE, const float xBMul, const float xEMul, const float BMul, const float yEMul, const Type *d, const unsigned int w) const
Type operator() (float fX, float fY, int iChannel, scalemode eMode) const
 sub-pixel access operator, uses given interpolation method

extractChannel functions

math::DynMatrix< Type > extractDynMatrix (int channel) throw (math::InvalidMatrixDimensionException)
 extracts given channel as DynMatrix<Type>
const math::DynMatrix< Type > extractDynMatrix (int channel) const throw (math::InvalidMatrixDimensionException)
 extracts given channel as DynMatrix<Type> const
void extractChannels (Channel< Type > *dst)
 extracts all image channels at once into given channel pointer
void extractChannels (Channel< Type > *dst) const
 this function is forbidden, it produces an error message
void extractChannels (const Channel< Type > *dst) const
 extracts all image channels at once into given channel pointer (const)
void extractPointers (Type **dst)
 extracts all data pointers into given destination pointer
void extractPointers (Type **dst) const
 this function is forbidden, it produces an error message
void extractPointers (const Type **dst) const
 extracts all data pointers into given destination pointer (const)

shallow/deepCopy functions

virtual Img< Type > * shallowCopy (const utils::Rect &roi, const std::vector< int > &channelIndices, format fmt, utils::Time time=utils::Time::null, ImgBase **ppoDst=NULL)
const Img< Type > * shallowCopy (const utils::Rect &roi, const std::vector< int > &channelIndices, format fmt, utils::Time time=utils::Time::null) const
Img< Type > * reinterpretChannels (format newFmt, Img< Type > *poDst=NULL)
 Create a shallow copy of this image with a new format.
const Img< Type > * reinterpretChannels (format newFmt)
 Create a shallow copy of this image with a new format (const version)
Img< Type > * shallowCopy (const utils::Rect &roi, Img< Type > *poDst=NULL)
 Create a shallow copy of the image.
const Img< Type > * shallowCopy (const utils::Rect &roi) const
 Create a shallow copy of a const source image.
Img< Type > * selectChannels (const std::vector< int > &channelIndices, Img< Type > *poDst=0)
 Create a shallow copy of selected channels of an image.
Img< Type > * selectChannel (int channelIndex, Img< Type > *poDst=0)
 Create a shallow copy of a single image channel of an image.
const Img< Type > * selectChannels (const std::vector< int > &channelIndices) const
 Create a shallow copy of selected channels of a const image.
const Img< Type > * selectChannel (int channelIndex) const
 Create a shallow copy of a single image channel of a const image.
virtual Img< Type > * deepCopy (ImgBase **ppoDst=0) const
 Perform a deep copy of an image.
Img< Type > * deepCopy (Img< Type > *poDst) const
 Perform a deep copy of an image.
virtual Img< Type > * deepCopyROI (ImgBase **ppoDst=0) const
 Perform a deep copy of an images ROI.
Img< Type > * deepCopyROI (Img< Type > *poDst) const
 Perform a deep copy of an images ROI.
virtual Img< Type > * scaledCopy (const utils::Size &newSize, scalemode eScaleMode=interpolateNN) const
 create a scaled copy of this image
virtual Img< Type > * scaledCopy (ImgBase **ppoDst=0, scalemode eScaleMode=interpolateNN) const
 create a scaled copy of this image
Img< Type > * scaledCopy (Img< Type > *poDst, scalemode eScaleMode=interpolateNN) const
 create a scaled copy of this image
virtual Img< Type > * scaledCopyROI (const utils::Size &newSize, scalemode eScaleMode=interpolateNN) const
 create a scaled copy of an images ROI with given size
virtual Img< Type > * scaledCopyROI (ImgBase **ppoDst=0, scalemode eScaleMode=interpolateNN) const
 create a scaled copy of an images ROI with given destination image
Img< Type > * scaledCopyROI (Img< Type > *poDst, scalemode eScaleMode=interpolateNN) const
 create a scaled copy of this images ROI

organization and channel management

virtual void detach (int iIndex=-1)
 Makes the image channels inside the Img independent from other Img.
Img< Type > detached () const
 Utility method, that returns a detached version of this image.
virtual void removeChannel (int iChannel)
 Removes a specified channel.
void append (Img< Type > *src, int iChannel=-1)
 Append channels of external Img to the existing Img.
void append (Img< Type > *src, const std::vector< int > &vChannels)
 Append a set of selected channels from source image.
Img< Type > extractChannelImg (int index)
 Returns a new image with a shallow copied single channel of this image.
const Img< Type > extractChannelImg (int index) const
 Returns a new image with a shallow copied single channel of this image.
Img< Type > extractChannelImg (const std::vector< int > &indices)
 Returns a new image with shallow copied single channels of this image.
const Img< Type > extractChannelImg (const std::vector< int > &indices) const
 Returns a new image with shallow copied single channels of this image.
virtual void swapChannels (int iIndexA, int iIndexB)
 Swap channel A and B.
void replaceChannel (int iThisIndex, Img< Type > *poOtherImg, int iOtherIndex)
 Replace the channel A of this image with the channel B another image.
virtual void setChannels (int iNewNumChannels)
 sets the channel count to a new value
virtual void setSize (const utils::Size &s)
 resizes the image to new values

getter functions

Type getMax (int iChannel, utils::Point *coords=0) const
 Returns max pixel value of channel iChannel within ROI.
Type getMin (int iChannel, utils::Point *coords=0) const
 Returns min pixel value of channel iChannel within ROI.
Type getMin () const
 return maximal pixel value over all channels (restricted to ROI)
Type getMax () const
 return minimal pixel value over all channels (restricted to ROI)
const utils::Range< Type > getMinMax (int iChannel, utils::Point *minCoords=0, utils::Point *maxCoords=0) const
 Returns min and max pixel values of channel iChannel within ROI.
const utils::Range< Type > getMinMax () const
 return minimal and maximal pixel values over all channels (restricted to ROI)
virtual int getLineStep () const
 Returns the width of an image line in bytes.
Type * getData (int iChannel)
 returns a Type save data data pointer to the channel data origin
const Type * getData (int iChannel) const
 returns a Type save data data pointer to the channel data origin (const)
Type * getROIData (int iChannel)
 returns a Type save data pointer to the first pixel within the images roi
const Type * getROIData (int iChannel) const
 returns a Type save data pointer to the first pixel within the images roi (const)
Type * getROIData (int iChannel, const utils::Point &p)
 returns the data pointer to a pixel with defined offset
const Type * getROIData (int iChannel, const utils::Point &p) const
 returns the data pointer to a pixel with defined offset (const)
virtual void * getDataPtr (int iChannel)
 returns the raw- data pointer of an image channel
virtual const void * getDataPtr (int iChannel) const
 returns the raw- data pointer of an image channel (const)

basic in-place image manipulations

template<typename UnaryFunction >
Img< Type > & forEach_C (UnaryFunction f, int channel)
 STL based "for_each" implementations applying an Unary function on each ROI-pixel of given channel.
template<typename UnaryFunction >
Img< Type > & forEach (UnaryFunction f)
 STL based "for_each" implementations applying an Unary function on each ROI-pixel.
template<typename UnaryFunction , class dstType >
Img< dstType > & transform_C (UnaryFunction f, int srcChannel, int dstChannel, Img< dstType > &dst) const
 STL based "transform" implementation applying an Unary function on ROI-pixles with given destination image.
template<typename UnaryFunction , class dstType >
Img< dstType > & transform (UnaryFunction f, Img< dstType > &dst) const
 STL based "transform" implementation applying an Unary function on ROI-pixles with given destination image.
template<typename BinaryFunction , class dstType , class otherSrcType >
Img< dstType > & combine_C (BinaryFunction f, int thisChannel, int otherSrcChannel, int dstChannel, const Img< otherSrcType > &otherSrc, Img< dstType > &dst) const
 STL-based "transform function combining two images pixel-wise into a given destination image (with ROI support)".
template<typename BinaryFunction , class dstType , class otherSrcType >
Img< dstType > & combine (BinaryFunction f, const Img< otherSrcType > &otherSrc, Img< dstType > &dst) const
 STL-based "transform function combining two images pixel-wise into a given destination image (with ROI support)".
template<typename Tdst , int Nthis, int Ndst, typename ReduceFunc >
void reduce_channels (Img< Tdst > &dst, ReduceFunc reduce) const
 Utility function for combining image channels into another image.
Img< Type > * lut (const Type *lut, Img< Type > *dst=0, int bits=8) const
 applys a lookup function using the given lookup table
virtual void scale (const utils::Size &s, scalemode eScaleMode=interpolateNN)
 perform an in-place resize of the image (keeping the data)
virtual void mirror (axis eAxis, bool bOnlyROI=false)
 perform an in-place mirror operation on the image
void clear (int iChannel=-1, Type tValue=0, bool bROIOnly=true)
 Sets the ROI pixels of one or all channels to a specified value.
template<class T >
void fill (const T &value)
 fills the whole image with given source type value
template<class T >
void fillChannel (int channel, const T &value)
 fills the given channel with given source type value
template<class T >
void fillROI (const T &value)
 fills the whole image with given source type value
template<class T >
void fillChannelROI (int channel, const T &value)
 fills the given channel's with given source type value
void normalizeAllChannels (const utils::Range< Type > &dstRange)
 Normalize the channel min/ max range to the new min, max range.
void normalizeChannel (int iChannel, const utils::Range< Type > &srcRange, const utils::Range< Type > &dstRange)
 Normalize the channel from a given min/max range to the new range.
void normalizeChannel (int iChannel, const utils::Range< Type > &dstRange)
 Normalize the channel from a given min/max range to the new range.
void normalizeImg (const utils::Range< Type > &srcRange, const utils::Range< Type > &dstRange)
 Normalize the image from a given min/max range to the new range.
void normalizeImg (const utils::Range< Type > &dstRange)
 Normalize the image from a min/max range to the new range.
template<typename Tsrc , typename Tdst , int Nsrc, int Ndst, typename ReduceFunc >
static void reduce_arrays (const Tsrc *src[Nsrc], Tdst *dst[Ndst], unsigned int dim, ReduceFunc reduce)
 private helper function called from reduce_channels template

pixel access using roi iterator

typedef Type * iterator
 iterator type (just a data pointer)
typedef const Type * const_iterator
 const iterator type (just a const pointer)
typedef ImgIterator< Type > roi_iterator
 type definition for ROI iterator
typedef const ImgIterator< Type > const_roi_iterator
 type definition for a const ROI iterator
iterator begin (int channel)
 returns the image iterator (equal to getData(channel))
const_iterator begin (int channel) const
 returns the image iterator (equal to getData(channel)) (const)
iterator end (int channel)
 returns the image end-iterator (equal to getData(channel)+getDim())
const_iterator end (int channel) const
 returns the image end-iterator (const)
roi_iterator beginROI (int channel)
 returns the iterator for an images ROI
const_roi_iterator beginROI (int channel) const
 returns the iterator for an images ROI (const)
roi_iterator endROI (int channel)
 returns the end-iterator for an images ROI
const_roi_iterator endROI (int channel) const
 returns the end-iterator for an images ROI (const)
utils::Point getLocation (const Type *p, int channel, bool relToROI=false) const
 returns the x,y-coordinates of a pointer whithin a given channel
void printAsMatrix (const std::string &format="5.3", bool visROI=true) const
 shows the image value by value at std::out
virtual bool isIndependent () const
 shows wheter all image channels are currently not share with another image

border functions

virtual void fillBorder (bool setFullROI=true)
 extrudes ROI borders through non-ROI borders
virtual void fillBorder (icl64f val, bool setFullROI=true)
 fills all non-ROI pixels with a given value
virtual void fillBorder (const std::vector< icl64f > &vals, bool setFullROI=true)
 fills all non-ROI pixels with a given value
virtual void fillBorder (const ImgBase *src, bool setFullROI=true)
 copies images non-border pixels from source image.

Detailed Description

template<class Type>
class icl::core::Img< Type >

The Img class implements the ImgBase Image interface with type specific functionalities \.


Member Typedef Documentation

template<class Type>
typedef const Type* icl::core::Img< Type >::const_iterator

const iterator type (just a const pointer)

template<class Type>
typedef const ImgIterator<Type> icl::core::Img< Type >::const_roi_iterator

type definition for a const ROI iterator

template<class Type>
typedef Type* icl::core::Img< Type >::iterator

iterator type (just a data pointer)

template<class Type>
typedef ImgIterator<Type> icl::core::Img< Type >::roi_iterator

type definition for ROI iterator


Constructor & Destructor Documentation

template<class Type>
icl::core::Img< Type >::Img ( const ImgParams params = ImgParams::null)

creates a new image specified by the given param struct

Parameters:
paramsinitializing image parameters, if null, then a null image is created
template<class Type>
icl::core::Img< Type >::Img ( const utils::Size size,
int  channels 
)

Creates an image with specified number of channels and size.

the format of the image will be set to "formatMatrix"

Parameters:
sizeimage size
channelsNumber of Channels
template<class Type>
icl::core::Img< Type >::Img ( const utils::Size s,
format  fmt 
)

Creates an image with specified size, number of channels and format.

Parameters:
ssize of the new image
fmt(color)-format of the image
template<class Type>
icl::core::Img< Type >::Img ( const utils::Size s,
int  channels,
format  fmt 
)

Crates an image with given size, channel count and format.

Note: channel count and format depend on each other, so if the given channel count and the given format are not compatible, an exception is thrown

Parameters:
ssize of the image
channelschannel count of the image (must be compatible to fmt)
fmtformat of the image (must be compatible to channels)
template<class Type>
icl::core::Img< Type >::Img ( const utils::Size size,
format  format,
const std::vector< Type * > &  vptData,
bool  passOwnerShip = false 
)

Creates an image with specified size and format, using shared data pointers as channel data.

The channel count is set to the channel count that is associated with given the format

Parameters:
sizenew image size
format(color)-format of the image
vptDataholds channel data pointers. It must contain enough Type-pointers for the given format. The data must not be deleted during the "lifetime" of the Img unless data ownership is passed to the Img instance by setting passOwnerShip to true. Call detach after the constructor call, to induce the Img to allocate own memory for the image data if ownership cannot be passed.
passOwnerShipflag to specify the passed ownership
template<class Type>
icl::core::Img< Type >::Img ( const utils::Size size,
int  channels,
const std::vector< Type * > &  vptData,
bool  passOwnerShip = false 
)

Creates an image with specified size and channel count, using shared data pointers as channel data.

the format is set to formatMatrix

Parameters:
sizenew image size
channelschannel count of the image (format is set to "formatMatrix")
vptDataholds channel data pointers. It must contain at least 'channels' data pointers. The data must not be deleted during the "lifetime" of the Img unless data ownership is passed to the Img instance by setting passOwnerShip to true. Call detach after the constructor call, to induce the Img to allocate own memory for the image data if ownership cannot be passed.
passOwnerShipflag to specify the passed ownership
template<class Type>
icl::core::Img< Type >::Img ( const utils::Size size,
int  channels,
format  fmt,
const std::vector< Type * > &  vptData,
bool  passOwnerShip = false 
)

Crates an image with given size, channel count and format.

Note: channel count and format depend on each other, so if the given channel count and the given format are not compatible, an exception is thrown

Parameters:
sizesize of the image
channelschannel count of the image (must be compatible to fmt)
fmtformat of the image (must be compatible to channels)
vptDataarray of data pointers, which are used as shared pointers. Ensure, that these pointers are persistent during the lifetime of the image unless ownership is passed by setting passOwnerShip to true, or call detach, to make the image allocate it own memory for the data
passOwnerShipflag to specify the passed ownership
template<class Type>
icl::core::Img< Type >::Img ( const Img< Type > &  tSrc)

Copy constructor WARNING: Violates const concept.

Creates a flat copy of the source image. The new image will contain a flat copy of all channels of the source image. This constructor is only applicable to non-const Img<Type> references. Note: this implicit shallow copy can be exploited to violate ICL's const concept:

          void func(const Img8u &a){
            Img8u b = a;
            // b is now unconst and therewith the data of
            // a can b chaned
          }
Parameters:
tSrcnon-const reference of source instance
template<class Type>
icl::core::Img< Type >::Img ( const math::DynMatrix< Type > &  c1,
const math::DynMatrix< Type > &  c2 = math::DynMatrix< Type >(),
const math::DynMatrix< Type > &  c3 = math::DynMatrix< Type >(),
const math::DynMatrix< Type > &  c4 = math::DynMatrix< Type >(),
const math::DynMatrix< Type > &  c5 = math::DynMatrix< Type >() 
) throw (math::InvalidMatrixDimensionException)

This constructor provides tight integration with DynMatrix template class.

creates a shallow Img<Type>-wrapper around a set of DynMatrix instances. Note, of course this consturctor might be used to break DynMatrix's const concept, so please be aware of this!. The resulting image counts that many channels as given count (up to 5) of non-null DynMatrix<T> instances. All null instances must have the same size, otherwise, an exception of type InvalidMatrixDimensionException is thrown.

Parameters:
c1first image channel (mandatory) (if this is null, the image becomes null)
c2optional 2nd image channel. Must have the same size as c1.
c3optional 3rd image channel. Must have the same size as c1 and c2.
c4optional 4th image channel. Must have the same size as c1 - c3.
c5optional 5th image channel. Must have the same size as c1 - c4.
template<class Type>
icl::core::Img< Type >::~Img ( )

Destructor.


Member Function Documentation

template<class Type>
void icl::core::Img< Type >::append ( const Img< Type > *  src,
int  iChannel = -1 
) [private]

private append function for a specified image channel

This must be kept private! Because it could otherwise be exploited to violate the Img's const concept

template<class Type>
void icl::core::Img< Type >::append ( const Img< Type > *  src,
const std::vector< int > &  vChannels 
) [private]

private append function for a specified image channel

This must be kept private! Because it could otherwise be exploited to violate the Img's const concept

template<class Type>
void icl::core::Img< Type >::append ( Img< Type > *  src,
int  iChannel = -1 
) [inline]

Append channels of external Img to the existing Img.

Both objects will share their data (cheap copy). If a non-matrix format image gets new channels using it's append method, the new channel count will not match to the channel count, that is associated with the current format. In this case, a waring is written to std::out, and the format will be set to formatMatrix implicitly.

Parameters:
srcsource image
iChannelchannel to append (or all, if < 0)
template<class Type>
void icl::core::Img< Type >::append ( Img< Type > *  src,
const std::vector< int > &  vChannels 
) [inline]

Append a set of selected channels from source image.

Parameters:
srcsource image
vChannelsvector of channels indices
template<class Type>
iterator icl::core::Img< Type >::begin ( int  channel) [inline]

returns the image iterator (equal to getData(channel))

template<class Type>
const_iterator icl::core::Img< Type >::begin ( int  channel) const [inline]

returns the image iterator (equal to getData(channel)) (const)

template<class Type>
roi_iterator icl::core::Img< Type >::beginROI ( int  channel) [inline]

returns the iterator for an images ROI

template<class Type>
const_roi_iterator icl::core::Img< Type >::beginROI ( int  channel) const [inline]

returns the iterator for an images ROI (const)

template<class Type>
void icl::core::Img< Type >::clear ( int  iChannel = -1,
Type  tValue = 0,
bool  bROIOnly = true 
)

Sets the ROI pixels of one or all channels to a specified value.

Parameters:
iChannelChannel to fill with zero (default: -1 = all channels)
tValuedestination value (default: 0)
bROIOnlyif set false, the whole image is set to tValue
template<class Type>
template<typename BinaryFunction , class dstType , class otherSrcType >
Img<dstType>& icl::core::Img< Type >::combine ( BinaryFunction  f,
const Img< otherSrcType > &  otherSrc,
Img< dstType > &  dst 
) const [inline]

STL-based "transform function combining two images pixel-wise into a given destination image (with ROI support)".

This function calls D = F(A,B), with D: destination ROI pixel, F: given binary functor/function, A: pixel of this image and B: pixel of other given src image. Internally this function uses std::transform Beispiel:

          #include <ICLQt/Quick.h>
          
          int main(){
            ImgQ a = scale(create("parrot"),640,480);
            ImgQ b = scale(create("women"),640,480);
          
            Img8u dst(a.getParams());
          
            a.setROI(Rect(10,10,300,100));
            b.setROI(Rect(10,10,300,100));
            dst.setROI(Rect(10,10,300,100));
          
            a.combine(std::less<icl32f>(),b,dst);
          
            dst.setFullROI();
            show(norm(cvt(dst)));
            return 0;
          }
Parameters:
fbinary function or functor implementing "dstType operator() const(Type &a, otherSrcType &b) const"
otherSrc2nd source image
dstdestination image
template<class Type>
template<typename BinaryFunction , class dstType , class otherSrcType >
Img<dstType>& icl::core::Img< Type >::combine_C ( BinaryFunction  f,
int  thisChannel,
int  otherSrcChannel,
int  dstChannel,
const Img< otherSrcType > &  otherSrc,
Img< dstType > &  dst 
) const [inline]

STL-based "transform function combining two images pixel-wise into a given destination image (with ROI support)".

Internally this function uses std::transform. Example:

          #include <ICLQt/Quick.h>
          
          inline bool gt_func(const float &a,const float &b){
            return a > b;
          }
          struct EqFunctor{
            bool operator()(const float &a, const float &b){
              return a == b;
            }
          };
           
          int main(){
            ImgQ a = scale(create("parrot"),640,480);
            ImgQ b = scale(create("women"),640,480);
          
            Img8u dst(a.getParams());
          
            a.setROI(Rect(10,10,500,400)); 
            b.setROI(Rect(10,10,500,400));
            dst.setROI(Rect(10,10,500,400));
          
            a.combine_C(std::less<icl32f>(),0,0,0,b,dst);
            a.combine_C(gt_func,1,1,1,b,dst);  
            a.combine_C(EqFunctor(),2,2,2,b,dst);
          
            dst.setFullROI();
            show(norm(cvt(dst)));
            return 0;
          }
Parameters:
fbinary function of functor implementing "dstType operator() const(Type &a, otherSrcType &b) const"
thisChannelvalid channel of this image
otherSrcChannelvalid channel index for give 2nd source image
dstChannelvalid channel index of dst image
otherSrc2nd source image (ROI-size must be equal to this' ROI size)
dstdestination image (ROI-size must be equal to this' ROI size)
template<class Type>
utils::SmartArray<Type> icl::core::Img< Type >::createChannel ( Type *  ptDataToCopy = 0) const [protected]

Internally creates a new deep copy of a specified Type*.

if the give Type* ptDataToCopy is not NULL, the data addressed from it, is copied deeply into the new created data pointer

template<class Type>
virtual Img<Type>* icl::core::Img< Type >::deepCopy ( ImgBase **  ppoDst = 0) const [virtual]

Perform a deep copy of an image.

Create a deep copy of a given image.

An optional destination image can be given via ppoDst. If ppoDst is NULL, a new image created and returned. If ppoDst points to NULL, the new image is created at *ppoDst. Otherwise, the given destination image (*ppoDst) is adapted to this images params including its depth. If the destination images depth differs from this images depth, (*ppoDst) is first released and then created new on the heap

Parameters:
ppoDstoptionally given destination image
Returns:
deep copied image

Implements icl::core::ImgBase.

template<class Type>
Img<Type>* icl::core::Img< Type >::deepCopy ( Img< Type > *  poDst) const

Perform a deep copy of an image.

This is an overloaded version of the above function. It behaves essentially like the above function, except getting an Img<Type>* as destination image argument, what allows to apply the operation without a depth switch.

Parameters:
poDstdestination image, if NULL, a new Img<Type> is created
Returns:
deep copy of this image
template<class Type>
virtual Img<Type>* icl::core::Img< Type >::deepCopyROI ( ImgBase **  ppoDst = 0) const [virtual]

Perform a deep copy of an images ROI.

Create a deep copy of an images ROI.

This function creates copies this images ROI into an optional given destination image. If ppoDst is NULL, a new image is created. If it points to NULL, a new image is created at *ppoDst. Otherwise the destination image is adapted in size, channels and depth to this image (the size is set to this images ROI size). The copy operation is performed line-wise using memcpy, what makes deepCopyROI very fast.

Parameters:
ppoDstoptionally given destination image
Returns:
image containing a deep copy of the source images ROI

Implements icl::core::ImgBase.

template<class Type>
Img<Type>* icl::core::Img< Type >::deepCopyROI ( Img< Type > *  poDst) const

Perform a deep copy of an images ROI.

This is an overloaded version of the above function. It behaves essentially like the above function, except getting an Img<Type>* as destination image argument, what allows to apply the operation without a depth switch.

Parameters:
poDstdestination image, if NULL, a new Img<Type> is created. poDst must have either ROI size identical to this images ROI size or zero-dim size (in this case poDst's size is set to this images ROI size)
Returns:
deep copy of this images ROI
template<class Type>
virtual void icl::core::Img< Type >::detach ( int  iIndex = -1) [virtual]

Makes the image channels inside the Img independent from other Img.

Makes the image channels independent from other images.

Parameters:
iIndexindex of the channel, that should be detached. (If iIndex is an legal channel index only the corresponding channel will be detached. If iIndex is -1 (default) all channels are detached

Implements icl::core::ImgBase.

template<class Type>
Img<Type> icl::core::Img< Type >::detached ( ) const [inline]

Utility method, that returns a detached version of this image.

This method can be seen as a deep-copy method. With this method, you can copy an image deeply be calling

          Img8u sourceImage(Size::VGA,formatRGB)
          Img8u deeplyCopiedInstance = sourceImage.detached();
template<class Type>
iterator icl::core::Img< Type >::end ( int  channel) [inline]

returns the image end-iterator (equal to getData(channel)+getDim())

template<class Type>
const_iterator icl::core::Img< Type >::end ( int  channel) const [inline]

returns the image end-iterator (const)

template<class Type>
roi_iterator icl::core::Img< Type >::endROI ( int  channel) [inline]

returns the end-iterator for an images ROI

the returned iterator must not be incremented or decremented!

template<class Type>
const_roi_iterator icl::core::Img< Type >::endROI ( int  channel) const [inline]

returns the end-iterator for an images ROI (const)

template<class Type>
Img<Type> icl::core::Img< Type >::extractChannelImg ( int  index)

Returns a new image with a shallow copied single channel of this image.

param index channel index to extract (must be valid, else resulting image has no channels and error message)

template<class Type>
const Img<Type> icl::core::Img< Type >::extractChannelImg ( int  index) const

Returns a new image with a shallow copied single channel of this image.

param index channel index to extract (must be valid, else resulting image has no channels and error message)

template<class Type>
Img<Type> icl::core::Img< Type >::extractChannelImg ( const std::vector< int > &  indices)

Returns a new image with shallow copied single channels of this image.

param indices channel indices to extract (each must be valid, else error and channel index that does not match is omitted)

template<class Type>
const Img<Type> icl::core::Img< Type >::extractChannelImg ( const std::vector< int > &  indices) const

Returns a new image with shallow copied single channels of this image.

param indices channel indices to extract (each must be valid, else error and channel index that does not match is omitted)

template<class Type>
void icl::core::Img< Type >::extractChannels ( Channel< Type > *  dst) [inline]

extracts all image channels at once into given channel pointer

template<class Type>
void icl::core::Img< Type >::extractChannels ( Channel< Type > *  dst) const [inline]

this function is forbidden, it produces an error message

This would allow the programme to violate the Imgs const concept

template<class Type>
void icl::core::Img< Type >::extractChannels ( const Channel< Type > *  dst) const [inline]

extracts all image channels at once into given channel pointer (const)

Plese note that the given dst-pointer must also be const

template<class Type>
math::DynMatrix<Type> icl::core::Img< Type >::extractDynMatrix ( int  channel) throw (math::InvalidMatrixDimensionException) [inline]

extracts given channel as DynMatrix<Type>

template<class Type>
const math::DynMatrix<Type> icl::core::Img< Type >::extractDynMatrix ( int  channel) const throw (math::InvalidMatrixDimensionException) [inline]

extracts given channel as DynMatrix<Type> const

template<class Type>
void icl::core::Img< Type >::extractPointers ( Type **  dst) [inline]

extracts all data pointers into given destination pointer

template<class Type>
void icl::core::Img< Type >::extractPointers ( Type **  dst) const [inline]

this function is forbidden, it produces an error message

This would allow the programme to violate the Imgs const concept

template<class Type>
void icl::core::Img< Type >::extractPointers ( const Type **  dst) const [inline]

extracts all data pointers into given destination pointer (const)

template<class Type>
template<class T >
void icl::core::Img< Type >::fill ( const T &  value) [inline]

fills the whole image with given source type value

In contrast to icl::Img::clear, which is highly optimized, this methods use std::fill. By this means, the given source value is really assigned to each value. This can e.g. be used to fill an image with random values

          #include <ICLCore/Img.h>
          #include <ICLCore/Random.h>
          #include <ICLQt/Quick.h>
          void foo(){
             Img8u image(Size::QQVGA,3);
             image.fill(URandI(255));
             show(image);
          }
img-fill.jpg
result if Img::fill example
template<class Type>
virtual void icl::core::Img< Type >::fillBorder ( bool  setFullROI = true) [virtual]

extrudes ROI borders through non-ROI borders

This function can be used fill all image border pixles (pixels outside the current ROI with the value of the closest ROI-pixel

Implements icl::core::ImgBase.

template<class Type>
virtual void icl::core::Img< Type >::fillBorder ( icl64f  val,
bool  setFullROI = true 
) [virtual]

fills all non-ROI pixels with a given value

Implements icl::core::ImgBase.

template<class Type>
virtual void icl::core::Img< Type >::fillBorder ( const std::vector< icl64f > &  vals,
bool  setFullROI = true 
) [virtual]

fills all non-ROI pixels with a given value

here, for each channel a given value is used, so vals.size() must be at least this->getChannels()

Implements icl::core::ImgBase.

template<class Type>
virtual void icl::core::Img< Type >::fillBorder ( const ImgBase src,
bool  setFullROI = true 
) [virtual]

copies images non-border pixels from source image.

The source image must provided pixel values for each non border pixel of this image. So the source images size must be at least (X+1)x(Y+1) where (X,Y) is the lower right non-border pixel of this image.

Implements icl::core::ImgBase.

template<class Type>
template<class T >
void icl::core::Img< Type >::fillChannel ( int  channel,
const T &  value 
) [inline]

fills the given channel with given source type value

template<class Type>
template<class T >
void icl::core::Img< Type >::fillChannelROI ( int  channel,
const T &  value 
) [inline]

fills the given channel's with given source type value

template<class Type>
template<class T >
void icl::core::Img< Type >::fillROI ( const T &  value) [inline]

fills the whole image with given source type value

template<class Type>
template<typename UnaryFunction >
Img<Type>& icl::core::Img< Type >::forEach ( UnaryFunction  f) [inline]

STL based "for_each" implementations applying an Unary function on each ROI-pixel.

Internally using std::for_each by calling Img<T>::forEach_C for all channels Example:

          #include <ICLQt/Quick.h>
  
          struct Thresh{
            inline void operator()(float &f){ f = f>128 ? 0 : 255; }
          };
          
          int main(){
            ImgQ a = scale(create("parrot"),0.2);
            a.forEach(Thresh());
            show(a);
            return 0;
          }
Parameters:
funary function or functor implementing "AnyType operator()(Type &val)"
template<class Type>
template<typename UnaryFunction >
Img<Type>& icl::core::Img< Type >::forEach_C ( UnaryFunction  f,
int  channel 
) [inline]

STL based "for_each" implementations applying an Unary function on each ROI-pixel of given channel.

Internally this function uses std::for_each Example:

          #include <ICLQt/Quick.h>
  
          struct Thresh{
            inline void operator()(float &f){ f = f>128 ? 0 : 255; }
          };
          
          inline void ttt(float &f){
            f = f>128 ? 0 : 255;
          }
          
          int main(){
            ImgQ a = create("parrot");
          
            a.forEach_C(ttt,1);
            a.forEach_C(Thresh(),0);
          
            show(scale(a,0.2));
            return 0;
          }       
Parameters:
funary function or functor implementing "AnyType operator()(Type &val)"
channelvalid channel index for this image
template<class Type>
Type* icl::core::Img< Type >::getData ( int  iChannel) [inline]

returns a Type save data data pointer to the channel data origin

If the channel index is not valid (<0 or >= getChannels) NULL is returned and an error is written to std::err

Parameters:
iChannelspecifies the channel
Returns:
data origin pointer to the specified channel
template<class Type>
const Type* icl::core::Img< Type >::getData ( int  iChannel) const [inline]

returns a Type save data data pointer to the channel data origin (const)

returns a Type save data data pointer to the channel data origin

If the channel index is not valid (<0 or >= getChannels) NULL is returned and an error is written to std::err

Parameters:
iChannelspecifies the channel
Returns:
data origin pointer to the specified channel
template<class Type>
virtual void* icl::core::Img< Type >::getDataPtr ( int  iChannel) [inline, virtual]

returns the raw- data pointer of an image channel

returns a pointer to first data element of a given channel

See also:
Img

Implements icl::core::ImgBase.

template<class Type>
virtual const void* icl::core::Img< Type >::getDataPtr ( int  iChannel) const [inline, virtual]

returns the raw- data pointer of an image channel (const)

returns a pointer to first data element of a given channel

See also:
Img

Implements icl::core::ImgBase.

template<class Type>
int icl::core::Img< Type >::getEndIndex ( int  iIndex) const [inline, protected]

returns the end index for a channel loop

this function behaves essentially like the above function

Parameters:
iIndexchannel index
Returns:
end index for for-loops
See also:
getStartIndex
template<class Type>
virtual int icl::core::Img< Type >::getLineStep ( ) const [inline, virtual]

Returns the width of an image line in bytes.

returns the length of an image line in bytes (width*sizeof(Type))

This information is compulsory for calling any IPP function.

Returns:
getWidth()*sizeof(Type) in the underlying Img template

Implements icl::core::ImgBase.

template<class Type>
utils::Point icl::core::Img< Type >::getLocation ( const Type *  p,
int  channel,
bool  relToROI = false 
) const

returns the x,y-coordinates of a pointer whithin a given channel

E.g channel c's pointer of image I points to adress p=1005, image width is 10 and data depth is 1 (icl-8u image). Then I.getLocation(1006,c) returns Point(1,0) and I.getLocation(1015,c) returns Point(0,1).
The following rule is always true: Point p = somewhat; image i = somewhat; p == i.getLocation(i.getData(0)+p.x+image.getWidth()*p.y,any-valid-channel); Optionally, returned point can be calculated w.r.t. the images roi offset.

template<class Type>
Type icl::core::Img< Type >::getMax ( int  iChannel,
utils::Point coords = 0 
) const

Returns max pixel value of channel iChannel within ROI.

Parameters:
iChannelIndex of channel
coords(optinal) if not null, the pixel position of the max is written into this argument

Reimplemented from icl::core::ImgBase.

template<class Type>
Type icl::core::Img< Type >::getMax ( ) const

return minimal pixel value over all channels (restricted to ROI)

Reimplemented from icl::core::ImgBase.

template<class Type>
Type icl::core::Img< Type >::getMin ( int  iChannel,
utils::Point coords = 0 
) const

Returns min pixel value of channel iChannel within ROI.

Parameters:
iChannelIndex of channel
coords(optinal) if not null, the pixel position of the min is written into this argument

Reimplemented from icl::core::ImgBase.

template<class Type>
Type icl::core::Img< Type >::getMin ( ) const

return maximal pixel value over all channels (restricted to ROI)

Reimplemented from icl::core::ImgBase.

template<class Type>
const utils::Range<Type> icl::core::Img< Type >::getMinMax ( int  iChannel,
utils::Point minCoords = 0,
utils::Point maxCoords = 0 
) const

Returns min and max pixel values of channel iChannel within ROI.

Parameters:
iChannelIndex of channel
minCoords(optinal) if not null, the pixel position of the min is written into this argument
maxCoords(optinal) if not null, the pixel position of the max is written into this argument

Reimplemented from icl::core::ImgBase.

template<class Type>
const utils::Range<Type> icl::core::Img< Type >::getMinMax ( ) const

return minimal and maximal pixel values over all channels (restricted to ROI)

Reimplemented from icl::core::ImgBase.

template<class Type>
Type* icl::core::Img< Type >::getROIData ( int  iChannel) [inline]

returns a Type save data pointer to the first pixel within the images roi

The following ASCII image shows an images ROI.

                         1st roi-pixel
                              |
                          ....|....................         ---
                          ....|..ooooooooo......... ---      |
                          ....|..ooooooooo.........  |       |
                          ....|..ooooooooo......... roi-h  image-h
          1st image pixel ....|..ooooooooo.........  |       |
               |          ....+->xoooooooo......... ---      |
               +--------->x........................         ---
                                 |-roi-w-|
                          |---------image-w-------|
          

Note: most ipp-function require the ROI-data pointer

Parameters:
iChannelspecifies the channel
Returns:
roi data pointer
template<class Type>
const Type* icl::core::Img< Type >::getROIData ( int  iChannel) const [inline]

returns a Type save data pointer to the first pixel within the images roi (const)

returns a Type save data pointer to the first pixel within the images roi

The following ASCII image shows an images ROI.

                         1st roi-pixel
                              |
                          ....|....................         ---
                          ....|..ooooooooo......... ---      |
                          ....|..ooooooooo.........  |       |
                          ....|..ooooooooo......... roi-h  image-h
          1st image pixel ....|..ooooooooo.........  |       |
               |          ....+->xoooooooo......... ---      |
               +--------->x........................         ---
                                 |-roi-w-|
                          |---------image-w-------|
          

Note: most ipp-function require the ROI-data pointer

Parameters:
iChannelspecifies the channel
Returns:
roi data pointer
template<class Type>
Type* icl::core::Img< Type >::getROIData ( int  iChannel,
const utils::Point p 
) [inline]

returns the data pointer to a pixel with defined offset

In some functions like filters, it might be necessary to change the images ROI parameters before applying the underlying image operation. Temporarily changing the images ROI parameters causes problems in multi-threaded environments. To avoid this, this function provides access to a data pointer to an arbitrary notional ROI-offset

Parameters:
iChannelselects the channel
pnotional ROI offset
Returns:
data pointer with notional ROI offset p
template<class Type>
const Type* icl::core::Img< Type >::getROIData ( int  iChannel,
const utils::Point p 
) const [inline]

returns the data pointer to a pixel with defined offset (const)

returns the data pointer to a pixel with defined offset

In some functions like filters, it might be necessary to change the images ROI parameters before applying the underlying image operation. Temporarily changing the images ROI parameters causes problems in multi-threaded environments. To avoid this, this function provides access to a data pointer to an arbitrary notional ROI-offset

Parameters:
iChannelselects the channel
pnotional ROI offset
Returns:
data pointer with notional ROI offset p
template<class Type>
int icl::core::Img< Type >::getStartIndex ( int  iIndex) const [inline, protected]

returns the start index for a channel loop

In some functions to cases must be regarded:

  • if given channel index is -1, then it has to be iterated over all image channels
  • else only the given image channel has to be touched

To avoid code doublication, one can use the following for-loop

          void foo(int iChannel){
             for(int i = iIndex < 0 ? 0 : iIndex, iEnd = iIndex < 0 ? m_iChannels : iIndex+1; i < iEnd; i++)   { 
do something
             }
          }
          

When using the get<Start|End>Index functions the loop becomes much more readable:

          void foo(int iChannel){
             for(int i=getStartIndex(iIndex), iEnd=getEndIndex(iIndex); i<iEnd ;i++){
do something
             }
          }
          
Parameters:
iIndexchannel index
Returns:
start index for for-loops
See also:
getEndIndex
template<class Type>
virtual bool icl::core::Img< Type >::isIndependent ( ) const [virtual]

shows wheter all image channels are currently not share with another image

\copydoc bool icl::core::ImgBase::isIndependent() const

Implements icl::core::ImgBase.

template<class Type>
bool icl::core::Img< Type >::isNull ( ) const [inline]

null check : null images have 0-Channels and null-size

template<class Type>
Img<Type>* icl::core::Img< Type >::lut ( const Type *  lut,
Img< Type > *  dst = 0,
int  bits = 8 
) const

applys a lookup function using the given lookup table

The lookup table has 2^bits entries. Source values are assumed to be in range [0,255]. If the given destination image is 0, a new image is created and returned IPP-accellerated for icl8u

template<class Type>
void icl::core::Img< Type >::mirror ( axis  eAxis,
int  iChannel,
const utils::Point oOffset,
const utils::Size oSize 
) [protected]

in-place mirror operation on the given image rect (for internal use)

Parameters:
eAxisaxis for the mirror operation
iChannelchannel index to work on
oOffsetimage rects offset to use
oSizeimage rects size to use
template<class Type>
virtual void icl::core::Img< Type >::mirror ( axis  eAxis,
bool  bOnlyROI = false 
) [virtual]

perform an in-place mirror operation on the image

performs an in-place mirror operation

This function is an in-place version of the flippedCopy function, that is also provided in this class. Its performance is comparable to the out-place function

Parameters:
eAxisaxis for the mirror operations
bOnlyROIif set, only the ROI of this image is mirrored, else the whole image is mirrored.

Implements icl::core::ImgBase.

template<class Type>
void icl::core::Img< Type >::normalize ( int  iChannel,
const utils::Range< Type > &  srcRange,
const utils::Range< Type > &  dstRange 
) [protected]

Scales pixel values from given min/max values to new min/max values (for internal use)

Values exceeding the given range are set to the new min/max values. For an automatic scaling use the results of min(),max() as as arguments. (Defining a range allows to compare different images.)

Parameters:
iChannelchannel index (if set to -1, then operation is
srcRangeassumption of the images range
dstRangeimage range after the operation

performed on all channels)

template<class Type>
void icl::core::Img< Type >::normalizeAllChannels ( const utils::Range< Type > &  dstRange)

Normalize the channel min/ max range to the new min, max range.

The min/ max range from the source channels are automatically detected, separately for each channel.

Parameters:
dstRangenew image range
template<class Type>
void icl::core::Img< Type >::normalizeChannel ( int  iChannel,
const utils::Range< Type > &  srcRange,
const utils::Range< Type > &  dstRange 
)

Normalize the channel from a given min/max range to the new range.

Parameters:
iChannelchannel index
srcRangenotional image range befor this function call
dstRangeimage range after this function call
template<class Type>
void icl::core::Img< Type >::normalizeChannel ( int  iChannel,
const utils::Range< Type > &  dstRange 
)

Normalize the channel from a given min/max range to the new range.

The min/ max range from the source channel is automatically detected, separately for this channel

Parameters:
iChannelchannel index
dstRangedestination image range
template<class Type>
void icl::core::Img< Type >::normalizeImg ( const utils::Range< Type > &  srcRange,
const utils::Range< Type > &  dstRange 
)

Normalize the image from a given min/max range to the new range.

Parameters:
srcRangenotional image range befor this function call
dstRangeimage range after this function call
template<class Type>
void icl::core::Img< Type >::normalizeImg ( const utils::Range< Type > &  dstRange)

Normalize the image from a min/max range to the new range.

The min/ max range from the image is automatically detected, combined over all image channels.

Parameters:
dstRangedestination image range
template<class Type>
icl::core::Img< Type >::operator const Img< Type > & ( ) const [inline]

implicit cast to it's own reference (?) (const)

template<class Type>
icl::core::Img< Type >::operator Img< Type > & ( ) [inline]

implicit cast to it's own reference (?)

template<class Type>
Type& icl::core::Img< Type >::operator() ( int  iX,
int  iY,
int  iChannel 
) [inline]

pixel access operator

This operator may be used, to access the pixel data of the image e.g. copy of image data:

          Img8u oA(Size(320,240),1),oB(Size(320,240),1);
          for(int x=0;x<320;x++){
          for(int y=0;y<240;y++){
          oB(x,y,0)=oA(x,y,0);
          }
          }
          

Efficiency

Although the ()-operator is compiled inline, and optimized, it is very slow, as it has to select a channel internally (array access) followed by the data access of the selected channel (return array[x+w*y]). A measurement with a "-O3" binary brought the result that pixel access is up to 10 times faster when working directly with a channel data pointer. Nevertheless, the ()-operator is provided in the Img-class, as it offers a very intuitive access to the pixel data. Note: The also provided ImgIterator provides an additional ROI handling mechanism and is more than 5 times faster.

See also:
ImgIterator
getIterator()
beginROI()
Parameters:
iXX-Position of the referenced pixel
iYY-Position of the referenced pixel
iChannelchannel index
template<class Type>
const Type& icl::core::Img< Type >::operator() ( int  iX,
int  iY,
int  iChannel 
) const [inline]

as above, but const

template<class Type>
PixelRef<Type> icl::core::Img< Type >::operator() ( int  x,
int  y 
) [inline]

extracts a pixels channel values at once

This enables the user to write imageA(x,y) = imageB(a,b);

template<class Type>
const PixelRef<Type> icl::core::Img< Type >::operator() ( int  x,
int  y 
) const [inline]

as above, but const

template<class Type>
Type icl::core::Img< Type >::operator() ( float  fX,
float  fY,
int  iChannel,
scalemode  eMode 
) const

sub-pixel access operator, uses given interpolation method

template<class Type>
Img<Type>& icl::core::Img< Type >::operator= ( const Img< Type > &  tSource) [inline]

Assign operator (flat copy of channels) WARNING: Violates const concept.

Both images will share their channel data. Use deepCopy() to obtain a copy of an image which is not attached to the source image. Note: this implicit shallow copy can be exploited to violate ICL's const concept:

          void func(const Img8u &a){
            Img8u b = a;
            // b is now unconst and therewith the data of
            // a can b chaned
          }
Parameters:
tSourceReference to source object.
template<class Type>
Channel<Type> icl::core::Img< Type >::operator[] ( int  channel) [inline]

extracts an image channel

See also:
ICLUtils::iclDynMatrix.h
Parameters:
channelvalid channel index
template<class Type>
const Channel<Type> icl::core::Img< Type >::operator[] ( int  channel) const [inline]

extracts an image channel

See also:
ICLUtils::iclDynMatrix.h
Parameters:
channelvalid channel index
template<class Type>
void icl::core::Img< Type >::printAsMatrix ( const std::string &  format = "5.3",
bool  visROI = true 
) const

shows the image value by value at std::out

Warning: SLOW

Parameters:
formatthis string is passed to printf internally uchars can be printed e.g. using format="3.0"
visROIindicates ROI-pixels with a 'r'-postfix (only if image has no full-ROI)
template<class Type>
template<typename Tsrc , typename Tdst , int Nsrc, int Ndst, typename ReduceFunc >
static void icl::core::Img< Type >::reduce_arrays ( const Tsrc *  src[Nsrc],
Tdst *  dst[Ndst],
unsigned int  dim,
ReduceFunc  reduce 
) [inline, static, private]

private helper function called from reduce_channels template

template<class Type>
template<typename Tdst , int Nthis, int Ndst, typename ReduceFunc >
void icl::core::Img< Type >::reduce_channels ( Img< Tdst > &  dst,
ReduceFunc  reduce 
) const [inline]

Utility function for combining image channels into another image.

In some application we want to combine an images channels pixel-by-pixel in any way and to store the result (or even results) in a 2nd image at the corresponding image location. This can easily be performed using the reduce channels template function. Look at the following example:

          struct Thresh{
             Thresh(int t):t(t*3){}
             int t;    
             void operator()(const icl8u src[6], icl8u dst[1]) const{
               *dst = 255*( (abs(src[0]-src[3])+abs(src[1]-src[4])+abs(src[2]-src[5])) > t);
             }
          };
  
          Img8u bgMask(const Img8u &image,const Img8u &bgImage, int tollerance){
             Img8u imageAndBG;
             imageAndBG.append(&const_cast<Img8u&>(image));   // const_cast is ok here,
             imageAndBG.append(&const_cast<Img8u&>(bgImage)); // we will not change them!
             Img8u dst(image.getSize(),formatMatrix);
             imageAndBG.reduce_channels<icl8u,6,1,Thresh>(dst,Thresh(tollerance));
             return dst;
          }

Performance

Source and destination channel count is given as template parameter, to allow the compiler to leave out loops over single values or to unroll short ones. Besides, the compiler is able to use fixed sized arrays on the stack, instead of dynamically allocated heap arrays. By this means performance of reduce_channels is accelerated by factor 12.

Benchmarks

Exemplarily, the example function above takes about 4-5ms on a 2GHz Core2Duo (using -O4 and -funroll-loop optimization of gcc) on a VGA-sized image (640x480)

template<class Type>
Img<Type>* icl::core::Img< Type >::reinterpretChannels ( format  newFmt,
Img< Type > *  poDst = NULL 
) [inline]

Create a shallow copy of this image with a new format.

Parameters:
newFmtnew format to choose. This must be compatible to the channel count of this image.
poDstdestination image (exploited as possible)
Returns:
shallow copie with given format of NULL if an error occured
template<class Type>
const Img<Type>* icl::core::Img< Type >::reinterpretChannels ( format  newFmt) [inline]

Create a shallow copy of this image with a new format (const version)

Parameters:
newFmtnew format to choose. This must be compatible to the channel count of this image.
Returns:
shallow copie with given format of NULL if an error occured
template<class Type>
virtual void icl::core::Img< Type >::removeChannel ( int  iChannel) [virtual]

Removes a specified channel.

Removes a specified channel.

If a non-matrix format image looses a channel, the new channel count will not match to the channel count, that is associated with the current format. In this case, a warning is written to std::out, and the format will be set to formatMatrix implicitly. To avoid this warning the programmer has to change the format explicitly before to formatMatrix.

Parameters:
iChannelIndex of channel to remove

Implements icl::core::ImgBase.

template<class Type>
void icl::core::Img< Type >::replaceChannel ( int  iThisIndex,
Img< Type > *  poOtherImg,
int  iOtherIndex 
)

Replace the channel A of this image with the channel B another image.

Both images must have the same width and height.

Parameters:
iThisIndexchannel to replace
iOtherIndexchannel to replace with
poOtherImgImage that contains the new channel
template<class Type>
virtual void icl::core::Img< Type >::scale ( const utils::Size s,
scalemode  eScaleMode = interpolateNN 
) [virtual]

perform an in-place resize of the image (keeping the data)

performs an in-place resize operation on the image (IPP-OPTIMIZED)

The image size is adapted on demand to the given size, and the image data is scaled. This function is SLOW in comparison to the scaledCopy function that is also provided in this class, as an additional scaling buffer is allocated and released at runtime.

Parameters:
snew size of this image
eScaleModeinterpolation method to use for the scaling operation

Implements icl::core::ImgBase.

template<class Type>
virtual Img<Type>* icl::core::Img< Type >::scaledCopy ( const utils::Size newSize,
scalemode  eScaleMode = interpolateNN 
) const [virtual]

create a scaled copy of this image

scaled-, and flipped-Copy functions

Create a scaled copy with given size of an image.

Parameters:
newSizesize of the new image
eScaleModeinterpolation method to use when scaling the image
Returns:
scaled image

Implements icl::core::ImgBase.

template<class Type>
virtual Img<Type>* icl::core::Img< Type >::scaledCopy ( ImgBase **  ppoDst = 0,
scalemode  eScaleMode = interpolateNN 
) const [virtual]

create a scaled copy of this image

Create a scaled copy into a given destination image.

If the given destination pointer ppoDst is NULL, a deep copy of this image is returned. If ppoDst points to NULL, a new a deep copy of this image is created at *ppoDst. Otherwise, the destination image is only adapted in its depth to this image; its size is hold.

Parameters:
ppoDstoptionally given destination image pointer
eScaleModeinterpolation method to use when scaling the image
Returns:
scaled image

Implements icl::core::ImgBase.

template<class Type>
Img<Type>* icl::core::Img< Type >::scaledCopy ( Img< Type > *  poDst,
scalemode  eScaleMode = interpolateNN 
) const

create a scaled copy of this image

Overloaded function to create a scaled copy of an image. This function gets an Img<Type>* as destination, what allows to apply the operation without any depth-switch.

Parameters:
poDstdestination image pointer, if NULL, a new Img<Type> is created
eScaleModeinterpolation method to use when scaling
template<class Type>
virtual Img<Type>* icl::core::Img< Type >::scaledCopyROI ( const utils::Size newSize,
scalemode  eScaleMode = interpolateNN 
) const [virtual]

create a scaled copy of an images ROI with given size

Create a scaled copy with given size of an images ROI.

This function behaves identically to the scaledCopy function above, except it is applied on the source images ROI only.

Parameters:
newSizesize of the new image
eScaleModeinterpolation method to use when scaling the image
Returns:
image containing a scaled instance of the source images ROI

Implements icl::core::ImgBase.

template<class Type>
virtual Img<Type>* icl::core::Img< Type >::scaledCopyROI ( ImgBase **  ppoDst = 0,
scalemode  eScaleMode = interpolateNN 
) const [virtual]

create a scaled copy of an images ROI with given destination image

Create a scaled copy of an images ROI with optionally given destination image.

This function behaves identically to the scaledCopy function above, except it is applied on the source images ROI only.

Parameters:
ppoDstoptionally given destination image pointer
eScaleModeinterpolation method to use when scaling the image
Returns:
image containing a scaled instance of the source images ROI

Implements icl::core::ImgBase.

template<class Type>
Img<Type>* icl::core::Img< Type >::scaledCopyROI ( Img< Type > *  poDst,
scalemode  eScaleMode = interpolateNN 
) const

create a scaled copy of this images ROI

Overloaded function to create a scaled copy of an images ROI. This function gets an Img<Type>* as destination, what allows to apply the operation without any depth-switch.

Parameters:
poDstdestination image pointer, if NULL, a new Img<Type> is created
eScaleModeinterpolation method to use when scaling
template<class Type>
Img<Type>* icl::core::Img< Type >::selectChannel ( int  channelIndex,
Img< Type > *  poDst = 0 
) [inline]

Create a shallow copy of a single image channel of an image.

This function is a shortcut to use icl::ImgBase::selectChannels(const std::vector<int>&,icl::ImgBase**) to select a single channel from an image

Parameters:
channelIndexindex of the channel to select (if invalid, NULL is returned)
poDstdestination image
Returns:
image containing only the selected channel
template<class Type>
const Img<Type>* icl::core::Img< Type >::selectChannel ( int  channelIndex) const [inline]

Create a shallow copy of a single image channel of a const image.

This function is a shortcut to use icl::ImgBase::selectChannels(const std::vector<int>&)const to select a single channel from a const image image

Parameters:
channelIndexindex of the channel to select (if invalid, NULL is returned)
Returns:
const image containing only the selected channel

Reimplemented from icl::core::ImgBase.

template<class Type>
Img<Type>* icl::core::Img< Type >::selectChannels ( const std::vector< int > &  channelIndices,
Img< Type > *  poDst = 0 
) [inline]

Create a shallow copy of selected channels of an image.

This function can be used if only one or some channels of a given const image should be used in further processing steps. It helps to avoid the necessity of "deepCopy" calls there.

Parameters:
channelIndicesvector containing channel indices to copy
poDstdestination image (if Null, a new one is created)
Returns:
image containing only the selected channels (as shallow copies) format of that image becomes formatMatrix
See also:
shallowCopy
template<class Type>
const Img<Type>* icl::core::Img< Type >::selectChannels ( const std::vector< int > &  channelIndices) const [inline]

Create a shallow copy of selected channels of a const image.

Parameters:
channelIndicesvector containing channel indices to copy
Returns:
const image containing only the selected channels

Reimplemented from icl::core::ImgBase.

template<class Type>
virtual void icl::core::Img< Type >::setChannels ( int  iNewNumChannels) [virtual]

sets the channel count to a new value

sets the channel count to a new value

This function works only on demand, that means, that channels will only be created/deleted, if the new channel count differs from the current. If the current image has a non-matrix format, then the new channel count must match to the channel count associated with this format. If not, a warning is written to std::out, and the format is set to formatMatrix implicitly. To avoid this warning, the image format must be set to formatMatrix explicitly before calling setChannels

Parameters:
iNewNumChannelsnew channel count

Implements icl::core::ImgBase.

template<class Type>
virtual void icl::core::Img< Type >::setSize ( const utils::Size s) [virtual]

resizes the image to new values

resizes the image to new size (image data is lost!)

operation is performed on demand - if the image has already the given size, then nothing is done at all. For resizing operation with scaling of the image data use scale. Note: The ROI of the image is set to the hole image using delROI(), notwithstanding if a resize operation was performed or not.

Parameters:
snew image size (if x or y is < 0, the original width/height is used)
See also:
scale

Implements icl::core::ImgBase.

template<class Type>
Img<Type>& icl::core::Img< Type >::shallowCopy ( const Img< Type > &  tSource) [private]

Private assign operator (internally used)

This must be kept private! Because the assign operator could otherwise be exploited to violate the Img's const concept

template<class Type>
virtual Img<Type>* icl::core::Img< Type >::shallowCopy ( const utils::Rect roi,
const std::vector< int > &  channelIndices,
format  fmt,
utils::Time  time = utils::Time::null,
ImgBase **  ppoDst = NULL 
) [virtual]

Create a shallow copy of an image with given

Parameters:
ppoDstdestination image which is exploited if possible, or otherwise reallocated
roiROI of the new Image
channelIndicesindices to select from the source image. These channels are shallow-copied into the destination image
fmtformat of the new image (the channel count that is associated with this format must be equal to the channel count that is implicitely defined by the size of the vector channelIndices
timenew timestamp for the returned image
Returns:
shallow-copied image

Implements icl::core::ImgBase.

template<class Type>
const Img<Type>* icl::core::Img< Type >::shallowCopy ( const utils::Rect roi,
const std::vector< int > &  channelIndices,
format  fmt,
utils::Time  time = utils::Time::null 
) const [inline]

Create a shallow copy of an image with given (const version)

See also:
the above function
Parameters:
roiROI of the new Image
channelIndicesindices to select from the source image. These channels are shallow-copied into the destination image (if size is null, all channels are selected)
fmtformat of the new image (the channel count that is associated with this format must be equal to the channel count that is implicitely defined by the size of the vector channelIndices
timenew timestamp for the returned image
Returns:
shallow-copied image

Reimplemented from icl::core::ImgBase.

template<class Type>
Img<Type>* icl::core::Img< Type >::shallowCopy ( const utils::Rect roi,
Img< Type > *  poDst = NULL 
) [inline]

Create a shallow copy of the image.

It exploits the given destination image if possible, i.e. if the pixel depth matches. Else this image is released and a new one is created. Optionally a second argument can be specified to get a new image with the given ROI.

Parameters:
poDstpointer to the destination image pointer If ppoDst is NULL, a new image is created, if ppoDst points to NULL, a new image is created at *ppoDst;
roinew ROI of the new image. If Rect::null, the source images roi is used.
Returns:
shallow copy of this image
template<class Type>
const Img<Type>* icl::core::Img< Type >::shallowCopy ( const utils::Rect roi) const [inline]

Create a shallow copy of a const source image.

In contrast to the not const function shallowCopy, the const one does not provide to specify a destination image pointer, because this must neither be const nor not const. If it would be const, it would not be possible to adapt it to correct parameters, otherwise it would violate the const concept as it could be used to change the const result.
This function can only be used to get const copy of a source image with a special ROI.

Parameters:
roiROI of the returned image (Rect::null is not allowed!)
Returns:
shallow copy of this image with specified ROI

Reimplemented from icl::core::ImgBase.

template<class Type>
float icl::core::Img< Type >::subPixelLIN ( float  fX,
float  fY,
int  iChannel 
) const

sub-pixel access using linear interpolation

template<class Type>
float icl::core::Img< Type >::subPixelNN ( float  fX,
float  fY,
int  iChannel 
) const [inline]

sub-pixel access using nearest neighbor interpolation

template<class Type>
float icl::core::Img< Type >::subPixelRA ( float  fX,
float  fY,
float  w,
float  h,
int  iChannel 
) const

sub-pixel access using region average interpolation

template<class Type>
float icl::core::Img< Type >::subPixelRA ( const unsigned int  xB,
const unsigned int  xE,
const unsigned int  yB,
const unsigned int  yE,
const float  xBMul,
const float  xEMul,
const float  BMul,
const float  yEMul,
const Type *  d,
const unsigned int  w 
) const
template<class Type>
virtual void icl::core::Img< Type >::swapChannels ( int  iIndexA,
int  iIndexB 
) [virtual]

Swap channel A and B.

Swap channel A and B.

The channel swap operation is shallow; only the channel pointers are swapped.

Parameters:
iIndexAIndex of channel A;
iIndexBIndex of channel B

Implements icl::core::ImgBase.

template<class Type>
template<typename UnaryFunction , class dstType >
Img<dstType>& icl::core::Img< Type >::transform ( UnaryFunction  f,
Img< dstType > &  dst 
) const [inline]

STL based "transform" implementation applying an Unary function on ROI-pixles with given destination image.

Internally this function uses std::transform. Example:

          #include <ICLQt/Quick.h>
          
          inline icl8u t_func(const float &f){ 
            return f>128 ? 0 : 255; 
          }
          
          int main(){
            ImgQ a = scale(create("parrot"),0.2);
            Img8u b(a.getParams());
          
            a.transform(t_func,b);
            show(cvt(b));
            return 0;
          }
Parameters:
funary function of functor implementing "dstType operator()(const Type &val)"
dstdestination image with identical ROI-size and channel count (compared to this image)
template<class Type>
template<typename UnaryFunction , class dstType >
Img<dstType>& icl::core::Img< Type >::transform_C ( UnaryFunction  f,
int  srcChannel,
int  dstChannel,
Img< dstType > &  dst 
) const [inline]

STL based "transform" implementation applying an Unary function on ROI-pixles with given destination image.

Internally this function uses std::transform. Example:

          #include <ICLQt/Quick.h>
          
          struct Thresh{
            inline float operator()(const float &f){ return f>128 ? 0 : 255; }
          };
          
          int main(){
            ImgQ a = scale(create("parrot"),0.2);
            ImgQ b(a.getParams());
          
            a.transform_C(Thresh(),1,2,b);
            show(b);
            return 0;
          }
Parameters:
funary function of functor implementing "dstType operator()(const Type &val)"
srcChannelvalid channel index for this image
dstChannelvalid channel index for dst image
dstdestination image with identical ROI-size to this images ROI-size

Friends And Related Function Documentation

template<class Type>
template<class ImgType >
const ImgType* combineImages ( const std::vector< const ImgType * > &  vec,
ImgBase **  ppoDst 
) [friend]

Member Data Documentation

template<class Type>
std::vector<utils::SmartArray<Type> > icl::core::Img< Type >::m_vecChannels [protected]

internally used storage for the image channels

template<class Type>
const Img<Type> icl::core::Img< Type >::null [static]

null sized and null channel image


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines