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 icl8u * | getMask () 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 |
icl8u * | m_pcMask |
utils::Size | m_oMaskSizeMorphOp |
ICLMorphState * | m_pState8u |
ICLMorphState * | m_pState32f |
ICLMorphAdvState * | m_pAdvState8u |
ICLMorphAdvState * | m_pAdvState32f |
bool | m_bMorphState8u |
bool | m_bMorphState32f |
bool | m_bMorphAdvState8u |
bool | m_bMorphAdvState32f |
bool | m_bHas_changed |
bool | m_bHas_changedAdv |
optype | m_eType |
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:
- dilatation: destination image pixel becomes the the maximum pixel of all pixels within mask
- erosion: destination image pixel becomes the the minimum pixel of all pixels within mask
- 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
- dilate/erode border replicate: as standard operation, except copying border pixels from closes valid computed pixels (not tested well in fallback case)
- opening erosion followed by a dilatation-step
- closing dilatation followed by an erosion-step
- tophat source image minus opening result
- blackhat closing result - source image
- gradient closing result - opened result
Example
As a useful help, some example images are shown here:
left: binary image results, right: gray image results