Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkShapeOpeningLabelMapFilter_h
00018 #define __itkShapeOpeningLabelMapFilter_h
00019
00020 #include "itkInPlaceLabelMapFilter.h"
00021 #include "itkLabelObjectAccessors.h"
00022 #include "itkShapeLabelObjectAccessors.h"
00023 #include "itkProgressReporter.h"
00024
00025 namespace itk {
00042 template<class TImage>
00043 class ITK_EXPORT ShapeOpeningLabelMapFilter :
00044 public InPlaceLabelMapFilter<TImage>
00045 {
00046 public:
00048 typedef ShapeOpeningLabelMapFilter Self;
00049 typedef InPlaceLabelMapFilter<TImage> Superclass;
00050 typedef SmartPointer<Self> Pointer;
00051 typedef SmartPointer<const Self> ConstPointer;
00052
00054 typedef TImage ImageType;
00055 typedef typename ImageType::Pointer ImagePointer;
00056 typedef typename ImageType::ConstPointer ImageConstPointer;
00057 typedef typename ImageType::PixelType PixelType;
00058 typedef typename ImageType::IndexType IndexType;
00059 typedef typename ImageType::LabelObjectType LabelObjectType;
00060
00061 typedef typename LabelObjectType::AttributeType AttributeType;
00062
00064 itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
00065
00067 itkNewMacro(Self);
00068
00070 itkTypeMacro(ShapeOpeningLabelMapFilter, InPlaceLabelMapFilter);
00071
00072 #ifdef ITK_USE_CONCEPT_CHECKING
00073
00074
00075
00076
00077
00078
00079
00080
00082 #endif
00083
00087 itkGetConstMacro(Lambda, double);
00088 itkSetMacro(Lambda, double);
00090
00097 itkGetConstMacro( ReverseOrdering, bool );
00098 itkSetMacro( ReverseOrdering, bool );
00099 itkBooleanMacro( ReverseOrdering );
00101
00106 itkGetConstMacro( Attribute, AttributeType );
00107 itkSetMacro( Attribute, AttributeType );
00108 void SetAttribute( const std::string & s )
00109 {
00110 this->SetAttribute( LabelObjectType::GetAttributeFromName( s ) );
00111 }
00113
00114
00115 protected:
00116 ShapeOpeningLabelMapFilter();
00117 ~ShapeOpeningLabelMapFilter() {};
00118
00119 void GenerateData();
00120
00121 template <class TAttributeAccessor>
00122 void TemplatedGenerateData( const TAttributeAccessor & accessor )
00123 {
00124
00125 this->AllocateOutputs();
00126
00127 ImageType * output = this->GetOutput();
00128 ImageType * output2 = this->GetOutput( 1 );
00129 assert( this->GetNumberOfOutputs() == 2 );
00130 assert( output2 != NULL );
00131
00132
00133 output2->SetBackgroundValue( output->GetBackgroundValue() );
00134
00135 const typename ImageType::LabelObjectContainerType & labelObjectContainer = output->GetLabelObjectContainer();
00136
00137 ProgressReporter progress( this, 0, labelObjectContainer.size() );
00138
00139 typename ImageType::LabelObjectContainerType::const_iterator it = labelObjectContainer.begin();
00140 while( it != labelObjectContainer.end() )
00141 {
00142 typename LabelObjectType::LabelType label = it->first;
00143 LabelObjectType * labelObject = it->second;
00144
00145 if( ( !m_ReverseOrdering && accessor( labelObject ) < m_Lambda )
00146 || ( m_ReverseOrdering && accessor( labelObject ) > m_Lambda ) )
00147 {
00148
00149 it++;
00150 output2->AddLabelObject( labelObject );
00151 output->RemoveLabel( label );
00152 }
00153 else
00154 {
00155 it++;
00156 }
00157
00158 progress.CompletedPixel();
00159 }
00160 }
00161
00162 void PrintSelf(std::ostream& os, Indent indent) const;
00163
00164 double m_Lambda;
00165 bool m_ReverseOrdering;
00166 AttributeType m_Attribute;
00167
00168 private:
00169 ShapeOpeningLabelMapFilter(const Self&);
00170 void operator=(const Self&);
00171
00172 };
00173
00174 }
00175
00176 #ifndef ITK_MANUAL_INSTANTIATION
00177 #include "itkShapeOpeningLabelMapFilter.txx"
00178 #endif
00179
00180 #endif
00181