Image Component Library (ICL)
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
icl::filter::MorphologicalOp Class Reference

Class for Morphological operations . More...

#include <MorphologicalOp.h>

Inheritance diagram for icl::filter::MorphologicalOp:
icl::filter::NeighborhoodOp icl::utils::Uncopyable icl::filter::UnaryOp icl::utils::Configurable

Public Types

enum  optype {
  dilate =0, erode =1, dilate3x3 =2, erode3x3 =3,
  dilateBorderReplicate =4, erodeBorderReplicate =5, openBorder =6, closeBorder =7,
  tophatBorder =8, blackhatBorder =9, gradientBorder =10
}
 this enum specifiy all possible morphological operations More...
 
- Public Types inherited from icl::utils::Configurable
typedef Function< void, const Property & > Callback
 Function type for changed properties. More...
 

Public Member Functions

 MorphologicalOp (optype t, const utils::Size &maskSize=utils::Size(3, 3), const icl8u *mask=0)
 Constructor that creates a Morphological object, with specified mask size. More...
 
 MorphologicalOp (const std::string &optype="erode", const utils::Size &maskSize=utils::Size(3, 3), const icl8u *mask=0)
 constructor with given optype as string More...
 
 ~MorphologicalOp ()
 Destructor. More...
 
void setMask (utils::Size size, const icl8u *pcMask=0)
 Change mask. More...
 
const icl8ugetMask () const
 returns mask More...
 
utils::Size getMaskSize () const
 returns mask size More...
 
void setOptype (optype type)
 
optype getOptype () const
 returns the type of the selected morphological operation More...
 
void apply (const core::ImgBase *poSrc, core::ImgBase **ppoDst)
 Performs morph of an image with given optype and mask. More...
 
virtual void apply (const core::ImgBase *operand1, core::ImgBase **dst)=0
 Import unaryOps apply function without destination image. More...
 
virtual const core::ImgBaseapply (const core::ImgBase *src)
 Import unaryOps apply function without destination image. More...
 
- Public Member Functions inherited from icl::filter::NeighborhoodOp
virtual ~NeighborhoodOp ()
 Destructor. More...
 
bool computeROI (const core::ImgBase *poSrc, utils::Point &oROIoffset, utils::Size &oROIsize)
 compute neccessary ROI offset and size More...
 
virtual void applyMT (const core::ImgBase *operand1, core::ImgBase **dst, unsigned int nThreads)
 NEW apply function for multithreaded filtering (reimplemented here for special roi handling!) More...
 
const utils::SizegetMaskSize () const
 
const utils::PointgetAnchor () const
 
const utils::PointgetROIOffset () const
 
virtual void apply (const core::ImgBase *operand1, core::ImgBase **dst)=0
 Import unaryOps apply function without destination image. More...
 
virtual const core::ImgBaseapply (const core::ImgBase *src)
 Import unaryOps apply function without destination image. More...
 
- Public Member Functions inherited from icl::filter::UnaryOp
 UnaryOp ()
 Explicit empty constructor. More...
 
 UnaryOp (const UnaryOp &other)
 Explicit copy constructor. More...
 
UnaryOpoperator= (const UnaryOp &other)
 Explicit declaration of the assignment operator. More...
 
virtual ~UnaryOp ()
 Destructor. More...
 
virtual const core::ImgBaseapply (const core::ImgBase *src)
 applys the filter usign an internal buffer as output image More...
 
