Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkScalarImageKmeansImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkScalarImageKmeansImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/06/16 14:02:18 $
00007   Version:   $Revision: 1.3 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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 );
00132 
00134   void SetImageRegion( const ImageRegionType & region );
00135   
00137   itkGetConstReferenceMacro( ImageRegion, ImageRegionType );
00138   
00139 protected:
00140   ScalarImageKmeansImageFilter();
00141   virtual ~ScalarImageKmeansImageFilter() {}
00142   void PrintSelf(std::ostream& os, Indent indent) const;
00143 
00149   void GenerateData();
00150 
00151 private:
00152   ScalarImageKmeansImageFilter(const Self&); //purposely not implemented
00153   void operator=(const Self&); //purposely not implemented
00154 
00155   typedef std::vector< RealPixelType > MeansContainer;
00156 
00157   MeansContainer  m_InitialMeans;
00158 
00159   ParametersType  m_FinalMeans;
00160 
00161   bool m_UseNonContiguousLabels;
00162 
00163   ImageRegionType m_ImageRegion;
00164 
00165   bool m_ImageRegionDefined;
00166 };
00167   
00168 } // end namespace itk
00169 
00170 #ifndef ITK_MANUAL_INSTANTIATION
00171 #include "itkScalarImageKmeansImageFilter.txx"
00172 #endif
00173 
00174 #endif

Generated at Wed May 24 23:59:56 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000