1. /***************************************************************************
  2.  *   Copyright (c) Johannes Perl                                           *
  3.  *   All rights reserved.                                                  *
  4.  *                                                                         *
  5.  *   This program is free software; you can redistribute it and/or modify  *
  6.  *   it under the terms of the GNU General Public License as published by  *
  7.  *   the Free Software Foundation; either version 2 of the License, or     *
  8.  *   (at your option) any later version.                                   *
  9.  ***************************************************************************/
  10.  
  11. #ifndef __SheppLoganFilter_h
  12. #define __SheppLoganFilter_h
  13.  
  14. #include <vector>
  15.  
  16. //ITK includes
  17. #include "itkImageToImageFilter.h"
  18. #include "itkImageRegionIterator.h"
  19. #include "itkConstNeighborhoodIterator.h"
  20. #include "itkOffset.h"
  21.  
  22. /*!
  23.  * \author Johannes Perl
  24.  * \class SheppLoganFilter
  25.  * \brief Applies a shepp logan filter to an image and returns the filtered image.
  26.  */
  27. template < typename TInputImage,  typename TOutputImage >
  28. class SheppLoganFilter : public itk::ImageToImageFilter< TInputImage, TOutputImage >
  29. {
  30. public:
  31.     /*! Standard class typedefs. */
  32.     typedef SheppLoganFilter Self;
  33.     typedef itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass;
  34.     typedef itk::SmartPointer< Self > Pointer;
  35.     typedef itk::SmartPointer< const Self > ConstPointer;
  36.  
  37.     /*! Method for creation through object factory */
  38.     itkNewMacro(Self);
  39.  
  40.     /*! Run-time type information (and related methods) */
  41.     itkTypeMacro(SheppLoganFilter, ImageToImageFilter);
  42.  
  43.     //Convenience typedefs
  44.     typedef TInputImage ImageType;
  45. 	typedef TOutputImage OImageType;
  46.     typedef typename ImageType::RegionType RegionType;
  47. 	typedef itk::ConstNeighborhoodIterator< ImageType > NeighborhoodIteratorType;
  48. 	typedef itk::ImageRegionIterator< OImageType> IteratorType;
  49.  
  50. 	typedef typename ImageType::ConstPointer ImageConstPointer;
  51.     typedef typename OImageType::Pointer ImagePointer;
  52.  
  53.     /*! Extract dimension from input and output image. */
  54.     itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
  55.  
  56.     itkSetMacro(VRadius, int);
  57.     itkGetConstReferenceMacro(VRadius, int);
  58.  
  59. protected:
  60.     SheppLoganFilter();
  61.     virtual ~SheppLoganFilter() {}
  62.     /*! Standard "PrintSelf" method */
  63.     void PrintSelf(std::ostream& os, itk::Indent indent) const;
  64.  
  65.     /*!
  66.      * SheppLoganFilter can be implemented as a 
  67.      * multithreaded filter. Therefore, this implementation provides
  68.      * a ThreadedGenerateData() routine which is called for each 
  69.      * processing thread. The output image data is allocated 
  70.      * automatically by the superclass prior to calling 
  71.      * ThreadedGenerateData().  ThreadedGenerateData can only
  72.      * write to the portion of the output image specified by the
  73.      * parameter "outputRegionForThread".
  74.      *
  75.      * \sa ImageToImageFilter::ThreadedGenerateData(),
  76.      *     ImageToImageFilter::GenerateData()
  77.      */
  78.     void ThreadedGenerateData(const RegionType& regionForThread, 
  79.                               int threadId );
  80.  
  81. private:
  82.     SheppLoganFilter(const Self&) {}; //purposely not implemented
  83.     void operator=(const Self&); //purposely not implemented
  84.  
  85.     /*! vertical radius of shepp logan filter  */
  86.     int m_VRadius;
  87. };
  88.  
  89. #ifndef ITK_MANUAL_INSTANTIATION
  90. #include "SheppLoganFilter.txx"
  91. #endif
  92.  
  93. #endif
  94.