IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Classes | Typedefs | Enumerations | Functions
Morphological structuring elements

Morphological structuring elements management. More...

Classes

class  ipsdk::BaseStructuringElement
 Base class for binary structuring element objects. More...
 
class  ipsdk::BaseStructuringElementInfo
 Base class for objects encapsulating informations about binary structuring element objects. More...
 
class  ipsdk::StructuringElementXY
 Class encapsulating a 2d structuring element spanning along x and y axis. More...
 
class  ipsdk::StructuringElementXYInfo
 Concrete class for objects encapsulating informations about 2d binary structuring element objects. More...
 
class  ipsdk::StructuringElementXYZ
 Class encapsulating a 3d structuring element spanning along x, y and z axis. More...
 
class  ipsdk::StructuringElementXYZInfo
 Concrete class for objects encapsulating informations about 3d binary structuring element objects. More...
 

Typedefs

typedef std::set< OffsetXYipsdk::XYOffsetColl
 collection of xy 2d offsets
 
typedef std::set< OffsetXYZipsdk::XYZOffsetColl
 collection of xyz 3d offsets
 

Enumerations

enum  ipsdk::eSEXYSubType {
  ipsdk::eSEXY_Generic, ipsdk::eSEXY_Circular, ipsdk::eSEXY_Square, ipsdk::eSEXY_Rectangular,
  ipsdk::eSEXY_HalfLinear, ipsdk::eSEXY_Linear
}
 Enumerate describing binary structuring element 2d sub type. More...
 
enum  ipsdk::eSEXYZSubType {
  ipsdk::eSEXYZ_Generic, ipsdk::eSEXYZ_Spherical, ipsdk::eSEXYZ_Cubic, ipsdk::eSEXYZ_Rectangular,
  ipsdk::eSEXYZ_HalfLinear, ipsdk::eSEXYZ_Linear
}
 Enumerate describing binary structuring element 3d sub type. More...
 
enum  ipsdk::eStructuringElementType { ipsdk::eSET_XY, ipsdk::eSET_XYZ }
 Enumerate describing binary structuring element type. More...
 

Functions

IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::genericSEXYInfo (const StructuringElementXY &seXY)
 function allowing to generate a generic structuring element (SE)
 
IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::emptySEXYInfo ()
 function allowing to generate an empty XY structuring element (SE)
 
IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::squareSEXYInfo (const ipUInt32 halfSESize)
 function allowing to generate a square XY structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::rectangularSEXYInfo (const ipUInt32 halfSESizeX, const ipUInt32 halfSESizeY)
 function allowing to generate a rectangular XY structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::circularSEXYInfo (const ipReal64 radius)
 function allowing to generate a filled circular XY structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::halfLinearSEXYInfo (const ipReal64 theta, const ipReal64 radius)
 function allowing to generate a half linear structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::linearSEXYInfo (const ipReal64 theta, const ipReal64 radius)
 function allowing to generate a linear structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::genericSEXYZInfo (const StructuringElementXYZ &seXYZ)
 function allowing to generate a generic structuring element (SE)
 
IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::emptySEXYZInfo ()
 function allowing to generate an empty XYZ structuring element (SE)
 
IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::cubicSEXYZInfo (const ipUInt32 halfSESize)
 function allowing to generate a cubic XYZ structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::rectangularSEXYZInfo (const ipUInt32 halfSESizeX, const ipUInt32 halfSESizeY, const ipUInt32 halfSESizeZ)
 function allowing to generate a rectangular parallelepiped XYZ structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::sphericalSEXYZInfo (const ipReal64 radius)
 function allowing to generate a filled spherical XYZ structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::halfLinearSEXYZInfo (const ipReal64 theta, const ipReal64 phi, const ipReal64 radius)
 function allowing to generate a half linear structuring element (SE) More...
 
IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::linearSEXYZInfo (const ipReal64 theta, const ipReal64 phi, const ipReal64 radius)
 function allowing to generate a linear structuring element (SE) More...
 
typedef boost::shared_ptr< StructuringElementXYInfoipsdk::StructuringElementXYInfoPtr
 shared pointer to StructuringElementXYInfo
 
