ITK  5.2.0
Insight Toolkit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
itk::FlatStructuringElement< VDimension > Class Template Reference

#include <itkKernelImageFilter.h>

+ Inheritance diagram for itk::FlatStructuringElement< VDimension >:
+ Collaboration diagram for itk::FlatStructuringElement< VDimension >:

Classes

struct  StructuringElementFacet
 

Public Types

using ConstIterator = typename Superclass::ConstIterator
 
using DecompType = std::vector< LType >
 
using ImageType = typename itk::Image< PixelType, VDimension >
 
using Iterator = typename Superclass::Iterator
 
using LType = Vector< float, VDimension >
 
using OffsetType = typename Superclass::OffsetType
 
using PixelType = typename Superclass::PixelType
 
using RadiusType = typename Superclass::RadiusType
 
using Self = FlatStructuringElement< VDimension >
 
using SizeType = typename Superclass::SizeType
 
using SliceIteratorType = typename Superclass::SliceIteratorType
 
using Superclass = Neighborhood< bool, VDimension >
 
- Public Types inherited from itk::Neighborhood< bool, VDimension >
using AllocatorType = NeighborhoodAllocator< bool >
 
using ConstIterator = typename AllocatorType::const_iterator
 
using DimensionValueType = unsigned int
 
using Iterator = typename AllocatorType::iterator
 
using NeighborIndexType = SizeValueType
 
using OffsetType = Offset< VDimension >
 
using PixelType = bool
 
using RadiusType = ::itk::Size< VDimension >
 
using Self = Neighborhood
 
using SizeType = ::itk::Size< VDimension >
 
using SizeValueType = typename SizeType::SizeValueType
 
using SliceIteratorType = SliceIterator< bool, Self >
 

Public Member Functions

 FlatStructuringElement ()
 
 ~FlatStructuringElement () override=default
 
- Public Member Functions inherited from itk::Neighborhood< bool, VDimension >
 itkTypeMacroNoParent (Neighborhood)
 
 Neighborhood ()
 
 Neighborhood (const Self &other)
 
 Neighborhood (Self &&)=default
 
virtual ~Neighborhood ()=default
 
Selfoperator= (const Self &other)
 
Selfoperator= (Self &&)=default
 
bool operator== (const Self &other) const
 
bool operator!= (const Self &other) const
 
const SizeType GetRadius () const
 
SizeValueType GetRadius (DimensionValueType n) const
 
SizeValueType GetSize (DimensionValueType n) const
 
SizeType GetSize () const
 
OffsetValueType GetStride (DimensionValueType axis) const
 
Iterator End ()
 
ConstIterator End () const
 
Iterator Begin ()
 
ConstIterator Begin () const
 
NeighborIndexType Size () const
 
bool & operator[] (NeighborIndexType i)
 
const bool & operator[] (NeighborIndexType i) const
 
bool & operator[] (const OffsetType &o)
 
const bool & operator[] (const OffsetType &o) const
 
bool & GetElement (NeighborIndexType i)
 
bool GetCenterValue () const
 
void SetRadius (const SizeType &)
 
void SetRadius (const SizeValueType *rad)
 
void SetRadius (const SizeValueType)
 
void Print (std::ostream &os) const
 
AllocatorTypeGetBufferReference ()
 
const AllocatorTypeGetBufferReference () const
 
OffsetType GetOffset (NeighborIndexType i) const
 
virtual NeighborIndexType GetNeighborhoodIndex (const OffsetType &) const
 
NeighborIndexType GetCenterNeighborhoodIndex () const
 
std::slice GetSlice (unsigned int) const
 

Static Public Member Functions

static Self Annulus (RadiusType radius, unsigned int thickness=1, bool includeCenter=false, bool radiusIsParametric=false)
 
static Self Ball (RadiusType radius, bool radiusIsParametric=false)
 
static Self Box (RadiusType radius)
 
static Self Cross (RadiusType radius)
 
static Self Polygon (RadiusType radius, unsigned lines)
 

Static Public Attributes

static constexpr unsigned int NeighborhoodDimension = VDimension
 
- Static Public Attributes inherited from itk::Neighborhood< bool, VDimension >
static constexpr unsigned int NeighborhoodDimension
 
using FacetType = StructuringElementFacet< VDimension >
 
using LType2 = Vector< float, 2 >
 
using LType3 = Vector< float, 3 >
 
using FacetType3 = StructuringElementFacet< 3 >
 
bool m_Decomposable
 
DecompType m_Lines
 
bool m_RadiusIsParametric
 
bool GetDecomposable () const
 
void SetDecomposable (bool v)
 
