#if defined (_MSC_VER) && (_MSC_VER >= 1000) #pragma once #endif #ifndef _SENSE_GRADIENT #define _SENSE_GRADIENT #include "itkGradientMagnitudeRecursiveGaussianImageFilter.h" #include "itkGradientRecursiveGaussianImageFilter.h" #include "itkImageFileWriter.h" #include "Sensor.h" namespace mial { //! Derived sensory class for computing image gradient. /*!A derived class of the sensory ABC, this class calculates the gradient of the image and returns it in the form of TGradientImage. Calculations are performed using ITK's GradientMagnitudeRecursiveGaussianImageFilter, and GradientRecursiveGaussianImageFilter, the later of which provides the derivatives along each direction. In order to run the sensor one must use its publicly defined sensorIn and sensorOut types to create the input arguments and receive the output. In this case the sensor takes a pointer to the input image and the standard deviation to be used for smoothing, and outputs a pointer to the gradient image.*/ template class Sense_Gradient: public Sensor { //**************************************************** //Member variables //**************************************************** public: //Smartpointer typedef Sense_Gradient Self; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; typedef itk::WeakPointer ConstWeakPointer; itkNewMacro(Self); typedef TInputImage InputImageType; typedef typename InputImageType::ConstPointer InputImagePointer; typedef itk::Image OutputImageType; typedef typename OutputImageType::ConstPointer OutputImagePointer; typedef TGradientImage GradientImageType; typedef typename GradientImageType::Pointer GradientImagePointer; struct sensorIn: public Sensor::sensorIn{ //Smartpointer typedef sensorIn Self; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; typedef itk::WeakPointer ConstWeakPointer; itkNewMacro(Self); //Define all custom here InputImagePointer imageIn; DataType sigma; protected: sensorIn(){}; }; struct sensorOut: public Sensor::sensorOut{ //Smartpointer typedef sensorOut Self; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; typedef itk::WeakPointer ConstWeakPointer; itkNewMacro(Self); //Define all custom here GradientImagePointer imageOut; protected: sensorOut(){}; }; private: //Define all variables specific to this sensor here typedef typename itk::GradientMagnitudeRecursiveGaussianImageFilter MagnitudeFilterType; typedef typename itk::GradientRecursiveGaussianImageFilter GradientFilterType; //Testing //typedef typename itk::GradientMagnitudeRecursiveGaussianImageFilter MagnitudeFilterType; typename MagnitudeFilterType::Pointer magnitudeFilter; typename GradientFilterType::Pointer gradientFilter; typename sensorOut::Pointer sensorOutput; //**************************************************** //Member functions //**************************************************** public: //Run the sensor virtual void run(typename Sensor::sensorIn * const i); //Overide in derived class if custom sensor output desired //virtual Sensor::sensorOut::Pointer getOutput(){ return sensorOutput;}; private: //write an image to file void writeImageToFile(OutputImagePointer img,char * name); protected: Sense_Gradient(); }; } // end namespace mial #include "Sense_Gradient.cxx" #endif