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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkConnectedComponentFunctorImageFilter.h,v $
Language: C++
Date: $Date: 2006-03-24 16:03:17 $
Version: $Revision: 1.4 $
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 __itkConnectedComponentFunctorImageFilter_h
#define __itkConnectedComponentFunctorImageFilter_h
#include "itkConnectedComponentImageFilter.h"
#include "itkImage.h"
namespace itk
{
/**
* \class ConnectedComponentFunctorImageFilter
* \brief A generic connected components filter that labels the
* objects in an artibitrary image.
*
* ConnectedComponentFunctorImageFilter labels the objects in an arbitrary
* image. Each distinct object is assigned a unique label. The filter makes
* three passes through the image. The first pass initializes the
* output. The second pass labels each foreground pixel such that all
* the pixels associated with an object either have the same label or
* have had their labels entered into a equivalency table. The third
* pass through the image flattens the equivalency table such that all
* pixels for an object have the same label.
*
* The functor specifies the criteria to join neighboring pixels. For
* example a simple intensity threshold difference might be used for
* scalar imagery.
*
* The final object labels are in no particular order (and some object
* labels may not be used on the final objects). You can reorder the
* labels such that object labels are consecutive and sorted based on
* object size by passing the output of this filter to a
* RelabelComponentImageFilter.
*
* \sa ImageToImageFilter
*/
template <class TInputImage, class TOutputImage, class TFunctor, class TMaskImage=TInputImage>
class ITK_EXPORT ConnectedComponentFunctorImageFilter :
public ConnectedComponentImageFilter< TInputImage, TOutputImage, TMaskImage >
{
public:
/**
* Standard "Self" & Superclass typedef.
*/
typedef ConnectedComponentFunctorImageFilter Self;
typedef ConnectedComponentImageFilter< TInputImage, TOutputImage, TMaskImage > Superclass;
/**
* Types from the Superclass
*/
typedef typename Superclass::InputImagePointer InputImagePointer;
/**
* Extract some information from the image types. Dimensionality
* of the two images is assumed to be the same.
*/
typedef typename TOutputImage::PixelType OutputPixelType;
typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
typedef typename TInputImage::PixelType InputPixelType;
typedef typename TInputImage::InternalPixelType InputInternalPixelType;
typedef typename TMaskImage::PixelType MaskPixelType;
itkStaticConstMacro(ImageDimension, unsigned int,
TOutputImage::ImageDimension);
itkStaticConstMacro(InputImageDimension, unsigned int,
TInputImage::ImageDimension);
/**
* Image typedef support
*/
typedef TFunctor FunctorType;
typedef TInputImage InputImageType;
typedef TMaskImage MaskImageType;
typedef TOutputImage OutputImageType;
typedef typename TInputImage::IndexType IndexType;
typedef typename TInputImage::SizeType SizeType;
typedef typename TOutputImage::RegionType RegionType;
typedef std::list<IndexType> ListType;
typedef typename MaskImageType::Pointer MaskImagePointer;
/**
* Smart pointer typedef support
*/
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/**
* Run-time type information (and related methods)
*/
itkTypeMacro(ConnectedComponentFunctorImageFilter, ImageToImageFilter);
/**
* Method for creation through the object factory.
*/
itkNewMacro(Self);
/** Get the functor object. The functor is returned by reference.
* (Functors do not have to derive from itk::LightObject, so they do
* not necessarily have a reference count. So we cannot return a
* SmartPointer.) */
FunctorType& GetFunctor() { return m_Functor; };
const FunctorType& GetFunctor() const { return m_Functor; };
/** Set the functor object. This replaces the current Functor with a
* copy of the specified Functor. This allows the user to specify a
* functor that has ivars set differently than the default functor.
* This method requires an operator!=() be defined on the functor
* (or the compiler's default implementation of operator!=() being
* appropriate). */
void SetFunctor(const FunctorType& functor)
{
m_Functor = functor;
this->Modified();
}
#ifdef ITK_USE_CONCEPT_CHECKING
/** Begin concept checking */
itkConceptMacro(SameDimensionCheck,
(Concept::SameDimension<InputImageDimension, ImageDimension>));
itkConceptMacro(InputEqualityComparableCheck,
(Concept::EqualityComparable<InputPixelType>));
itkConceptMacro(OutputEqualityComparableCheck,
(Concept::EqualityComparable<OutputPixelType>));
itkConceptMacro(OutputConvertibleToUnsignedIntCheck,
(Concept::Convertible<OutputPixelType, unsigned int>));
itkConceptMacro(OutputConvertibleToUnsignedLongCheck,
(Concept::Convertible<OutputPixelType, unsigned long>));
itkConceptMacro(OutputConvertibleToLongCheck,
(Concept::Convertible<OutputPixelType, long>));
itkConceptMacro(UnsignedLongConvertibleToOutputCheck,
(Concept::Convertible<unsigned long, OutputPixelType>));
itkConceptMacro(OutputIncrementDecrementOperatorsCheck,
(Concept::IncrementDecrementOperators<OutputPixelType>));
/** End concept checking */
#endif
protected:
ConnectedComponentFunctorImageFilter() {}
virtual ~ConnectedComponentFunctorImageFilter() {}
ConnectedComponentFunctorImageFilter(const Self&) {}
FunctorType m_Functor;
/**
* Standard pipeline method.
*/
void GenerateData();
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkConnectedComponentFunctorImageFilter.txx"
#endif
#endif
|