const DecompTypeGetLines () const
 
void AddLine (LType l)
 
bool CheckParallel (LType NewVec) const
 
void ComputeBufferFromLines ()
 
bool GetRadiusIsParametric () const
 
void SetRadiusIsParametric (bool flag)
 
virtual void RadiusIsParametricOn ()
 
virtual void RadiusIsParametricOff ()
 
static Self FromImage (const ImageType *image)
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
template<typename TStructuringElement , typename TRadius >
static void GeneratePolygon (TStructuringElement &res, TRadius radius, unsigned lines)
 
static void GeneratePolygon (itk::FlatStructuringElement< 2 > &res, itk::Size< 2 > radius, unsigned lines)
 
static void GeneratePolygon (itk::FlatStructuringElement< 3 > &res, itk::Size< 3 > radius, unsigned lines)
 
static RadiusType CheckImageSize (const ImageType *image)
 

Additional Inherited Members

- Protected Member Functions inherited from itk::Neighborhood< bool, VDimension >
void SetSize ()
 
virtual void Allocate (NeighborIndexType i)
 
virtual void ComputeNeighborhoodStrideTable ()
 
virtual void ComputeNeighborhoodOffsetTable ()
 

Detailed Description

template<unsigned int VDimension>
class itk::FlatStructuringElement< VDimension >

A class to support a variety of flat structuring elements, including versions created by decomposition of lines.

FlatStructuringElement provides several static methods, which can be used to create a structuring element with a particular shape, size, etc. Currently, those methods enable the creation of the following structuring elements: ball, box, cross, annulus, or polygon. Polygons are available as fast approximations of balls using line decompositions. Boxes also use line decompositions.

"Flat" refers to binary as opposed to grayscale structuring elements. Flat structuring elements can be used for both binary and grayscale images.

A Neighborhood has an N-dimensional radius. The radius is defined separately for each dimension as the number of pixels that the neighborhood extends outward from the center pixel. For example, a 2D Neighborhood object with a radius of 2x3 has sides of length 5x7. However, in the case of balls and annuli, this definition is slightly different from the parametric definition of those objects. For example, an ellipse of radius 2x3 has a diameter of 4x6, not 5x7. To have a diameter of 5x7, the radius would need to increase by 0.5 in each dimension. Thus, the "radius" of the neighborhood and the "radius" of the object should be distinguished.

To accomplish this, the "ball" and "annulus" structuring elements have an optional flag called "radiusIsParametric" (off by default). Setting this flag to true will use the parametric definition of the object and will generate structuring elements with more accurate areas, which can be especially important when morphological operations are intended to remove or retain objects of particular sizes. When the mode is turned off (default), the radius is the same, but the object diameter is set to (radius*2)+1, which is the size of the neighborhood region. Thus, the original ball and annulus structuring elements have a systematic bias in the radius of +0.5 voxels in each dimension relative to the parametric definition of the radius. Thus, we recommend turning this mode on for more accurate structuring elements, but this mode is turned off by default for backward compatibility.

As an example, a 3D ball of radius 5 should have an area of 523. With this mode turned on, the number of "on" pixels is 515 (error 1.6%), but with it turned off, the area is 739 (error 41%). For a 3D annulus of radius 5 and thickness 2, the area should be 410. With this mode turned on, the area is 392 (error 4.5%), but when turned off it is 560 (error 36%). This same trend holds for balls and annuli of any radius or dimension. For more detailed experiments with this mode, please refer to the results of the test itkFlatStructuringElementTest.cxx or the wiki example.

ITK Sphinx Examples:
ITK Sphinx Examples:
Examples
SphinxExamples/src/Filtering/BinaryMathematicalMorphology/DilateABinaryImage/Code.cxx, SphinxExamples/src/Filtering/BinaryMathematicalMorphology/ErodeABinaryImage/Code.cxx, SphinxExamples/src/Filtering/LabelMap/ApplyMorphologicalClosingOnAllLabelObjects/Code.cxx, SphinxExamples/src/Filtering/LabelMap/ApplyMorphologicalClosingOnSpecificLabelObject/Code.cxx, SphinxExamples/src/Filtering/MathematicalMorphology/DilateAGrayscaleImage/Code.cxx, SphinxExamples/src/Filtering/MathematicalMorphology/ErodeAGrayscaleImage/Code.cxx, SphinxExamples/src/Filtering/MathematicalMorphology/ErodeBinaryImageUsingFlatStruct/Code.cxx, and SphinxExamples/src/Filtering/MathematicalMorphology/GenerateStructureElementsWithAccurateArea/Code.cxx.

Definition at line 27 of file itkKernelImageFilter.h.