void operator() (const core::ImgBase *src, core::ImgBase **dst)
 function operator (alternative for apply(src,dst) More...
 
const core::ImgBaseoperator() (const core::ImgBase *src)
 function operator for the implicit destination apply(src) call More...
 
const core::ImgBaseoperator() (const core::ImgBase &src)
 reference based function operator More...
 
void setClipToROI (bool bClipToROI)
 sets if the image should be clip to ROI or not More...
 
void setCheckOnly (bool bCheckOnly)
 sets if the destination image should be adapted to the source, or if it is only checked if it can be adapted. More...
 
bool getClipToROI () const
 returns the ClipToROI status More...
 
bool getCheckOnly () const
 returns the CheckOnly status More...
 
virtual void setPropertyValue (const std::string &propertyName, const utils::Any &value)
 sets value of a property (always call call_callbacks(propertyName) or Configurable::setPropertyValue) More...
 
- Public Member Functions inherited from icl::utils::Configurable
virtual ~Configurable ()
 virtual destructor More...
 
 Configurable (const Configurable &other)
 Copy constructor. More...
 
Configurableoperator= (const Configurable &other)
 Assignment operator. More...
 
void setConfigurableID (const std::string &ID)
 sets the ID of this configurable More...
 
const std::string & getConfigurableID () const
 returns the configurables static ID More...
 
bool isOrderedFlagSet () const
 returns whether the ordered flag is set More...
 
void deactivateProperty (const std::string &pattern)
 adds an additional deativation pattern More...
 
void deleteDeactivationPattern (const std::string &pattern)
 removed a formerly added deactivation pattern More...
 
std::vector< std::string > getPropertyListWithoutDeactivated () const
 this returns a filtered list of properties (using all filters added by deactivateProperty) More...
 
virtual void adaptProperty (const std::string &name, const std::string &newType, const std::string &newInfo, const std::string &newToolTip)
 this function can be used to adapt a specific property afterwards More...
 
void registerCallback (const Callback &cb)
 add a callback for changed properties More...
 
void removedCallback (const Callback &cb)
 removes a callback that was registered before More...
 
void syncChangesTo (Configurable *others, int num=1)
 this can be used to let this instance also apply property changes to others More...
 
virtual std::vector< std::string > getPropertyList () const
 returns a list of All properties, that can be set using setProperty More...
 
virtual bool supportsProperty (const std::string &propertyName) const
 base implementation for property check (seaches in the property list) More...
 
virtual void saveProperties (const std::string &filename, const std::vector< std::string > &propertiesToSkip=EMPTY_VEC) const
 writes all available properties into a file More...
 
virtual void loadProperties (const std::string &filename, const std::vector< std::string > &propertiesToSkip=EMPTY_VEC)
 reads a camera config file from disc More...
 
virtual std::string getPropertyType (const std::string &propertyName) const
 get type of property More...
 
virtual std::string getPropertyInfo (const std::string &propertyName) const
 get information of a properties valid values More...
 
virtual Any getPropertyValue (const std::string &propertyName) const
 returns the current value of a property or a parameter More...
 
virtual std::string getPropertyToolTip (const std::string &propertyName) const
 returns the tooltip description for a given property More...
 
virtual int getPropertyVolatileness (const std::string &propertyName) const
 Returns whether this property may be changed internally. More...
 

Private Types

typedef IppiMorphState ICLMorphState
 
typedef IppiMorphAdvState ICLMorphAdvState
 

Private Member Functions

template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize, const Ipp8u *, IppiSize, IppiPoint) >
IppStatus ippiMorphologicalCall (const core::Img< T > *src, core::Img< T > *dst)
 
template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize) >
IppStatus ippiMorphologicalCall3x3 (const core::Img< T > *src, core::Img< T > *dst)
 
template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize, _IppiBorderType, IppiMorphState *) >
IppStatus ippiMorphologicalBorderReplicateCall (const core::Img< T > *src, core::Img< T > *dst, IppiMorphState *state)
 
template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize, IppiBorderType, IppiMorphAdvState *) >
IppStatus ippiMorphologicalBorderCall (const core::Img< T > *src, core::Img< T > *dst, IppiMorphAdvState *advState)
 
void deleteMorphStates ()
 
void checkMorphAdvState8u (const utils::Size roiSize)
 
void checkMorphAdvState32f (const utils::Size roiSize)
 
void checkMorphState8u (const utils::Size roiSize)
 
void checkMorphState32f (const utils::Size roiSize)
 

Private Attributes

icl8um_pcMask
 
utils::Size m_oMaskSizeMorphOp
 
ICLMorphStatem_pState8u
 
ICLMorphStatem_pState32f
 
ICLMorphAdvStatem_pAdvState8u
 
