1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkBinaryMorphologicalClosingImageFilter.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkBinaryMorphologicalClosingImageFilter_h
#define __itkBinaryMorphologicalClosingImageFilter_h
#include "itkKernelImageFilter.h"
namespace itk {
/**
* \class BinaryMorphologicalClosingImageFilter
* \brief binary morphological closing of an image.
*
* This filter removes small (i.e., smaller than the structuring
* element) holes and tube like structures in the interior or at the
* boundaries of the image. The morphological closing of an image
* "f" is defined as:
* Closing(f) = Erosion(Dilation(f)).
*
* The structuring element is assumed to be composed of binary
* values (zero or one). Only elements of the structuring element
* having values > 0 are candidates for affecting the center pixel.
*
*
* \author Gaetan Lehmann. Biologie du Developpement et de la Reproduction, INRA de Jouy-en-Josas, France.
*
* \sa MorphologyImageFilter, GrayscaleDilateImageFilter, GrayscaleErodeImageFilter
* \ingroup ImageEnhancement MathematicalMorphologyImageFilters
*/
template<class TInputImage, class TOutputImage, class TKernel>
class ITK_EXPORT BinaryMorphologicalClosingImageFilter :
public KernelImageFilter<TInputImage, TOutputImage, TKernel>
{
public:
/** Standard class typedefs. */
typedef BinaryMorphologicalClosingImageFilter Self;
typedef KernelImageFilter<TInputImage, TOutputImage, TKernel> Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Standard New method. */
itkNewMacro(Self);
/** Runtime information support. */
itkTypeMacro(BinaryMorphologicalClosingImageFilter,
KernelImageFilter);
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef typename InputImageType::Pointer InputImagePointer;
typedef typename OutputImageType::RegionType OutputImageRegionType;
/** Declaration of pixel type. */
typedef typename TInputImage::PixelType InputPixelType;
typedef typename TInputImage::PixelType OutputPixelType;
/** Kernel typedef. */
typedef TKernel KernelType;
/** Set the value in the image to consider as "foreground". Defaults to
* maximum value of InputPixelType. */
itkSetMacro(ForegroundValue, InputPixelType);
/** Get the value in the image considered as "foreground". Defaults to
* maximum value of InputPixelType. */
itkGetConstMacro(ForegroundValue, InputPixelType);
/** A safe border is added to input image to avoid borders effects
* and remove it once the closing is done */
itkSetMacro(SafeBorder, bool);
itkGetConstReferenceMacro(SafeBorder, bool);
itkBooleanMacro(SafeBorder);
protected:
BinaryMorphologicalClosingImageFilter();
~BinaryMorphologicalClosingImageFilter() {};
void PrintSelf(std::ostream& os, Indent indent) const;
/** Single-threaded version of GenerateData. This filter delegates
* to GrayscaleDilateImageFilter GrayscaleErodeImageFilter. */
void GenerateData ();
private:
BinaryMorphologicalClosingImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
InputPixelType m_ForegroundValue;
bool m_SafeBorder;
}; // end of class
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkBinaryMorphologicalClosingImageFilter.txx"
#endif
#endif
|