ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkScalarImageToRunLengthFeaturesFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkScalarImageToRunLengthFeaturesFilter_h
00019 #define __itkScalarImageToRunLengthFeaturesFilter_h
00020 
00021 #include "itkDataObjectDecorator.h"
00022 
00023 #include "itkHistogramToRunLengthFeaturesFilter.h"
00024 #include "itkScalarImageToRunLengthMatrixFilter.h"
00025 
00026 namespace itk
00027 {
00028 namespace Statistics
00029 {
00094 template< class TImageType,
00095           class THistogramFrequencyContainer = DenseFrequencyContainer2 >
00096 class ITK_EXPORT ScalarImageToRunLengthFeaturesFilter:public ProcessObject
00097 {
00098 public:
00100   typedef ScalarImageToRunLengthFeaturesFilter  Self;
00101   typedef ProcessObject                         Superclass;
00102   typedef SmartPointer< Self >                  Pointer;
00103   typedef SmartPointer< const Self >            ConstPointer;
00104 
00106   itkTypeMacro(ScalarImageToRunLengthFeaturesFilter, ProcessObject);
00107 
00109   itkNewMacro(Self);
00110 
00111   typedef THistogramFrequencyContainer FrequencyContainerType;
00112   typedef TImageType                   ImageType;
00113   typedef typename ImageType::Pointer  ImagePointer;
00114 
00115   typedef typename ImageType::PixelType                PixelType;
00116   typedef typename ImageType::OffsetType               OffsetType;
00117   typedef VectorContainer< unsigned char, OffsetType > OffsetVector;
00118   typedef typename OffsetVector::Pointer               OffsetVectorPointer;
00119   typedef typename OffsetVector::ConstPointer          OffsetVectorConstPointer;
00120 
00121   typedef ScalarImageToRunLengthMatrixFilter<
00122     ImageType, FrequencyContainerType >               RunLengthMatrixFilterType;
00123 
00124   typedef typename RunLengthMatrixFilterType::HistogramType
00125   HistogramType;
00126 
00127   typedef HistogramToRunLengthFeaturesFilter< HistogramType >
00128   RunLengthFeaturesFilterType;
00129 
00130   typedef short                                    RunLengthFeatureName;
00131   typedef VectorContainer<unsigned char,
00132     RunLengthFeatureName>                          FeatureNameVector;
00133   typedef typename FeatureNameVector::Pointer      FeatureNameVectorPointer;
00134   typedef typename FeatureNameVector::ConstPointer FeatureNameVectorConstPointer;
00135   typedef VectorContainer< unsigned char, double > FeatureValueVector;
00136   typedef typename FeatureValueVector::Pointer     FeatureValueVectorPointer;
00137 
00139   typedef DataObject::Pointer DataObjectPointer;
00140 
00142   typedef DataObjectDecorator< FeatureValueVector >
00143   FeatureValueVectorDataObjectType;
00144 
00145   const FeatureValueVectorDataObjectType * GetFeatureMeansOutput() const;
00146 
00147   const FeatureValueVectorDataObjectType * GetFeatureStandardDeviationsOutput()
00148     const;
00149 
00152   using Superclass::SetInput;
00153   void SetInput(const ImageType *);
00154 
00155   const ImageType * GetInput() const;
00156 
00158   itkGetConstReferenceObjectMacro(FeatureMeans, FeatureValueVector);
00159   itkGetConstReferenceObjectMacro(FeatureStandardDeviations, FeatureValueVector);
00161 
00163   itkSetConstObjectMacro(RequestedFeatures, FeatureNameVector);
00164   itkGetConstObjectMacro(RequestedFeatures, FeatureNameVector);
00166 
00169   itkSetConstObjectMacro(Offsets, OffsetVector);
00170   itkGetConstObjectMacro(Offsets, OffsetVector);
00172 
00175   void SetNumberOfBinsPerAxis(unsigned int);
00176 
00179   void SetPixelValueMinMax(PixelType min, PixelType max);
00181 
00184   void SetDistanceValueMinMax( double min, double max );
00186 
00189   void SetMaskImage(const ImageType *);
00190 
00191   const ImageType * GetMaskImage() const;
00192 
00195   void SetInsidePixelValue(PixelType InsidePixelValue);
00196 
00197   itkGetConstMacro(FastCalculations, bool);
00198   itkSetMacro(FastCalculations, bool);
00199   itkBooleanMacro(FastCalculations);
00200 protected:
00201   ScalarImageToRunLengthFeaturesFilter();
00202   virtual ~ScalarImageToRunLengthFeaturesFilter() {}
00203   void PrintSelf( std::ostream & os, Indent indent ) const;
00204 
00205   void FastCompute();
00206 
00207   void FullCompute();
00208 
00210   virtual void GenerateData();
00211 
00213   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00214   using Superclass::MakeOutput;
00215   virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType);
00216 
00217 private:
00218   typename RunLengthMatrixFilterType::Pointer m_RunLengthMatrixGenerator;
00219 
00220   FeatureValueVectorPointer     m_FeatureMeans;
00221   FeatureValueVectorPointer     m_FeatureStandardDeviations;
00222   FeatureNameVectorConstPointer m_RequestedFeatures;
00223   OffsetVectorConstPointer      m_Offsets;
00224   bool                          m_FastCalculations;
00225 };
00226 } // end of namespace Statistics
00227 } // end of namespace itk
00228 
00229 #ifndef ITK_MANUAL_INSTANTIATION
00230 #include "itkScalarImageToRunLengthFeaturesFilter.hxx"
00231 #endif
00232 
00233 #endif
00234