Member Typedef Documentation

◆ ConstIterator

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::ConstIterator = typename Superclass::ConstIterator

Definition at line 102 of file itkFlatStructuringElement.h.

◆ DecompType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::DecompType = std::vector<LType>

Definition at line 118 of file itkFlatStructuringElement.h.

◆ FacetType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::FacetType = StructuringElementFacet<VDimension>
private

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 239 of file itkFlatStructuringElement.h.

◆ FacetType3

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::FacetType3 = StructuringElementFacet<3>
private

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 250 of file itkFlatStructuringElement.h.

◆ ImageType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::ImageType = typename itk::Image<PixelType, VDimension>

ImageType used in constructors

Definition at line 121 of file itkFlatStructuringElement.h.

◆ Iterator

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::Iterator = typename Superclass::Iterator

Iterator type alias support Note the naming is intentional, i.e., AllocatorType::iterator and AllocatorType::const_iterator, because the allocator may be a vnl object or other type, which uses this form.

Definition at line 101 of file itkFlatStructuringElement.h.

◆ LType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::LType = Vector<float, VDimension>

Definition at line 117 of file itkFlatStructuringElement.h.

◆ LType2

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::LType2 = Vector<float, 2>
private

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 247 of file itkFlatStructuringElement.h.

◆ LType3

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::LType3 = Vector<float, 3>
private

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 249 of file itkFlatStructuringElement.h.

◆ OffsetType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::OffsetType = typename Superclass::OffsetType

Definition at line 106 of file itkFlatStructuringElement.h.

◆ PixelType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::PixelType = typename Superclass::PixelType

External support for pixel type.

Definition at line 96 of file itkFlatStructuringElement.h.

◆ RadiusType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::RadiusType = typename Superclass::RadiusType

Radius type alias support

Definition at line 109 of file itkFlatStructuringElement.h.

◆ Self

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::Self = FlatStructuringElement<VDimension>

Standard class type aliases.

Definition at line 92 of file itkFlatStructuringElement.h.

◆ SizeType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::SizeType = typename Superclass::SizeType

Size and value type alias support

Definition at line 105 of file itkFlatStructuringElement.h.

◆ SliceIteratorType

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::SliceIteratorType = typename Superclass::SliceIteratorType

External slice iterator type type alias support

Definition at line 112 of file itkFlatStructuringElement.h.

◆ Superclass

template<unsigned int VDimension>
using itk::FlatStructuringElement< VDimension >::Superclass = Neighborhood<bool, VDimension>

Definition at line 93 of file itkFlatStructuringElement.h.

Constructor & Destructor Documentation

◆ ~FlatStructuringElement()

template<unsigned int VDimension>
itk::FlatStructuringElement< VDimension >::~FlatStructuringElement ( )
overridedefault

Default destructor.

◆ FlatStructuringElement()

template<unsigned int VDimension>
itk::FlatStructuringElement< VDimension >::FlatStructuringElement ( )
inline

Default constructor.

Definition at line 127 of file itkFlatStructuringElement.h.

Member Function Documentation

◆ AddLine()

template<unsigned int VDimension>
void itk::FlatStructuringElement< VDimension >::AddLine ( LType  l)
inline

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 186 of file itkFlatStructuringElement.h.

◆ Annulus()

template<unsigned int VDimension>
static Self itk::FlatStructuringElement< VDimension >::Annulus ( RadiusType  radius,
unsigned int  thickness = 1,
bool  includeCenter = false,
bool  radiusIsParametric = false 
)
static

Create an annulus structuring element

◆ Ball()

template<unsigned int VDimension>
static Self itk::FlatStructuringElement< VDimension >::Ball ( RadiusType  radius,
bool  radiusIsParametric = false 
)
static

Create a ball structuring element

◆ Box()

template<unsigned int VDimension>
static Self itk::FlatStructuringElement< VDimension >::Box ( RadiusType  radius)
static

Various constructors Create a box structuring element. The structuring element is is decomposable.

◆ CheckImageSize()

template<unsigned int VDimension>
static RadiusType itk::FlatStructuringElement< VDimension >::CheckImageSize ( const ImageType image)
staticprivate

Check for correct odd size image. Return image size. Called in constructor FromImage.

◆ CheckParallel()

template<unsigned int VDimension>
bool itk::FlatStructuringElement< VDimension >::CheckParallel ( LType  NewVec) const

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

◆ ComputeBufferFromLines()

template<unsigned int VDimension>
void itk::FlatStructuringElement< VDimension >::ComputeBufferFromLines ( )

Fill the buffer of the structuring element based on the lines associated to the structuring element

