itkScalarImageKmeansImageFilter.h
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 __itkScalarImageKmeansImageFilter_h
00018 #define __itkScalarImageKmeansImageFilter_h
00019
00020 #include "itkImageToImageFilter.h"
00021 #include "itkImage.h"
00022 #include "itkNumericTraits.h"
00023
00024 #include "itkKdTree.h"
00025 #include "itkKdTreeBasedKmeansEstimator.h"
00026 #include "itkWeightedCentroidKdTreeGenerator.h"
00027
00028 #include "itkMinimumDecisionRule.h"
00029 #include "itkEuclideanDistance.h"
00030 #include "itkSampleClassifier.h"
00031
00032 #include "itkScalarImageToListAdaptor.h"
00033 #include "itkImageRegion.h"
00034 #include "itkRegionOfInterestImageFilter.h"
00035
00036 #include <vector>
00037
00038 namespace itk
00039 {
00061 template <class TInputImage >
00062 class ITK_EXPORT ScalarImageKmeansImageFilter :
00063 public ImageToImageFilter< TInputImage, Image<unsigned char,
00064 ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00065 {
00066 public:
00068 itkStaticConstMacro(ImageDimension, unsigned int,
00069 TInputImage::ImageDimension);
00070
00072 typedef TInputImage InputImageType;
00073 typedef Image<unsigned char,
00074 ::itk::GetImageDimension<TInputImage>::ImageDimension> OutputImageType;
00075
00077 typedef ScalarImageKmeansImageFilter Self;
00078 typedef ImageToImageFilter< InputImageType, OutputImageType> Superclass;
00079 typedef SmartPointer<Self> Pointer;
00080 typedef SmartPointer<const Self> ConstPointer;
00081
00083 itkNewMacro(Self);
00084
00086 itkTypeMacro(ScalarImageKmeansImageFilter, ImageToImageFilter);
00087
00089 typedef typename InputImageType::PixelType InputPixelType;
00090 typedef typename OutputImageType::PixelType OutputPixelType;
00091
00093 typedef typename NumericTraits< InputPixelType >::RealType RealPixelType;
00094
00096 typedef itk::Statistics::ScalarImageToListAdaptor<
00097 InputImageType > AdaptorType;
00098
00100 typedef typename AdaptorType::MeasurementVectorType MeasurementVectorType;
00101
00103 typedef itk::Statistics::WeightedCentroidKdTreeGenerator<
00104 AdaptorType >
00105 TreeGeneratorType;
00106 typedef typename TreeGeneratorType::KdTreeType TreeType;
00107 typedef itk::Statistics::KdTreeBasedKmeansEstimator<TreeType> EstimatorType;
00108
00109 typedef typename EstimatorType::ParametersType ParametersType;
00110
00111 typedef typename InputImageType::RegionType ImageRegionType;
00112
00113 typedef RegionOfInterestImageFilter<
00114 InputImageType,
00115 InputImageType > RegionOfInterestFilterType;
00116
00117
00119 void AddClassWithInitialMean( RealPixelType mean );
00120
00122 itkGetConstReferenceMacro( FinalMeans, ParametersType );
00123
00129 itkSetMacro( UseNonContiguousLabels, bool );
00130 itkGetConstReferenceMacro( UseNonContiguousLabels, bool );
00131 itkBooleanMacro( UseNonContiguousLabels );
00133
00135 void SetImageRegion( const ImageRegionType & region );
00136
00138 itkGetConstReferenceMacro( ImageRegion, ImageRegionType );
00139
00140 #ifdef ITK_USE_CONCEPT_CHECKING
00141
00142 itkConceptMacro(InputHasNumericTraitsCheck,
00143 (Concept::HasNumericTraits<InputPixelType>));
00144
00146 #endif
00147
00148 protected:
00149 ScalarImageKmeansImageFilter();
00150 virtual ~ScalarImageKmeansImageFilter() {}
00151 void PrintSelf(std::ostream& os, Indent indent) const;
00152
00158 void GenerateData();
00159
00160 private:
00161 ScalarImageKmeansImageFilter(const Self&);
00162 void operator=(const Self&);
00163
00164 typedef std::vector< RealPixelType > MeansContainer;
00165
00166 MeansContainer m_InitialMeans;
00167
00168 ParametersType m_FinalMeans;
00169
00170 bool m_UseNonContiguousLabels;
00171
00172 ImageRegionType m_ImageRegion;
00173
00174 bool m_ImageRegionDefined;
00175 };
00176
00177 }
00178
00179 #ifndef ITK_MANUAL_INSTANTIATION
00180 #include "itkScalarImageKmeansImageFilter.txx"
00181 #endif
00182
00183 #endif
00184