ICLMorphAdvStatem_pAdvState32f
 
bool m_bMorphState8u
 
bool m_bMorphState32f
 
bool m_bMorphAdvState8u
 
bool m_bMorphAdvState32f
 
bool m_bHas_changed
 
bool m_bHas_changedAdv
 
optype m_eType
 

Additional Inherited Members

- Static Public Member Functions inherited from icl::filter::UnaryOp
static UnaryOpfromString (const std::string &definition)
 Creates a UnaryOp instance from given string definition. More...
 
static std::string getFromStringSyntax (const std::string &opSpecifier)
 gives a string syntax description for given opSpecifier More...
 
static std::vector< std::string > listFromStringOps ()
 returns a list of all supported OP_SPEC values for the fromString function More...
 
static void applyFromString (const std::string &definition, const core::ImgBase *src, core::ImgBase **dst)
 creates, applies and releases a UnaryOp defined by given definition string More...
 
- Static Public Member Functions inherited from icl::utils::Configurable
static std::string create_default_ID (const std::string &prefix)
 this function can be used in subclasses to create a default ID More...
 
static Configurableget (const std::string &id)
 returns configurable by given ID More...
 
static void register_configurable_type (const std::string &classname, Function< Configurable * > creator)
 registers a configurable type More...
 
static std::vector< std::string > get_registered_configurables ()
 returns a list of all registered configurable classnames More...
 
static Configurablecreate_configurable (const std::string &classname)
 creates a configurable by given name More...
 
- Static Public Attributes inherited from icl::utils::Configurable
static const std::vector< std::string > EMPTY_VEC
 used as shortcut – just an empty vector of std::strings More...
 
- Protected Member Functions inherited from icl::filter::NeighborhoodOp
 NeighborhoodOp ()
 
 NeighborhoodOp (const utils::Size &size)
 
void setMask (const utils::Size &size)
 
void setMask (const utils::Size &size, const utils::Point &anchor)
 
void setROIOffset (const utils::Point &offs)
 
virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc)
 prepare filter operation: ensure compatible image format and size More...
 
virtual bool prepare (core::ImgBase **ppoDst, const core::ImgBase *poSrc, core::depth eDepht)
 prepare filter operation: as above, but with depth parameter More...
 
virtual utils::Size adaptSize (const utils::Size &size)
 this function can be reimplemented e.g to enshure an odd mask width and height More...
 
- Protected Member Functions inherited from icl::filter::UnaryOp
bool prepare (core::ImgBase **ppoDst, core::depth eDepth, const utils::Size &imgSize, core::format eFormat, int nChannels, const utils::Rect &roi, utils::Time timestamp=utils::Time::null)
 
- Protected Member Functions inherited from icl::utils::Configurable
void addProperty (const std::string &name, const std::string &type, const std::string &info, const Any &value=Any(), const int volatileness=0, const std::string &tooltip=std::string())
 This can be used by derived classes to store supported properties in the internal list. More...
 
void addChildConfigurable (Configurable *configurable, const std::string &childPrefix="")
 This adds another configurable as child. More...
 
void removeChildConfigurable (Configurable *configurable)
 removes the given child configurable More...
 
Propertyprop (const std::string &propertyName)
 this CAN be used e.g. to store a property value in internal property-list More...
 
const Propertyprop (const std::string &propertyName) const
 this CAN be used e.g. to store a property value in internal property-list More...
 
 Configurable (const std::string &ID="", bool ordered=true)
 create this configurable with given ID More...
 
void call_callbacks (const std::string &propertyName, const Configurable *caller) const
 calls all registered callbacks More...
 
- Protected Member Functions inherited from icl::utils::Uncopyable
 Uncopyable ()
 Empty base constructor. More...
 
- Protected Attributes inherited from icl::filter::NeighborhoodOp
utils::Size m_oMaskSize
 TODO: later private with getter and setter functions. More...
 
utils::Point m_oAnchor
 anchor of filter mask More...
 
utils::Point m_oROIOffset
 to-be-used ROI offset for source image More...
 