typedef boost::shared_ptr< const StructuringElementXYInfoipsdk::StructuringElementXYInfoConstPtr
 shared pointer to StructuringElementXYInfo
 
typedef boost::shared_ptr< StructuringElementXYZInfoipsdk::StructuringElementXYZInfoPtr
 shared pointer to StructuringElementXYZInfo
 
typedef boost::shared_ptr< const StructuringElementXYZInfoipsdk::StructuringElementXYZInfoConstPtr
 shared pointer to StructuringElementXYZInfo
 
typedef boost::shared_ptr< StructuringElementXYipsdk::StructuringElementXYPtr
 shared pointer to StructuringElementXY
 
typedef boost::shared_ptr< const StructuringElementXYipsdk::StructuringElementXYConstPtr
 shared pointer to StructuringElementXY
 
typedef boost::shared_ptr< StructuringElementXYZipsdk::StructuringElementXYZPtr
 shared pointer to StructuringElementXYZ
 
typedef boost::shared_ptr< const StructuringElementXYZipsdk::StructuringElementXYZConstPtr
 shared pointer to StructuringElementXYZ
 

Detailed Description

Morphological structuring elements management.

Definition

Introduction

A morphological structuring element (SE) is a binary shape used by morphological operators (such as erosion, dilation, ...) to specialize operator behavior.

See also
http://en.wikipedia.org/wiki/Structuring_element

2d structuring elements

In 2d case, a morphological structuring element (associated to class ipsdk::StructuringElementXYInfo) is represented by a collection of offsets (associated to class ipsdk::OffsetXY) defining its shape.

Rectangular structuring elements

Rectangular structuring elements are defined by their half size along X and Y axis ( $ halfSizeX $ and $ halfSizeY $) and aggregate all offsets such as :

\[ SE[halfSizeX, halfSizeY] = \left \{ (o_x, o_y) / \left | o_x \right | \leqslant halfSizeX \& \left | o_y \right | \leqslant halfSizeY \right \} \]

Full size of structuring element is then defined by :