◆ Cross()

template<unsigned int VDimension>
static Self itk::FlatStructuringElement< VDimension >::Cross ( RadiusType  radius)
static

Create a cross structuring element

◆ FromImage()

template<unsigned int VDimension>
static Self itk::FlatStructuringElement< VDimension >::FromImage ( const ImageType image)
static

Create a FlatStructureElement from a bool image. Image must be odd in all dimensions.

◆ GeneratePolygon() [1/3]

template<unsigned int VDimension>
static void itk::FlatStructuringElement< VDimension >::GeneratePolygon ( itk::FlatStructuringElement< 2 > &  res,
itk::Size< 2 >  radius,
unsigned  lines 
)
staticprivate

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

◆ GeneratePolygon() [2/3]

template<unsigned int VDimension>
static void itk::FlatStructuringElement< VDimension >::GeneratePolygon ( itk::FlatStructuringElement< 3 > &  res,
itk::Size< 3 >  radius,
unsigned  lines 
)
staticprivate

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

◆ GeneratePolygon() [3/3]

template<unsigned int VDimension>
template<typename TStructuringElement , typename TRadius >
static void itk::FlatStructuringElement< VDimension >::GeneratePolygon ( TStructuringElement &  res,
TRadius  radius,
unsigned  lines 
)
staticprivate

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

◆ GetDecomposable()

template<unsigned int VDimension>
bool itk::FlatStructuringElement< VDimension >::GetDecomposable ( ) const
inline

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 168 of file itkFlatStructuringElement.h.

Referenced by itk::KernelImageFilter< TImage, TImage, TKernel >::MakeKernel().

◆ GetLines()

template<unsigned int VDimension>
const DecompType& itk::FlatStructuringElement< VDimension >::GetLines ( ) const
inline

Return the lines associated with the structuring element

Definition at line 181 of file itkFlatStructuringElement.h.

◆ GetRadiusIsParametric()

template<unsigned int VDimension>
bool itk::FlatStructuringElement< VDimension >::GetRadiusIsParametric ( ) const
inline

The RadiusIsParametric mode ensures that the area of the foreground corresponds to the radius that was specified. This defaults to "off" for backward compatibility.

Definition at line 208 of file itkFlatStructuringElement.h.

◆ Polygon()

template<unsigned int VDimension>
static Self itk::FlatStructuringElement< VDimension >::Polygon ( RadiusType  radius,
unsigned  lines 
)
static

Create a polygon structuring element. The structuring element is is decomposable. lines is the number of elements in the decomposition

◆ PrintSelf()

template<unsigned int VDimension>
void itk::FlatStructuringElement< VDimension >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
overrideprotectedvirtual

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Reimplemented from itk::Neighborhood< bool, VDimension >.

◆ RadiusIsParametricOff()

template<unsigned int VDimension>
virtual void itk::FlatStructuringElement< VDimension >::RadiusIsParametricOff ( )
virtual

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

◆ RadiusIsParametricOn()

template<unsigned int VDimension>
virtual void itk::FlatStructuringElement< VDimension >::RadiusIsParametricOn ( )
virtual

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

◆ SetDecomposable()

template<unsigned int VDimension>
void itk::FlatStructuringElement< VDimension >::SetDecomposable ( bool  v)
inline

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 173 of file itkFlatStructuringElement.h.

◆ SetRadiusIsParametric()

template<unsigned int VDimension>
void itk::FlatStructuringElement< VDimension >::SetRadiusIsParametric ( bool  flag)
inline

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 213 of file itkFlatStructuringElement.h.

Member Data Documentation

◆ m_Decomposable

template<unsigned int VDimension>
bool itk::FlatStructuringElement< VDimension >::m_Decomposable
private

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 230 of file itkFlatStructuringElement.h.

◆ m_Lines

template<unsigned int VDimension>
DecompType itk::FlatStructuringElement< VDimension >::m_Lines
private

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 232 of file itkFlatStructuringElement.h.

◆ m_RadiusIsParametric

template<unsigned int VDimension>
bool itk::FlatStructuringElement< VDimension >::m_RadiusIsParametric
private

Returns whether the structuring element is decomposable or not. If the structuring is decomposable, the set of lines associated with the structuring may be used by an algorithm instead of the standard buffer.

Definition at line 252 of file itkFlatStructuringElement.h.

◆ NeighborhoodDimension

template<unsigned int VDimension>
constexpr unsigned int itk::FlatStructuringElement< VDimension >::NeighborhoodDimension = VDimension
staticconstexpr

External support for dimensionality.

Definition at line 115 of file itkFlatStructuringElement.h.


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