- Protected Attributes inherited from icl::filter::UnaryOp
utils::MultiThreaderm_poMT
 
- Protected Attributes inherited from icl::utils::Configurable
std::vector< Callbackcallbacks
 internally managed list of callbacks More...
 

Detailed Description

Class for Morphological operations .

(Only available for Img8u and Img32f, IPP and fallback implementation)

Destination Image Sizes

Destination image ROI size depends not only on given input ROI size and mask-size, but also on the used optype. In case of default operations (dilate, erode, ... destination ROI size is calculated as in the top level NeighborhoodOp class. But Note: for dilate and erode border, destination image roi size becomes equal to the source images one if using IPP support. The fallback C++ implementation uses internally other instaces of MorphologicalOp to apply e.g. an erosion operation, hence, destination roi size is adapted in that case as one might expect.

Operations

The basic operations dilatation and erosion are not implemented as hit-or-miss transformation, but as gray-level morphologic operators. Each operator works with a binary mask which is moved successively through the source images ROI. At each pixel location. All pixel values within the mask boundaries, where the corresponding mask-entry differs from zero are evaluated as follows:

  1. dilatation: destination image pixel becomes the the maximum pixel of all pixels within mask
  2. erosion: destination image pixel becomes the the minimum pixel of all pixels within mask
  3. erosion3x3 and dilatation3x3: this is just a shortcut for using a 3x3 mask where all entries are set to 1. IPP obviously does a lot of optimizations here, fallback doesn't
  4. dilate/erode border replicate: as standard operation, except copying border pixels from closes valid computed pixels (not tested well in fallback case)
  5. opening erosion followed by a dilatation-step
  6. closing dilatation followed by an erosion-step
  7. tophat source image minus opening result
  8. blackhat closing result - source image
  9. gradient closing result - opened result

Example (Image Convolution)

As a useful help, some example images are shown here:

left: binary image results, right: gray image results

morphologic_operator_results.png

Member Typedef Documentation

◆ ICLMorphAdvState

typedef IppiMorphAdvState icl::filter::MorphologicalOp::ICLMorphAdvState
private

◆ ICLMorphState

typedef IppiMorphState icl::filter::MorphologicalOp::ICLMorphState
private

Member Enumeration Documentation

◆ optype

this enum specifiy all possible morphological operations

Enumerator
dilate 
erode 
dilate3x3 
erode3x3 
dilateBorderReplicate 
erodeBorderReplicate 
openBorder 
closeBorder 
tophatBorder 
blackhatBorder 
gradientBorder 

Constructor & Destructor Documentation

◆ MorphologicalOp() [1/2]

icl::filter::MorphologicalOp::MorphologicalOp ( optype  t,
const utils::Size maskSize = utils::Size(3, 3),
const icl8u mask = 0 
)

Constructor that creates a Morphological object, with specified mask size.

Parameters
toperation type if(dilate3x3 or erode3x3), further arguments can be left out
maskSizenot used if t is dilate3x3 or erode3x3. maskSie must be positive in width and height. If widht or height is even, the next larger odd integer is used (otherwise IPP fails)
maskIf != NULL, only pixels within that mask that are not 0 are are used

◆ MorphologicalOp() [2/2]

icl::filter::MorphologicalOp::MorphologicalOp ( const std::string &  optype = "erode",
const utils::Size maskSize = utils::Size(3, 3),
const icl8u mask = 0 
)

constructor with given optype as string

The string ids are identical to the optype enumeration value names

◆ ~MorphologicalOp()

icl::filter::MorphologicalOp::~MorphologicalOp ( )

Destructor.

Member Function Documentation

◆ apply() [1/3]

void icl::filter::MorphologicalOp::apply ( const core::ImgBase poSrc,
core::ImgBase **  ppoDst 
)
virtual

Performs morph of an image with given optype and mask.

Implements icl::filter::UnaryOp.

◆ apply() [2/3]

virtual void icl::filter::UnaryOp::apply

Import unaryOps apply function without destination image.

◆ apply() [3/3]

virtual const core::ImgBase* icl::filter::UnaryOp::apply

Import unaryOps apply function without destination image.

◆ checkMorphAdvState32f()

void icl::filter::MorphologicalOp::checkMorphAdvState32f ( const utils::Size  roiSize)
private

◆ checkMorphAdvState8u()

void icl::filter::MorphologicalOp::checkMorphAdvState8u ( const utils::Size  roiSize)
private

◆ checkMorphState32f()

void icl::filter::MorphologicalOp::checkMorphState32f ( const utils::Size  roiSize)
private

◆ checkMorphState8u()

void icl::filter::MorphologicalOp::checkMorphState8u ( const utils::Size  roiSize)
private

◆ deleteMorphStates()

void icl::filter::MorphologicalOp::deleteMorphStates ( )
private

◆ getMask()

const icl8u* icl::filter::MorphologicalOp::getMask ( ) const

returns mask

Returns
mask

◆ getMaskSize()

utils::Size icl::filter::MorphologicalOp::getMaskSize ( ) const

returns mask size

Returns
mask size

◆ getOptype()

optype icl::filter::MorphologicalOp::getOptype ( ) const

returns the type of the selected morphological operation

Returns
optype

◆ ippiMorphologicalBorderCall()

template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize, IppiBorderType, IppiMorphAdvState *) >
IppStatus icl::filter::MorphologicalOp::ippiMorphologicalBorderCall ( const core::Img< T > *  src,
core::Img< T > *  dst,
IppiMorphAdvState *  advState 
)
private

