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

itkDeformationFieldJacobianDeterminantFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDeformationFieldJacobianDeterminantFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/08/24 18:00:04 $
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 __itkDeformationFieldJacobianDeterminantFilter_h
00018 #define __itkDeformationFieldJacobianDeterminantFilter_h
00019 
00020 #include "itkConstNeighborhoodIterator.h"
00021 #include "itkNeighborhoodIterator.h"
00022 #include "itkImageToImageFilter.h"
00023 #include "itkImage.h"
00024 #include "itkVector.h"
00025 #include "vnl/vnl_matrix.h"
00026 #include "vnl/vnl_det.h"
00027 
00028 namespace itk
00029 {
00115 template < typename TInputImage,
00116            typename TRealType = float,
00117            typename TOutputImage = Image< TRealType,
00118                                           ::itk::GetImageDimension<TInputImage>::ImageDimension >
00119 >
00120 class ITK_EXPORT DeformationFieldJacobianDeterminantFilter :
00121     public ImageToImageFilter< TInputImage, TOutputImage >
00122 {
00123 public:
00125   typedef DeformationFieldJacobianDeterminantFilter Self;
00126   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00127   typedef SmartPointer<Self> Pointer;
00128   typedef SmartPointer<const Self>  ConstPointer;
00129 
00131   itkNewMacro(Self);
00132 
00134   itkTypeMacro(DeformationFieldJacobianDeterminantFilter, ImageToImageFilter);
00135 
00138   typedef typename TOutputImage::PixelType OutputPixelType;
00139   typedef typename TInputImage::PixelType  InputPixelType;
00140 
00142   typedef TInputImage  InputImageType;
00143   typedef TOutputImage OutputImageType;
00144   typedef typename InputImageType::Pointer  InputImagePointer;
00145   typedef typename OutputImageType::Pointer OutputImagePointer;
00146 
00148   itkStaticConstMacro(ImageDimension, unsigned int,
00149                       TOutputImage::ImageDimension);
00150 
00152   itkStaticConstMacro(VectorDimension, unsigned int,
00153                       InputPixelType::Dimension);
00154 
00156   typedef TRealType RealType;
00157   typedef Vector<TRealType, ::itk::GetVectorDimension<InputPixelType>::VectorDimension> RealVectorType;
00158   typedef Image<RealVectorType, ::itk::GetImageDimension<TInputImage>::ImageDimension>  RealVectorImageType;
00159 
00160 
00163   typedef ConstNeighborhoodIterator<RealVectorImageType> ConstNeighborhoodIteratorType;
00164   typedef typename ConstNeighborhoodIteratorType::RadiusType RadiusType;  
00165 
00167   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00168 
00177   virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError);
00178 
00182   void SetUseImageSpacingOn()
00183   { this->SetUseImageSpacing(true); }
00184 
00188   void SetUseImageSpacingOff()
00189   { this->SetUseImageSpacing(false); }
00190 
00193   void SetUseImageSpacing(bool);                         
00194   itkGetMacro(UseImageSpacing, bool);
00196 
00199   void SetDerivativeWeights(TRealType data[]);
00200   itkGetVectorMacro(DerivativeWeights, const TRealType, itk::GetImageDimension<TInputImage>::ImageDimension);
00202 
00203 protected:
00204   DeformationFieldJacobianDeterminantFilter();
00205   virtual ~DeformationFieldJacobianDeterminantFilter() {}
00206 
00210   void BeforeThreadedGenerateData ();
00211 
00224   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00225                             int threadId );
00226 
00227   void PrintSelf(std::ostream& os, Indent indent) const;
00228 
00229   typedef typename InputImageType::Superclass ImageBaseType;
00230 
00232   itkGetConstObjectMacro( RealValuedInputImage, ImageBaseType );
00233 
00235   itkGetConstReferenceMacro( NeighborhoodRadius, RadiusType );
00236   itkSetMacro( NeighborhoodRadius, RadiusType );
00238 
00239 
00240   TRealType EvaluateAtNeighborhood
00241   (const ConstNeighborhoodIteratorType &it) const
00242   {
00243     unsigned i, j;
00244     vnl_matrix_fixed<TRealType,ImageDimension,VectorDimension> J;
00245 
00246     for (i = 0; i < ImageDimension; ++i)
00247       {
00248       for (j = 0; j < VectorDimension; ++j)
00249         {
00250         J[i][j] = m_DerivativeWeights[i]
00251                   * 0.5 * (it.GetNext(i)[j] - it.GetPrevious(i)[j]);
00252         }
00253       }
00254     
00255     return vnl_det(J);
00256   }
00257 
00259   TRealType m_DerivativeWeights[itk::GetImageDimension<TInputImage>::ImageDimension];
00260 
00261 private:
00262   bool m_UseImageSpacing;
00263   int m_RequestedNumberOfThreads;
00264 
00265   typename ImageBaseType::ConstPointer m_RealValuedInputImage;
00266   
00267   DeformationFieldJacobianDeterminantFilter(const Self&); //purposely not implemented
00268   void operator=(const Self&); //purposely not implemented
00269 
00270   RadiusType    m_NeighborhoodRadius;  
00271 };
00272   
00273 } // end namespace itk
00274 
00275 #ifndef ITK_MANUAL_INSTANTIATION
00276 #include "itkDeformationFieldJacobianDeterminantFilter.txx"
00277 #endif
00278 
00279 #endif
00280 

Generated at Mon Mar 12 00:03:06 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000