\[ \left \{ \begin{matrix} sizeX = 2 \times halfSizeX + 1 \\ sizeY = 2 \times halfSizeY + 1 \end{matrix} \right . \]

The following C++ example illustrates the definition of a rectangular morphological structuring element :

using namespace ipsdk;
void testRectangularSE()
{
const ipUInt32 halfSizeX = 3;
const ipUInt32 halfSizeY = 2;
}
rectangularSE2d.png

The following C++ example illustrates the definition of a square morphological structuring element :

using namespace ipsdk;
void testSquareSE()
{
const ipUInt32 halfSize = 3;
}
squareSE2d.png

Circular structuring elements

Circular structuring elements are defined by their radius and aggregate all offsets enclosed in associated circle :

\[ SE[radius] = \left \{ (o_x, o_y) / o_x^2 + o_y^2 <= radius^2 \right \} \]

The following C++ example illustrates the definition of a circular morphological structuring element :

using namespace ipsdk;
void testCircularSE()
{
const ipReal64 radius = 3.5;
}
circularSE2d.png

Half Linear structuring elements

Half linear structuring elements are defined by an orientation and a radius and aggregate offsets at the intersection of associated direction and circle :

\[ SE[\theta, radius] = \left \{ (o_x, o_y) / \exists \lambda \in \mathbb{N}^+ / o_x=\lambda \cos{\theta}, o_y=\lambda \sin{\theta} \& o_x^2 + o_y^2 <= radius^2 \right \} \]

The following C++ example illustrates the definition of a half linear morphological structuring element :

using namespace ipsdk;
void testHalfLinearSE()
{
const ipReal64 theta = M_PI / 6;
const ipReal64 radius = 6;
}
halfLinearSE2d.png
Note
See Points and vectors 2d representation for more informations on 2d orientation conventions.

Linear structuring elements

Linear structuring elements are defined by an orientation and a radius and aggregate offsets at the intersection of associated direction and circle :

\[ SE[\theta, radius] = \left \{ (o_x, o_y) / \exists \lambda \in \mathbb{N} / o_x=\lambda \cos{\theta}, o_y=\lambda \sin{\theta} \& o_x^2 + o_y^2 <= radius^2 \right \} \]

The following C++ example illustrates the definition of a linear morphological structuring element :

using namespace ipsdk;
void testLinearSE()
{
const ipReal64 theta = M_PI / 6;
const ipReal64 radius = 6;
}
linearSE2d.png
Note
See Points and vectors 2d representation for more informations on 2d orientation conventions.

3d structuring elements

In 3d case, a morphological structuring element (associated to class ipsdk::StructuringElementXYZInfo) is represented by a collection of offsets (associated to class ipsdk::OffsetXYZ) defining its shape.

Rectangular structuring elements

Rectangular structuring elements are defined by their half size along X, Y and Z axis ( $ halfSizeX $, $ halfSizeY $ and $ halfSizeZ $) and aggregate all offsets such as :

\[ SE[halfSizeX, halfSizeY, halfSizeZ] = \left \{ (o_x, o_y, o_z) / \left | o_x \right | \leqslant halfSizeX \& \left | o_y \right | \leqslant halfSizeY \& \left | o_z \right | \leqslant halfSizeZ \right \} \]

Full size of structuring element is then defined by :

\[ \left \{ \begin{matrix} sizeX = 2 \times halfSizeX + 1 \\ sizeY = 2 \times halfSizeY + 1 \\ sizeZ = 2 \times halfSizeZ + 1 \end{matrix} \right . \]

The following C++ example illustrates the definition of a rectangular morphological structuring element :

using namespace ipsdk;
void testRectangularSE()
{
const ipUInt32 halfSizeX = 4;
const ipUInt32 halfSizeY = 1;
const ipUInt32 halfSizeZ = 2;
StructuringElementXYZInfoConstPtr pSE = rectangularSEXYZInfo(halfSizeX, halfSizeY, halfSizeZ);
}
rectangularSE3d.png

The following C++ example illustrates the definition of a cubic morphological structuring element :

using namespace ipsdk;
void testCubicSE()
{
const ipUInt32 halfSize = 3;
}
cubicSE3d.png

Spherical structuring elements

Spherical structuring elements are defined by their radius and aggregate all offsets enclosed in associated sphere :

\[ SE[radius] = \left \{ (o_x, o_y, o_z) / o_x^2 + o_y^2 + o_z^2 <= radius^2 \right \} \]

The following C++ example illustrates the definition of a spherical morphological structuring element :

using namespace ipsdk;
void testSphericalSE()
{
const ipReal64 radius = 4;
}
sphericalSE3d.png

Half Linear structuring elements

Half linear structuring elements are defined by an orientation and a radius and aggregate offsets at the intersection of associated direction and sphere :

\[ SE[\theta, \phi, radius] = \left \{ (o_x, o_y) / \exists \lambda \in \mathbb{N}^+ / o_x=\lambda \sin{\theta} \cos{\phi}, o_y=\lambda \sin{\theta} \sin{\phi}, o_z=\lambda \cos{\theta} \& o_x^2 + o_y^2 + o_z^2 <= radius^2 \right \} \]

The following C++ example illustrates the definition of a half linear morphological structuring element :

using namespace ipsdk;
void testHalfLinearSE()
{
const ipReal64 theta = M_PI / 6;
const ipReal64 phi = M_PI / 4;
const ipReal64 radius = 6;
}
halfLinearSE3d.png
Note
See Points and vectors 3d representation for more informations on 3d orientation conventions.

Linear structuring elements

Linear structuring elements are defined by an orientation and a radius and aggregate offsets at the intersection of associated direction and sphere :

\[ SE[\theta, \phi, radius] = \left \{ (o_x, o_y) / \exists \lambda \in \mathbb{N} / o_x=\lambda \sin{\theta} \cos{\phi}, o_y=\lambda \sin{\theta} \sin{\phi}, o_z=\lambda \cos{\theta} \& o_x^2 + o_y^2 + o_z^2 <= radius^2 \right \} \]

The following C++ example illustrates the definition of a linear morphological structuring element :

using namespace ipsdk;
void testLinearSE()
{
const ipReal64 theta = M_PI / 6;
const ipReal64 phi = M_PI / 4;
const ipReal64 radius = 6;
}
linearSE3d.png
Note
See Points and vectors 3d representation for more informations on 3d orientation conventions.

Usage

Introduction

Erosion and dilation are the two fundamental morphological operations.

These operations use a flat (with values in [0, 1]) structuring element combined to a Minkowski sum (in case of dilation) or subtraction (in case of erosion). Formula associated to each of these operations are given by :

Structuring elements typology

Structuring elements specific typology (shape) are detailed into :

These different typologies include rectangle, circle, sphere, lines, ...

Each of this shape can be used to respond to a specific need. We will try to illustrate this concept in the following section.

Detailed samples :

The following examples illustrates usage of different structuring element types for dilation 2d algorithm. A dilation 2d operation has been chosen for this use case but all these considerations could be extended to 3d case as well as other morphological operators.

Specific case of circular and spherical shapes

Circular 2d and spherical 3d structuring elements morphological operations can be optimised using a multi-level decomposition algorithm described in :
Multi-level decomposition of Euclidean spheres, Michael S. Vaz, Atilla P. Kiraly and Russell M. Mersereau, Proceedings of the 8 th International Symposium on Mathematical Morphology, Rio de Janeiro, Brazil, Oct. 10–13, 2007, MCT/INPE, v. 1, p. 461–472

This method allows to decompose convex and symmetric (with respect to x, y and z axis) structuring elements into a combination of elementary structuring elements.

The following graph shows processing time comportment of a standard implementation of a morphological operation using a circular 2d structuring element versus its multi-level decomposition form :

MLDProcessingTimes2d.png

The following graph shows processing time comportment of a standard implementation of a morphological operation using a spherical 3d structuring element versus its multi-level decomposition form :

MLDProcessingTimes3d.png

Morphological 2d and 3d operations are optimized to swap between a standard and a multi-level decomposition implementation in function of these graphs.

Note
In special case of binary input images, an additional optimization is applied (based on a distance map algorithm) which ensure constant processing times for high structuring element radiuss.

Enumeration Type Documentation

◆ eSEXYSubType

Enumerate describing binary structuring element 2d sub type.

Note
This object is associated to a strong enumerate definition
See also
IPSDK_Enum
Enumerator
eSEXY_Generic 

generic 2d binary structuring element

eSEXY_Circular 

2d filled circular binary structuring element

eSEXY_Square 

2d filled square binary structuring element

eSEXY_Rectangular 

2d filled rectangular binary structuring element

eSEXY_HalfLinear 

2d half linear binary structuring element agregating offsets along given direction enclosed into a given circle

eSEXY_Linear 

2d linear binary structuring element agregating offsets along given direction enclosed into a given circle

◆ eSEXYZSubType

Enumerate describing binary structuring element 3d sub type.

Note
This object is associated to a strong enumerate definition
See also
IPSDK_Enum
Enumerator
eSEXYZ_Generic 

generic 3d binary structuring element

eSEXYZ_Spherical 

3d filled spherical binary structuring element

eSEXYZ_Cubic 

3d filled cubic binary structuring element

eSEXYZ_Rectangular 

3d filled rectangular binary structuring element

eSEXYZ_HalfLinear 

3d half linear binary structuring element agregating offsets along given direction enclosed into a given sphere

eSEXYZ_Linear 

3d linear binary structuring element agregating offsets along given direction enclosed into a given sphere

◆ eStructuringElementType

Enumerate describing binary structuring element type.

Note
This object is associated to a strong enumerate definition
See also
IPSDK_Enum
Enumerator
eSET_XY 

2d binary structuring element type spanning x and y direction

eSET_XYZ 

3d binary structuring element type spanning x, y and z direction

Function Documentation

◆ squareSEXYInfo()

IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::squareSEXYInfo ( const ipUInt32  halfSESize)

function allowing to generate a square XY structuring element (SE)

Note
this structuring element will be composed of (2*halfSESize+1)*(2*halfSESize+1) elements

◆ rectangularSEXYInfo()

IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::rectangularSEXYInfo ( const ipUInt32  halfSESizeX,
const ipUInt32  halfSESizeY 
)

function allowing to generate a rectangular XY structuring element (SE)

Note
this structuring element will be composed of (2*halfSESizeX+1)*(2*halfSESizeY+1) elements

◆ circularSEXYInfo()

IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::circularSEXYInfo ( const ipReal64  radius)

function allowing to generate a filled circular XY structuring element (SE)

Note
this structuring element will be composed of all offsets $\left \{ (o_x, o_y) \right \} \in\mathbb{N}^2 / \left \| (o_x, o_y) \right \| \leq radius$
Exceptions
ipsdk::IPSDKBaseDataExceptionif radius < 0
ipsdk::IPSDKBaseDataExceptionif radius < 0

◆ halfLinearSEXYInfo()

IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::halfLinearSEXYInfo ( const ipReal64  theta,
const ipReal64  radius 
)

function allowing to generate a half linear structuring element (SE)

Note
Only direct half part of linear structuring element is considered (there is no symmetry around central offset)
Resulting structuring element will be associated to all offsets along given direction enclosed into circle defined by radius parameter
Exceptions
ipsdk::IPSDKBaseDataExceptionif radius < 0

◆ linearSEXYInfo()

IPSDKBASEDATA_API StructuringElementXYInfoPtr ipsdk::linearSEXYInfo ( const ipReal64  theta,
const ipReal64  radius 
)

function allowing to generate a linear structuring element (SE)

Note
Resulting structuring element will be symmetric around central offset
Resulting structuring element will be associated to all offsets along given direction enclosed into circle defined by radius parameter
Exceptions
ipsdk::IPSDKBaseDataExceptionif radius < 0

◆ cubicSEXYZInfo()

IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::cubicSEXYZInfo ( const ipUInt32  halfSESize)

function allowing to generate a cubic XYZ structuring element (SE)

Note
this structuring element will be composed of (2*halfSESize+1)*(2*halfSESize+1)*(2*halfSESize+1) elements

◆ rectangularSEXYZInfo()

IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::rectangularSEXYZInfo ( const ipUInt32  halfSESizeX,
const ipUInt32  halfSESizeY,
const ipUInt32  halfSESizeZ 
)

function allowing to generate a rectangular parallelepiped XYZ structuring element (SE)

Note
this structuring element will be composed of (2*halfSESizeX+1)*(2*halfSESizeY+1)*(2*halfSESizeZ+1) elements

◆ sphericalSEXYZInfo()

IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::sphericalSEXYZInfo ( const ipReal64  radius)

function allowing to generate a filled spherical XYZ structuring element (SE)

Note
this structuring element will be composed of all offsets $\left \{ (o_x, o_y, o_z) \right \} \in\mathbb{N}^3 / \left \| (o_x, o_y, o_z) \right \| \leq radius$
Exceptions
ipsdk::IPSDKBaseDataExceptionif radius < 0
ipsdk::IPSDKBaseDataExceptionif radius < 0

◆ halfLinearSEXYZInfo()

IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::halfLinearSEXYZInfo ( const ipReal64  theta,
const ipReal64  phi,
const ipReal64  radius 
)

function allowing to generate a half linear structuring element (SE)

Note
Only direct half part of linear structuring element is considered (there is no symmetry around central offset)
Resulting structuring element will be associated to all offsets along given direction enclosed into sphere defined by radius parameter
Exceptions
ipsdk::IPSDKBaseDataExceptionif radius < 0

◆ linearSEXYZInfo()

IPSDKBASEDATA_API StructuringElementXYZInfoPtr ipsdk::linearSEXYZInfo ( const ipReal64  theta,
const ipReal64  phi,
const ipReal64  radius 
)

function allowing to generate a linear structuring element (SE)

Note
Resulting structuring element will be symmetric around central offset
Resulting structuring element will be associated to all offsets along given direction enclosed into sphere defined by radius parameter
Exceptions
ipsdk::IPSDKBaseDataExceptionif radius < 0