00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freSpatialRegionOfInterestImageFilter_h
00023 #define __freSpatialRegionOfInterestImageFilter_h
00024
00025 #include "itkImageToImageFilter.h"
00026 #include "itkSmartPointer.h"
00027 #include "itkSpatialObject.h"
00028
00029 namespace FREE
00030 {
00031
00049 template <class TInputImage, class TOutputImage>
00050 class ITK_EXPORT SpatialRegionOfInterestImageFilter:
00051 public itk::ImageToImageFilter<TInputImage,TOutputImage>
00052 {
00053 public:
00055 typedef SpatialRegionOfInterestImageFilter Self;
00056 typedef itk::ImageToImageFilter< TInputImage, TOutputImage> Superclass;
00057 typedef itk::SmartPointer<Self> Pointer;
00058 typedef itk::SmartPointer<const Self> ConstPointer;
00059 typedef typename Superclass::InputImageRegionType InputImageRegionType;
00060
00062 itkNewMacro(Self);
00063
00065 itkTypeMacro(SpatialRegionOfInterestImageFilter, ImageToImageFilter);
00066
00068 typedef typename TInputImage::RegionType RegionType;
00069 typedef typename TInputImage::IndexType IndexType;
00070 typedef typename TInputImage::SizeType SizeType;
00071 typedef typename TInputImage::PointType PointType;
00072
00074 typedef typename TOutputImage::PixelType OutputImagePixelType;
00075 typedef typename TInputImage::PixelType InputImagePixelType;
00076
00078 typedef itk::SpatialObject< TInputImage::ImageDimension > SpatialObjectType;
00079 typedef typename SpatialObjectType::Pointer SpatialObjectPointer;
00080
00082 virtual void SetSpatialRegionOfInterest(SpatialObjectType* pROI);
00083 virtual SpatialObjectType* GetSpatialRegionOfInterest();
00084
00085 itkSetMacro(OutsideValue, OutputImagePixelType);
00086 itkGetMacro(OutsideValue, OutputImagePixelType);
00087
00088 itkSetMacro(CropByInput, bool);
00089 itkGetMacro(CropByInput, bool);
00090
00092 itkStaticConstMacro(ImageDimension, unsigned int,
00093 TInputImage::ImageDimension);
00094 itkStaticConstMacro(OutputImageDimension, unsigned int,
00095 TOutputImage::ImageDimension);
00096
00097 #ifdef ITK_USE_CONCEPT_CHECKING
00098
00099 itkConceptMacro(SameDimensionCheck,
00100 (Concept::SameDimension<ImageDimension, OutputImageDimension>));
00101 itkConceptMacro(InputConvertibleToOutputCheck,
00102 (Concept::Convertible<InputImagePixelType, OutputImagePixelType>));
00104 #endif
00105
00106 protected:
00107 SpatialRegionOfInterestImageFilter();
00108 ~SpatialRegionOfInterestImageFilter() {};
00109 void PrintSelf(std::ostream& os, itk::Indent indent) const;
00110
00111
00112 virtual void GenerateInputRequestedRegion();
00113 virtual void EnlargeOutputRequestedRegion(itk::DataObject *output);
00114
00123 virtual void GenerateOutputInformation();
00124
00125
00135 void ThreadedGenerateData(const RegionType& outputRegionForThread,
00136 int threadId );
00137
00143 RegionType GenerateLargestSpatialRegion(const TInputImage* pInput);
00144
00145 private:
00146 SpatialRegionOfInterestImageFilter(const Self&);
00147 void operator=(const Self&);
00148
00149 SpatialObjectPointer m_SpatialObject;
00150 OutputImagePixelType m_OutsideValue;
00151 bool m_CropByInput;
00152 };
00153
00154
00155 }
00156
00157 #ifndef ITK_MANUAL_INSTANTIATION
00158 #include "freSpatialRegionOfInterestImageFilter.txx"
00159 #endif
00160
00161 #endif