ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkScalarImageToRunLengthMatrixFilter.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 __itkScalarImageToRunLengthMatrixFilter_h
00019 #define __itkScalarImageToRunLengthMatrixFilter_h
00020 
00021 #include "itkImage.h"
00022 #include "itkHistogram.h"
00023 #include "itkNumericTraits.h"
00024 #include "itkVectorContainer.h"
00025 
00026 namespace itk
00027 {
00028 namespace Statistics
00029 {
00030 
00104 template<class TImageType, class THistogramFrequencyContainer =
00105   DenseFrequencyContainer2>
00106 class ScalarImageToRunLengthMatrixFilter : public ProcessObject
00107 {
00108 public:
00110   typedef ScalarImageToRunLengthMatrixFilter  Self;
00111   typedef ProcessObject                       Superclass;
00112   typedef SmartPointer<Self>                  Pointer;
00113   typedef SmartPointer<const Self>            ConstPointer;
00114 
00116   itkTypeMacro( ScalarImageToRunLengthMatrixFilter, ProcessObject );
00117 
00119   itkNewMacro( Self );
00120 
00121   typedef TImageType                                      ImageType;
00122   typedef typename ImageType::Pointer                     ImagePointer;
00123   typedef typename ImageType::ConstPointer                ImageConstPointer;
00124   typedef typename ImageType::PixelType                   PixelType;
00125   typedef typename ImageType::IndexType                   IndexType;
00126   typedef typename ImageType::RegionType                  RegionType;
00127   typedef typename ImageType::SizeType                    RadiusType;
00128   typedef typename ImageType::OffsetType                  OffsetType;
00129   typedef VectorContainer<unsigned char, OffsetType>      OffsetVector;
00130   typedef typename OffsetVector::Pointer                  OffsetVectorPointer;
00131   typedef typename ImageType::PointType                   PointType;
00132 
00133   typedef typename NumericTraits<PixelType>::RealType     MeasurementType;
00134   typedef typename NumericTraits<PixelType>::RealType     RealType;
00135 
00136   typedef Histogram<MeasurementType, THistogramFrequencyContainer>
00137                                                           HistogramType;
00138   typedef typename HistogramType::Pointer                 HistogramPointer;
00139   typedef typename HistogramType::ConstPointer            HistogramConstPointer;
00140   typedef typename HistogramType::MeasurementVectorType   MeasurementVectorType;
00141 
00143   itkStaticConstMacro( ImageDimension, unsigned int,
00144     TImageType::ImageDimension );
00145 
00147   itkStaticConstMacro( DefaultBinsPerAxis, unsigned int, 256 );
00148 
00158   itkSetObjectMacro( Offsets, OffsetVector );
00159 
00169   void SetOffset( const OffsetType offset );
00170 
00174   itkGetConstObjectMacro( Offsets, OffsetVector );
00175 
00177   itkSetMacro( NumberOfBinsPerAxis, unsigned int );
00178 
00180   itkGetConstMacro( NumberOfBinsPerAxis, unsigned int );
00181 
00186   void SetPixelValueMinMax( PixelType min, PixelType max );
00187 
00189   itkGetConstMacro( Min, PixelType );
00190 
00192   itkGetConstMacro( Max, PixelType );
00193 
00198   void SetDistanceValueMinMax( RealType min, RealType max );
00199 
00203   itkGetConstMacro( MinDistance, RealType );
00204 
00208   itkGetConstMacro( MaxDistance, RealType );
00209 
00211   using Superclass::SetInput;
00212   void SetInput( const ImageType *image );
00213 
00215   const ImageType * GetInput() const;
00216 
00218   void SetMaskImage( const ImageType *image );
00219 
00221   const ImageType * GetMaskImage() const;
00222 
00224   const HistogramType * GetOutput() const;
00225 
00230   itkSetMacro( InsidePixelValue, PixelType );
00231   itkGetConstMacro( InsidePixelValue, PixelType );
00233 
00234 protected:
00235   ScalarImageToRunLengthMatrixFilter();
00236   virtual ~ScalarImageToRunLengthMatrixFilter() {};
00237   void PrintSelf( std::ostream& os, Indent indent ) const;
00238 
00240   typedef DataObject::Pointer DataObjectPointer;
00241 
00242   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00243   using Superclass::MakeOutput;
00244   virtual DataObjectPointer MakeOutput( DataObjectPointerArraySizeType idx );
00245 
00247   virtual void GenerateData();
00248 
00256   void NormalizeOffsetDirection(OffsetType &offset);
00257 
00258 private:
00259 
00260   unsigned int             m_NumberOfBinsPerAxis;
00261   PixelType                m_Min;
00262   PixelType                m_Max;
00263   RealType                 m_MinDistance;
00264   RealType                 m_MaxDistance;
00265   PixelType                m_InsidePixelValue;
00266 
00267   MeasurementVectorType    m_LowerBound;
00268   MeasurementVectorType    m_UpperBound;
00269   OffsetVectorPointer      m_Offsets;
00270 
00271 };
00272 } // end of namespace Statistics
00273 } // end of namespace itk
00274 
00275 #ifndef ITK_MANUAL_INSTANTIATION
00276 #include "itkScalarImageToRunLengthMatrixFilter.hxx"
00277 #endif
00278 
00279 #endif
00280