◆ ippiMorphologicalBorderReplicateCall()

template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize, _IppiBorderType, IppiMorphState *) >
IppStatus icl::filter::MorphologicalOp::ippiMorphologicalBorderReplicateCall ( const core::Img< T > *  src,
core::Img< T > *  dst,
IppiMorphState *  state 
)
private

◆ ippiMorphologicalCall()

template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize, const Ipp8u *, IppiSize, IppiPoint) >
IppStatus icl::filter::MorphologicalOp::ippiMorphologicalCall ( const core::Img< T > *  src,
core::Img< T > *  dst 
)
private

◆ ippiMorphologicalCall3x3()

template<typename T , IppStatus(IPP_DECL *ippiFunc)(const T *, int, T *, int, IppiSize) >
IppStatus icl::filter::MorphologicalOp::ippiMorphologicalCall3x3 ( const core::Img< T > *  src,
core::Img< T > *  dst 
)
private

◆ setMask()

void icl::filter::MorphologicalOp::setMask ( utils::Size  size,
const icl8u pcMask = 0 
)

Change mask.

◆ setOptype()

void icl::filter::MorphologicalOp::setOptype ( optype  type)

Member Data Documentation

◆ m_bHas_changed

bool icl::filter::MorphologicalOp::m_bHas_changed
private

◆ m_bHas_changedAdv

bool icl::filter::MorphologicalOp::m_bHas_changedAdv
private

◆ m_bMorphAdvState32f

bool icl::filter::MorphologicalOp::m_bMorphAdvState32f
private

◆ m_bMorphAdvState8u

bool icl::filter::MorphologicalOp::m_bMorphAdvState8u
private

◆ m_bMorphState32f

bool icl::filter::MorphologicalOp::m_bMorphState32f
private

◆ m_bMorphState8u

bool icl::filter::MorphologicalOp::m_bMorphState8u
private

◆ m_eType

optype icl::filter::MorphologicalOp::m_eType
private

◆ m_oMaskSizeMorphOp

utils::Size icl::filter::MorphologicalOp::m_oMaskSizeMorphOp
private

◆ m_pAdvState32f

ICLMorphAdvState* icl::filter::MorphologicalOp::m_pAdvState32f
private

◆ m_pAdvState8u

ICLMorphAdvState* icl::filter::MorphologicalOp::m_pAdvState8u
private

◆ m_pcMask

icl8u* icl::filter::MorphologicalOp::m_pcMask
private

◆ m_pState32f

ICLMorphState* icl::filter::MorphologicalOp::m_pState32f
private

◆ m_pState8u

ICLMorphState* icl::filter::MorphologicalOp::m_pState8u
private

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