Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
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

List of all members.

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 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.
 MorphologicalOp (const std::string &optype="erode", const utils::Size &maskSize=utils::Size(3, 3), const icl8u *mask=0)
 constructor with given optype as string
 ~MorphologicalOp ()
 Destructor.
void setMask (utils::Size size, const icl8u *pcMask=0)
 Change mask.
const icl8ugetMask () const
 returns mask
utils::Size getMaskSize () const
 returns mask size
void setOptype (optype type)
optype getOptype () const
 returns the type of the selected morphological operation
void apply (const core::ImgBase *poSrc, core::ImgBase **ppoDst)
 Performs morph of an image with given optype and mask.

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

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

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

typedef IppiMorphAdvState icl::filter::MorphologicalOp::ICLMorphAdvState [private]
typedef IppiMorphState icl::filter::MorphologicalOp::ICLMorphState [private]

Member Enumeration Documentation

this enum specifiy all possible morphological operations

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

Constructor & Destructor Documentation

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
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

Destructor.


Member Function Documentation

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.

returns mask

Returns:
mask

returns mask size

Returns:
mask size

Reimplemented from icl::filter::NeighborhoodOp.

returns the type of the selected morphological operation

Returns:
optype
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]
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]
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]
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]
void icl::filter::MorphologicalOp::setMask ( utils::Size  size,
const icl8u pcMask = 0 
)

Change mask.


Member Data Documentation


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