/******************************************************************** ** Image Component Library (ICL) ** ** ** ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** ** Neuroinformatics Group ** ** Website: www.iclcv.org and ** ** http://opensource.cit-ec.de/projects/icl ** ** ** ** File : ICLCore/src/ICLCore/ImgBase.h ** ** Module : ICLCore ** ** Authors: Christof Elbrechter, Michael Goetting, Robert ** ** Haschke, Andre Justus ** ** ** ** ** ** GNU LESSER GENERAL PUBLIC LICENSE ** ** This file may be used under the terms of the GNU Lesser General ** ** Public License version 3.0 as published by the ** ** ** ** Free Software Foundation and appearing in the file LICENSE.LGPL ** ** included in the packaging of this file. Please review the ** ** following information to ensure the license requirements will ** ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** ** ** ** The development of this software was supported by the ** ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** ** Forschungsgemeinschaft (DFG) in the context of the German ** ** Excellence Initiative. ** ** ** ********************************************************************/ #pragma once #include #include #include #include #include #include #include #include namespace icl { namespace core{ /// ImgBase is the Image-Interface class that provides save access to underlying Img-template \ingroup IMAGE \ingroup TYPES /** \section SEC1 Class The ImgBase class provides access to the following basic image features: - image size - channel count - depth: currently one of the following: - depth8u - depth16s - depth32s - depth32f - depth64f - format: color-format associated with images channels (see section "Img Color Formats") - raw data: getDataPtr(int) returns image data form nth channel as void pointer. The function is implemented in the inherited classes Img and Img, which also provide type-safe access functions, e.g. getData (int). - time stamp: The time stamp of an images can be set using the setTime() and getTime() functions. All image sources should set the time stamp of the produced images.\n An images time stamp is associated with image images content ( what scene is shown on the image). So it is not implicitly the images creation time, but it corresponds to the last time the images data content was set. E.g. a scaling operation would not change the images time stamp. \section SEC2 How to use the ImgBase class. As the ImgBase is an abstract class, no ImgBase objects can be instantiated It merely provides a common interface to methods provided by the inherited classe Img. It can be used in all functions the abstract about the underlying data type. E.g. consider a scaling operation on images: When regarding an image as a continuous 2D function, it is not necessary to know the images data type when scaling it. However the developer might say: "At the latest if I want to implement some kind of interpolation I have to know the actual data type I'm working on".\n The ImgBase class implements exactly this kind of abstraction from the underlying implementation. Although the implementation has indeed to tackle each of the different data types (E.g. floating point types vs. integer types) in an appropriate way, it is possible to call such function directly on the abstract ImgBase object.\n Many other operations are also conceptually independent on the concrete pixel type, e.g. recombining or selecting channels For these operations the ImgBase class provides abstract or implemented methods ensuring a common and type-independent interface. For example, to resize an image, one can easily write: \code void any_function(ImgBase *poBase){ poBase->setSize(Size(640,480)); ... } \endcode \section Examples The following example should explain how to work with ImgBase class. \code void special_function_8u(Img8u* poImage){...} void special_function_16s(Img16f* poImage){...} ... void special_function_64f(Img64f* poImage){...} void generic_function(ImgBase *poImage){ switch(poImage->getDepth()){ case depth8u: special_function_8u(poImage->asImg()); case depth16s: special_function_8u(poImage->asImg()); ... case depth64f: special_function_(poImage->asImg()); } } \endcode Template functions can be called in an analogous way: \code template void template_function(Img *poImg){...} void generic_function(ImgBase *poImage){ switch(poImage->getDepth()){ case depth8u: template_function(poImage->asImg()); case depth16s: template_function(poImage->asImg()); ... case depth64f: template_function(poImage->asImg()); } } \endcode **/ class ICLCore_API ImgBase{ public: /// Destructor virtual ~ImgBase(); /** @{ @name shallow copy */ /** Create a shallow copy of an image with given @param ppoDst destination image which is exploited if possible, or otherwise reallocated @param roi ROI of the new Image @param channelIndices indices to select from the source image. These channels are shallow-copied into the destination image @param fmt format 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 @param time new timestamp for the returned image @return shallow-copied image **/ virtual ImgBase *shallowCopy(const utils::Rect &roi, const std::vector &channelIndices, format fmt, utils::Time time=utils::Time::null, ImgBase **ppoDst = NULL) = 0; /** Create a shallow copy of an image with given (const version) @see the above function @param roi ROI of the new Image @param channelIndices indices to select from the source image. These channels are shallow-copied into the destination image (if size is null, all channels are selected) @param fmt format 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 @param time new timestamp for the returned image @return shallow-copied image **/ const ImgBase *shallowCopy(const utils::Rect &roi, const std::vector &channelIndices, format fmt, utils::Time time=utils::Time::null) const{ // casting constness away is safe, because we effectively return a const Img* return const_cast(this)->shallowCopy(roi,channelIndices,fmt,time,0); } /// Create a shallow copy of this image with a new format /** @param newFmt new format to choose. This must be compatible to the channel count of this image. @param ppoDst destination image (exploited as possible) @return shallow copie with given format of NULL if an error occured **/ ImgBase *reinterpretChannels(format newFmt, ImgBase **ppoDst = NULL){ return shallowCopy(getROI(),std::vector(),newFmt,getTime(),ppoDst); } /// Create a shallow copy of this image with a new format (const version) /** @param newFmt new format to choose. This must be compatible to the channel count of this image. @return shallow copie with given format of NULL if an error occured **/ const ImgBase *reinterpretChannels(format newFmt) const{ // casting constness away is safe, because we effectively return a const Img* return const_cast(this)->shallowCopy(getROI(),std::vector(),newFmt,getTime()); } /// 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. @param ppoDst pointer 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; @param roi new ROI of the new image. If Rect::null, the source images roi is used. @return shallow copy of this image **/ ImgBase* shallowCopy(const utils::Rect &roi, ImgBase** ppoDst = NULL){ return shallowCopy(roi,std::vector(),getFormat(),getTime(),ppoDst); } ImgBase* shallowCopy(ImgBase** ppoDst = NULL){ return shallowCopy(getROI(),std::vector(),getFormat(),getTime(),ppoDst); } /// 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.\n This function can only be used to get const copy of a source image with a special ROI. @param roi ROI of the returned image (Rect::null is not allowed!) @return shallow copy of this image with specified ROI */ const ImgBase* shallowCopy(const utils::Rect& roi) const { // casting constness away is safe, because we effectively return a const Img* return const_cast(this)->shallowCopy(roi,0); } /// 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. @param channelIndices vector containing channel indices to copy @param ppoDst destination image (if Null, a new one is created) @return image containing only the selected channels (as shallow copies) format of that image becomes formatMatrix @see shallowCopy */ ImgBase* selectChannels (const std::vector& channelIndices, ImgBase** ppoDst=0){ return shallowCopy(getROI(),channelIndices,formatMatrix,getTime(),ppoDst); } /// 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&,icl::ImgBase**) to select a single channel from an image @param channelIndex index of the channel to select (if invalid, NULL is returned) @param ppoDst destination image @return image containing only the selected channel **/ ImgBase* selectChannel(int channelIndex, ImgBase **ppoDst=0){ ICLASSERT_RETURN_VAL(validChannel(channelIndex), 0); std::vector v(1); v[0]= channelIndex; return selectChannels(v,ppoDst); } /// Create a shallow copy of selected channels of a const image. /** @param channelIndices vector containing channel indices to copy @return const image containing only the selected channels */ const ImgBase* selectChannels (const std::vector& channelIndices) const { // casting constness away is safe, because we effectively return a const Img* return const_cast(this)->selectChannels(channelIndices, 0); } /// 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&)const to select a single channel from a const image image @param channelIndex index of the channel to select (if invalid, NULL is returned) @return const image containing only the selected channel **/ const ImgBase *selectChannel(int channelIndex) const{ ICLASSERT_RETURN_VAL(validChannel(channelIndex), 0); std::vector v(1); v[0]= channelIndex; return selectChannels(v); } /** @{ @name deep copy and depth conversion */ /// 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 @param ppoDst optionally given destination image @return deep copied image */ virtual ImgBase *deepCopy(ImgBase **ppoDst=0) const=0; /// 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. @param ppoDst optionally given destination image @return image containing a deep copy of the source images ROI */ virtual ImgBase *deepCopyROI(ImgBase **ppoDst=0) const=0; /// returns an Img instance of this image (type-conversion or deep copy) /** If the requested type differs from the actual image type, then a type conversion is performed to transfer the image data to poDst. Else deepCopy is called, to transfer the image data. If poDst is NULL, it is created with identical parameters, except for the images depth, which is given by the template parameter T. (For developers: The convert function builds the base function for other higher level functions like deepCopy. Internally it calls the icl namespace function deepCopyChannel, which decides if data has to be copied or converted.) @param poDst destination image. If NULL, then a deep copy of the current image is returned @return converted image @see deepCopy */ template ICLCore_API Img *convert(Img *poDst=NULL) const; /// returns a converted (or deep copied) instance of this image /** This function can be called using an explicit destination depth. The function switches the depth parameter and calls the associated convert template function @param d new images depth @return converted image */ ImgBase *convert(depth d) const; /// converts image data into the given destination image /** @param poDst destination image (exploited if not NULL else a deep copy of this is returned) @return converted image **/ ImgBase *convert(ImgBase *poDst) const; /// returns a converted (or deep copied) instance of this images ROI /** This function behaves essentially like the above functions, except it is applied on the source image ROI only. @param poDst optionally given destination image pointer. @return converted image, containing the source images ROI */ template ICLCore_API Img *convertROI(Img *poDst=NULL) const; /// returns a converted (or deep copied) instance of this images ROI /** This function behaves essentially like the above functions, except it is applied on the source image ROI only. @param d new images depth @return converted image, containing the source images ROI */ ImgBase *convertROI(depth d) const; /// converts this images ROI into a given destination image /** The destination image is exploited if not NULL, else a deep copy of this is created and returned. @param poDst destination image (its depth is hold, other parameters are adapted) @return converted image (poDst if it was not NULL) that was adapted to this images ROI size, channels, format and Time **/ ImgBase *convertROI(ImgBase *poDst) const; /// Create a scaled copy with given size of an image /** @param newSize size of the new image @param eScaleMode interpolation method to use when scaling the image @return scaled image */ virtual ImgBase *scaledCopy(const utils::Size &newSize, scalemode eScaleMode=interpolateNN) const = 0; /// 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. @param ppoDst optionally given destination image pointer @param eScaleMode interpolation method to use when scaling the image @return scaled image */ virtual ImgBase *scaledCopy(ImgBase **ppoDst=0, scalemode eScaleMode=interpolateNN) const = 0; /// 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. @param newSize size of the new image @param eScaleMode interpolation method to use when scaling the image @return image containing a scaled instance of the source images ROI */ virtual ImgBase *scaledCopyROI(const utils::Size &newSize, scalemode eScaleMode=interpolateNN) const = 0; /// 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. @param ppoDst optionally given destination image pointer @param eScaleMode interpolation method to use when scaling the image @return image containing a scaled instance of the source images ROI */ virtual ImgBase *scaledCopyROI(ImgBase **ppoDst=0, scalemode eScaleMode=interpolateNN) const = 0; /// @} /** @{ @name asImg cast templates */ /// dynamically casts this image to one of its Img subclasses /** This function performs an emulated dynamic_cast on this image and returns a Img*. If this image can not be casted to the the template type that is specified by the template parameter T, a NULL-pointer is returned. To avoid an expensive RTTI-runtime check using dynamic_cast, this images depth is compared the the depth associated the the template parameter T. @return Img* instance of this image **/ template Img *asImg() { ICLASSERT_RETURN_VAL( icl::core::getDepth() == this->getDepth(), 0); return reinterpret_cast*>(this); } /// dynamically casts this image to one of its Img subclasses (const version) /** const version of the above function @return const Img* instance of this image **/ template const Img *asImg() const { ICLASSERT_RETURN_VAL( icl::core::getDepth() == getDepth(), 0); return reinterpret_cast*>(this); } /// convenience shortcut version for asImg() inline Img *as8u() { return asImg(); } /// convenience shortcut version for asImg() inline Img *as16s() { return asImg(); } /// convenience shortcut version for asImg() inline Img *as32s() { return asImg(); } /// convenience shortcut version for asImg() inline Img *as32f() { return asImg(); } /// convenience shortcut version for asImg() inline Img *as64f() { return asImg(); } /// convenience shortcut version for asImg() inline const Img *as8u() const { return asImg(); } /// convenience shortcut version for asImg() inline const Img *as16s() const { return asImg(); } /// convenience shortcut version for asImg() inline const Img *as32s() const { return asImg(); } /// convenience shortcut version for asImg() inline const Img *as32f() const { return asImg(); } /// convenience shortcut version for asImg() inline const Img *as64f() const { return asImg(); } /// @} /** @{ @name getter (without ROI handling) */ /// returns all params in terms of a const ImgParams reference /** This enables the programmer to write
          imageA.setParams(imageB.getParams());
          
