00001 #if defined (_MSC_VER) && (_MSC_VER >= 1000) 00002 #pragma once 00003 #endif 00004 #ifndef _SENSE_GRADIENT 00005 #define _SENSE_GRADIENT 00006 00007 #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" 00008 #include "itkGradientRecursiveGaussianImageFilter.h" 00009 #include "itkImageFileWriter.h" 00010 #include "Sensor.h" 00011 namespace mial 00012 { 00013 00015 00027 template<class DataType, class TInputImage, class TGradientImage, int nDims> 00028 class Sense_Gradient: public Sensor 00029 { 00030 //**************************************************** 00031 //Member variables 00032 //**************************************************** 00033 public: 00034 //Smartpointer 00035 typedef Sense_Gradient Self; 00036 typedef itk::SmartPointer<Self> Pointer; 00037 typedef itk::SmartPointer<const Self> ConstPointer; 00038 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00039 itkNewMacro(Self); 00040 00041 typedef TInputImage InputImageType; 00042 typedef typename InputImageType::ConstPointer InputImagePointer; 00043 00044 typedef itk::Image<DataType,nDims> OutputImageType; 00045 typedef typename OutputImageType::ConstPointer OutputImagePointer; 00046 00047 00048 typedef TGradientImage GradientImageType; 00049 typedef typename GradientImageType::Pointer GradientImagePointer; 00050 00051 struct sensorIn: public Sensor::sensorIn{ 00052 //Smartpointer 00053 typedef sensorIn Self; 00054 typedef itk::SmartPointer<Self> Pointer; 00055 typedef itk::SmartPointer<const Self> ConstPointer; 00056 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00057 itkNewMacro(Self); 00058 00059 //Define all custom here 00060 InputImagePointer imageIn; 00061 DataType sigma; 00062 protected: 00063 sensorIn(){}; 00064 }; 00065 00066 struct sensorOut: public Sensor::sensorOut{ 00067 //Smartpointer 00068 typedef sensorOut Self; 00069 typedef itk::SmartPointer<Self> Pointer; 00070 typedef itk::SmartPointer<const Self> ConstPointer; 00071 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00072 itkNewMacro(Self); 00073 00074 //Define all custom here 00075 GradientImagePointer imageOut; 00076 protected: 00077 sensorOut(){}; 00078 }; 00079 00080 private: 00081 00082 //Define all variables specific to this sensor here 00083 typedef typename itk::GradientMagnitudeRecursiveGaussianImageFilter<InputImageType, OutputImageType> MagnitudeFilterType; 00084 typedef typename itk::GradientRecursiveGaussianImageFilter<OutputImageType, GradientImageType> GradientFilterType; 00085 00086 //Testing 00087 //typedef typename itk::GradientMagnitudeRecursiveGaussianImageFilter<InputImageType, InputImageType> MagnitudeFilterType; 00088 00089 typename MagnitudeFilterType::Pointer magnitudeFilter; 00090 typename GradientFilterType::Pointer gradientFilter; 00091 00092 typename sensorOut::Pointer sensorOutput; 00093 00094 00095 //**************************************************** 00096 //Member functions 00097 //**************************************************** 00098 public: 00099 00100 //Run the sensor 00101 virtual void run(typename Sensor::sensorIn * const i); 00102 00103 //Overide in derived class if custom sensor output desired 00104 //virtual Sensor::sensorOut::Pointer getOutput(){ return sensorOutput;}; 00105 00106 private: 00107 //write an image to file 00108 void writeImageToFile(OutputImagePointer img,char * name); 00109 00110 protected: 00111 Sense_Gradient(); 00112 00113 }; 00114 } // end namespace mial 00115 #include "Sense_Gradient.cxx" 00116 #endif