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: 2004/11/19 22:34:49 $
00007   Version:   $Revision: 1.2 $
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 
00034 #include <vector>
00035 
00036 namespace itk
00037 {
00059 template <class TInputImage >
00060 class ITK_EXPORT ScalarImageKmeansImageFilter :
00061     public ImageToImageFilter< TInputImage, Image<unsigned char,
00062              ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00063 {
00064 public:
00066   itkStaticConstMacro(ImageDimension, unsigned int,
00067                       TInputImage::ImageDimension);
00068 
00070   typedef TInputImage InputImageType;
00071   typedef Image<unsigned char,
00072              ::itk::GetImageDimension<TInputImage>::ImageDimension> OutputImageType;
00073 
00075   typedef ScalarImageKmeansImageFilter Self;
00076   typedef ImageToImageFilter< InputImageType, OutputImageType> Superclass;
00077   typedef SmartPointer<Self> Pointer;
00078   typedef SmartPointer<const Self>  ConstPointer;
00079 
00081   itkNewMacro(Self);
00082 
00084   itkTypeMacro(ScalarImageKmeansImageFilter, ImageToImageFilter);
00085   
00087   typedef typename InputImageType::PixelType InputPixelType;
00088   typedef typename OutputImageType::PixelType OutputPixelType;
00089 
00091   typedef typename NumericTraits< InputPixelType >::RealType RealPixelType;
00092   
00094   typedef itk::Statistics::ScalarImageToListAdaptor< 
00095                                    InputImageType > AdaptorType;
00096  
00098   typedef typename AdaptorType::MeasurementVectorType  MeasurementVectorType;
00099 
00101   typedef itk::Statistics::WeightedCentroidKdTreeGenerator< 
00102                                                       AdaptorType > 
00103                                                               TreeGeneratorType;
00104   typedef typename TreeGeneratorType::KdTreeType TreeType;
00105   typedef itk::Statistics::KdTreeBasedKmeansEstimator<TreeType> EstimatorType;
00106 
00107   typedef typename EstimatorType::ParametersType ParametersType;
00108 
00109 
00111   void AddClassWithInitialMean( RealPixelType mean );
00112 
00114   itkGetConstReferenceMacro( FinalMeans, ParametersType );
00115 
00121   itkSetMacro( UseNonContiguousLabels, bool );
00122   itkGetConstReferenceMacro( UseNonContiguousLabels, bool );
00123   itkBooleanMacro( UseNonContiguousLabels );
00124   
00125 protected:
00126   ScalarImageKmeansImageFilter();
00127   virtual ~ScalarImageKmeansImageFilter() {}
00128   void PrintSelf(std::ostream& os, Indent indent) const;
00129 
00135   void GenerateData();
00136 
00137 private:
00138   ScalarImageKmeansImageFilter(const Self&); //purposely not implemented
00139   void operator=(const Self&); //purposely not implemented
00140 
00141   typedef std::vector< RealPixelType > MeansContainer;
00142 
00143   MeansContainer  m_InitialMeans;
00144 
00145   ParametersType  m_FinalMeans;
00146 
00147   bool m_UseNonContiguousLabels;
00148 };
00149   
00150 } // end namespace itk
00151 
00152 #ifndef ITK_MANUAL_INSTANTIATION
00153 #include "itkScalarImageKmeansImageFilter.txx"
00154 #endif
00155 
00156 #endif

Generated at Wed Mar 30 00:09:26 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000