*/ const ImgParams &getParams() const{ return m_oParams; } /// returns the size of the images // returns the images size const utils::Size& getSize() const { return m_oParams.getSize(); } /// returns the images width int getWidth() const { return m_oParams.getWidth(); } /// returns the images height int getHeight() const { return m_oParams.getHeight(); } /// returns the pixel count of each channel int getDim() const { return m_oParams.getDim(); } /// returns the channel count of the image int getChannels() const { return m_oParams.getChannels(); } /// returns the depth (depth8u or depth32f) depth getDepth() const { return m_eDepth; } /// returns the current (color)-format of this image format getFormat() const { return m_oParams.getFormat(); } /// returns the timestamp of the image utils::Time getTime() const { return m_timestamp; } /// returns the length of an image line in bytes (width*sizeof(Type)) /** This information is compulsory for calling any IPP function. @return getWidth()*sizeof(Type) in the underlying Img template **/ virtual int getLineStep() const = 0; /// @} /** @{ @name ROI handling */ /// returns the images ROI rectangle const utils::Rect &getROI() const{ return m_oParams.getROI(); } /// copies the current ROI into the given offset and size references void getROI(utils::Point& offset, utils::Size& size) const { m_oParams.getROI(offset,size); } /// returns the images ROI offset (upper left corner) utils::Point getROIOffset() const{ return m_oParams.getROIOffset(); } /// returns the images ROI size utils::Size getROISize() const{ return m_oParams.getROISize(); } /// returns the images ROI width int getROIWidth() const{ return m_oParams.getROIWidth(); } /// returns the images ROI height int getROIHeight() const{ return m_oParams.getROIHeight(); } /// returns the images ROI XOffset int getROIXOffset() const{ return m_oParams.getROIXOffset(); } /// returns the images ROI YOffset int getROIYOffset() const{ return m_oParams.getROIYOffset(); } /// returns the image rect (0,0,width, height) utils::Rect getImageRect() const { return utils::Rect(utils::Point::null,getSize()); } /// sets the image ROI offset to the given value void setROIOffset(const utils::Point &offset) { m_oParams.setROIOffset(offset); } /// sets the image ROI size to the given value void setROISize(const utils::Size &size) { m_oParams.setROISize(size); } /// set both image ROI offset and size void setROI(const utils::Point &offset, const utils::Size &size){ m_oParams.setROI(offset,size); } /// sets the image ROI to the given rectangle void setROI(const utils::Rect &roi) { m_oParams.setROI(roi); } /// checks, eventually adapts and finally sets the image ROI size /** @see ImgParams*/ void setROIOffsetAdaptive(const utils::Point &offset) { m_oParams.setROIOffsetAdaptive(offset); } /// checks, eventually adapts and finally sets the image ROI size /** @see ImgParams*/ void setROISizeAdaptive(const utils::Size &size){ m_oParams.setROISizeAdaptive(size); } /// checks, eventually adapts and finally sets the image ROI size /** @see ImgParams*/ void setROIAdaptive(const utils::Rect &roi) { m_oParams.setROIAdaptive(roi); } /// returns ROISize == ImageSize int hasFullROI() const { return m_oParams.hasFullROI(); } /// resets the image ROI to the whole image size with offset (0,0) void setFullROI() { m_oParams.setFullROI(); } /// @} /** @{ @name border functions */ /// 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 */ virtual void fillBorder(bool setFullROI=true)=0; /// fills all non-ROI pixels with a given value virtual void fillBorder(icl64f val, bool setFullROI=true)=0; /// 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() */ virtual void fillBorder(const std::vector &vals, bool setFullROI=true)=0; /// 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.*/ virtual void fillBorder(const ImgBase *src, bool setFullROI=true)=0; /// @} /** @{ @name data access */ /// returns a pointer to first data element of a given channel /** @see Img*/ virtual const void* getDataPtr(int iChannel) const = 0; /// returns a pointer to first data element of a given channel /** @see Img*/ virtual void* getDataPtr(int iChannel) = 0; /// @} /** @{ @name channel management */ /// Makes the image channels independent from other images. /** @param iIndex index 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 **/ virtual void detach(int iIndex = -1)=0; /// 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. @param iChannel Index of channel to remove **/ virtual void removeChannel(int iChannel)=0; /// Swap channel A and B /** The channel swap operation is shallow; only the channel pointers are swapped. @param iIndexA Index of channel A; @param iIndexB Index of channel B **/ virtual void swapChannels(int iIndexA, int iIndexB)=0; /// sets all image parameters in order channels,size,format,roi void setParams(const ImgParams ¶ms); /// 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 @param iNewNumChannels new channel count **/ virtual void setChannels(int iNewNumChannels)=0; /// 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. @param s new image size (if x or y is < 0, the original width/height is used) @see scale **/ virtual void setSize(const utils::Size &s)=0; /// sets the format associated with channels of the image /** The channel count of the image is set to the channel count associated with the set format, if they differ. E.g an image with one channel will have 3 channels after a setFormat(formatRGB) - call. @param fmt new format value @see getChannelsOfFormat **/ void setFormat(format fmt); /// sets the timestamp of the image void setTime(const utils::Time time) { m_timestamp = time; } /// sets timestamp of the image to the current time void setTime() { m_timestamp = utils::Time::now(); } /// @} /** @{ @name min and max element */ /// Returns max pixel value of channel iChannel within ROI /** @param iChannel Index of channel @param coords (optinal) if not null, the pixel position of the max is written into this argument **/ icl64f getMax(int iChannel, utils::Point *coords=0) const; /// Returns min pixel value of channel iChannel within ROI /** @param iChannel Index of channel @param coords (optinal) if not null, the pixel position of the min is written into this argument **/ icl64f getMin(int iChannel, utils::Point *coords=0) const; /// return maximal pixel value over all channels (restricted to ROI) icl64f getMin() const; /// return minimal pixel value over all channels (restricted to ROI) icl64f getMax() const; /// Returns min and max pixel values of channel iChannel within ROI /** @param iChannel Index of channel @param minCoords (optinal) if not null, the pixel position of the min is written into this argument @param maxCoords (optinal) if not null, the pixel position of the max is written into this argument @return channel range in terms of a Range struct **/ const utils::Range getMinMax(int iChannel, utils::Point *minCoords=0, utils::Point *maxCoords=0) const; /// Returns min and max pixel values of all channels within ROI /** @return image range in terms of a Range struct **/ const utils::Range getMinMax() const; /// @} /** @{ @name in-place image adaption */ /// 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. @param s new size of this image @param eScaleMode interpolation method to use for the scaling operation **/ virtual void scale(const utils::Size& s, scalemode eScaleMode=interpolateNN)=0; /// 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 @param eAxis axis for the mirror operations @param bOnlyROI if set, only the ROI of this image is mirrored, else the whole image is mirrored. **/ virtual void mirror(axis eAxis, bool bOnlyROI=false)=0; /// Sets the ROI pixels of one or all channels to a specified value /** @param iChannel Channel to fill with zero (default: -1 = all channels) @param val destination value (default: 0) @param bROIOnly if set false, the whole image is set to val **/ void clear(int iChannel = -1, icl64f val=0, bool bROIOnly=true); /// 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. @param dstRange range of all channels after the operation **/ void normalizeAllChannels(const utils::Range &dstRange); /// Normalize the channel from a given min/max range to the new range /** @param iChannel channel index @param srcRange assumption of the current range of the channel @param dstRange range of the channel after the operation **/ void normalizeChannel(int iChannel,const utils::Range &srcRange, const utils::Range &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. (Internally: this function calls normalizeChannel with srcRage = this->getMinMax(iChannel) ) @param iChannel channel index @param dstRange range of the channel after the operation **/ void normalizeChannel(int iChannel, const utils::Range &dstRange); /// Normalize the image from a given min/max range to the new range /** @param srcRange assumption of the current image range @param dstRange range of the image after the operation **/ void normalizeImg(const utils::Range &srcRange, const utils::Range &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. (Internally: this function calls normalizeImg with srcRage = this->getMinMax() ) @param dstRange range of the image after the operation **/ void normalizeImg(const utils::Range &dstRange); /// @} /** @{ @name utility functions */ /// prints the image to std-out /** @param sTitle optional title, that can be printed before printing the image parameters to identify the message. **/ void print(const std::string sTitle="image") const; /// validate the given channel index bool validChannel(const int iChannel) const { return iChannel >= 0 && iChannel < getChannels(); } /// returns if two images have same size, and channel count /** @param s size to test @param nChannels channel count to test **/ bool isEqual(const utils::Size &s, int nChannels) const { FUNCTION_LOG("isEqual("<getParams() && getDepth() == otherImage->getDepth(); } /// returns whether image data is currently shared /** This function does only return true, if all channel pointers have reference count 1 -- i.e. all channels are currently not shared with another image */ virtual bool isIndependent() const=0; /// @} /// returns whether meta data has been associated to this image inline bool hasMetaData() const { return m_metaData.length(); } /// associates new meta data with this image inline void setMetaData(const std::string &data){ m_metaData = data; } /// removes all meta data inline void clearMetaData(){ setMetaData(""); } /// returns associated meta data inline const std::string &getMetaData() const { return m_metaData; } /// returns associated meta data (unconst) std::string &getMetaData() { return m_metaData; } protected: /// Creates an ImgBase object with specified image parameters ImgBase(depth d, const ImgParams& params); /// all image params /** the params class consists of - image size - number of image channels - image format - image ROI */ ImgParams m_oParams; /// depth of the image (depth8 for icl8u/depth32 for icl32f) depth m_eDepth; /// timestamp of the image utils::Time m_timestamp; /// additional information associated with this image std::string m_metaData; }; /// puts a string representation of the image into given steam ICLCore_API std::ostream &operator<<(std::ostream &s, const ImgBase &image); } // namespace core }