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: 2010-01-31 19:29:05 $
00007   Version:   $Revision: 1.7 $
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 #ifdef ITK_USE_REVIEW_STATISTICS
00029 #include "itkEuclideanDistanceMetric.h"
00030 #include "itkSampleClassifierFilter.h"
00031 #include "itkImageToListSampleAdaptor.h"
00032 #include "itkMinimumDecisionRule2.h"
00033 #else
00034 #include "itkMinimumDecisionRule.h"
00035 #include "itkEuclideanDistance.h"
00036 #include "itkSampleClassifier.h"
00037 #include "itkScalarImageToListAdaptor.h"
00038 #endif
00039 
00040 #include "itkImageRegion.h"
00041 #include "itkRegionOfInterestImageFilter.h"
00042 
00043 #include <vector>
00044 
00045 namespace itk
00046 {
00068 template <class TInputImage,
00069           class TOutputImage=Image<unsigned char, ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00070 class ITK_EXPORT ScalarImageKmeansImageFilter :
00071     public ImageToImageFilter< TInputImage, TOutputImage >
00072 {
00073 public:
00075   itkStaticConstMacro(ImageDimension, unsigned int,
00076                       TInputImage::ImageDimension);
00077 
00079   typedef TInputImage  InputImageType;
00080   typedef TOutputImage OutputImageType;
00081 
00083   typedef ScalarImageKmeansImageFilter                         Self;
00084   typedef ImageToImageFilter< InputImageType, OutputImageType> Superclass;
00085   typedef SmartPointer<Self>                                   Pointer;
00086   typedef SmartPointer<const Self>                             ConstPointer;
00087 
00089   itkNewMacro(Self);
00090 
00092   itkTypeMacro(ScalarImageKmeansImageFilter, ImageToImageFilter);
00093 
00095   typedef typename InputImageType::PixelType  InputPixelType;
00096   typedef typename OutputImageType::PixelType OutputPixelType;
00097 
00099   typedef typename NumericTraits< InputPixelType >::RealType RealPixelType;
00100 
00102 #ifdef ITK_USE_REVIEW_STATISTICS
00103   typedef itk::Statistics::ImageToListSampleAdaptor< InputImageType > AdaptorType;
00104 #else
00105   typedef itk::Statistics::ScalarImageToListAdaptor< 
00106                                    InputImageType > AdaptorType;
00107 #endif  
00108 
00110   typedef typename AdaptorType::MeasurementVectorType  MeasurementVectorType;
00111 
00112 #ifdef ITK_USE_REVIEW_STATISTICS
00113   typedef itk::Statistics::DistanceToCentroidMembershipFunction< MeasurementVectorType > MembershipFunctionType;
00114   typedef itk::Statistics::SampleClassifierFilter< AdaptorType > ClassifierType;
00115   typedef itk::Statistics::MinimumDecisionRule2                  DecisionRuleType;
00116 #else
00117   typedef itk::Statistics::EuclideanDistance< MeasurementVectorType > MembershipFunctionType;
00118   typedef itk::Statistics::SampleClassifier< AdaptorType > ClassifierType;
00119   typedef itk::MinimumDecisionRule                         DecisionRuleType;
00120 #endif
00121 
00122 #ifdef ITK_USE_REVIEW_STATISTICS
00123   typedef typename ClassifierType::ClassLabelVectorType ClassLabelVectorType;
00124 #else
00125   typedef std::vector< unsigned int > ClassLabelVectorType;
00126 #endif
00127   
00128 #ifdef ITK_USE_REVIEW_STATISTICS
00129   typedef typename ClassifierType::MembershipFunctionVectorType MembershipFunctionVectorType;
00130   typedef typename MembershipFunctionType::CentroidType  MembershipFunctionOriginType;
00131 #else
00132   typedef typename MembershipFunctionType::OriginType  MembershipFunctionOriginType;
00133 #endif
00134   
00135   typedef typename MembershipFunctionType::Pointer     MembershipFunctionPointer;
00136   
00138   typedef itk::Statistics::WeightedCentroidKdTreeGenerator< 
00139                                                       AdaptorType > 
00140                                                                 TreeGeneratorType;
00141   typedef typename TreeGeneratorType::KdTreeType                TreeType;
00142   typedef itk::Statistics::KdTreeBasedKmeansEstimator<TreeType> EstimatorType;
00143 
00144   typedef typename EstimatorType::ParametersType ParametersType;
00145 
00146   typedef typename InputImageType::RegionType        ImageRegionType;
00147   
00148   typedef RegionOfInterestImageFilter< 
00149                                  InputImageType,
00150                                  InputImageType  > RegionOfInterestFilterType;
00151 
00152 
00154   void AddClassWithInitialMean( RealPixelType mean );
00155 
00157   itkGetConstReferenceMacro( FinalMeans, ParametersType );
00158 
00164   itkSetMacro( UseNonContiguousLabels, bool );
00165   itkGetConstReferenceMacro( UseNonContiguousLabels, bool );
00166   itkBooleanMacro( UseNonContiguousLabels );
00168 
00170   void SetImageRegion( const ImageRegionType & region );
00171 
00173   itkGetConstReferenceMacro( ImageRegion, ImageRegionType );
00174 
00175 #ifdef ITK_USE_CONCEPT_CHECKING
00176 
00177   itkConceptMacro(InputHasNumericTraitsCheck,
00178                   (Concept::HasNumericTraits<InputPixelType>));
00179 
00181 #endif
00182 
00183 protected:
00184   ScalarImageKmeansImageFilter();
00185   virtual ~ScalarImageKmeansImageFilter() {}
00186   void PrintSelf(std::ostream& os, Indent indent) const;
00187 
00193   void GenerateData();
00194 
00195 private:
00196   ScalarImageKmeansImageFilter(const Self&); //purposely not implemented
00197   void operator=(const Self&); //purposely not implemented
00198 
00199   typedef std::vector< RealPixelType > MeansContainer;
00200 
00201   MeansContainer  m_InitialMeans;
00202 
00203   ParametersType  m_FinalMeans;
00204 
00205   bool m_UseNonContiguousLabels;
00206 
00207   ImageRegionType m_ImageRegion;
00208 
00209   bool m_ImageRegionDefined;
00210 };
00211   
00212 } // end namespace itk
00213 
00214 #ifndef ITK_MANUAL_INSTANTIATION
00215 #include "itkScalarImageKmeansImageFilter.txx"
00216 #endif
00217 
00218 #endif
00219 

Generated at Mon Jul 12 2010 19:45:07 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000