itkBRAINSROIAutoImageFilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBRAINSROIAutoImageFilter_h
00018 #define __itkBRAINSROIAutoImageFilter_h
00019
00020
00021
00022
00023 #include "itkConfigure.h"
00024 #include "itkImageToImageFilter.h"
00025 #include "itkImage.h"
00026
00027 #include "itkImageMaskSpatialObject.h"
00028 #include "itkLargestForegroundFilledMaskImageFilter.h"
00029 #include "itkCastImageFilter.h"
00030
00031 typedef itk::SpatialObject< 3 > SpatialObjectType;
00032 typedef SpatialObjectType::Pointer ImageMaskPointer;
00033
00034 namespace itk
00035 {
00045 template< class TInputImage, class TOutputImage >
00046 class ITK_EXPORT BRAINSROIAutoImageFilter:
00047 public ImageToImageFilter< TInputImage, TOutputImage >
00048 {
00049 public:
00051 itkStaticConstMacro(InputImageDimension, unsigned int,
00052 TInputImage::ImageDimension);
00053 itkStaticConstMacro(OutputImageDimension, unsigned int,
00054 TOutputImage::ImageDimension);
00055
00057 typedef TInputImage InputImageType;
00058 typedef TOutputImage OutputImageType;
00059
00061 typedef BRAINSROIAutoImageFilter Self;
00062 typedef ImageToImageFilter< InputImageType, OutputImageType > Superclass;
00063 typedef SmartPointer< Self > Pointer;
00064 typedef SmartPointer< const Self > ConstPointer;
00065
00067 itkNewMacro(Self);
00068
00070 itkTypeMacro(BRAINSROIAutoImageFilter, ImageToImageFilter);
00071
00073 typedef typename InputImageType::PixelType InputPixelType;
00074 typedef typename OutputImageType::PixelType OutputPixelType;
00075
00076 typedef typename InputImageType::RegionType InputImageRegionType;
00077 typedef typename OutputImageType::RegionType OutputImageRegionType;
00078
00079 typedef typename InputImageType::SizeType InputSizeType;
00080
00081 typedef itk::Image< unsigned char, 3 > UCHARIMAGE;
00082 typedef itk::ImageMaskSpatialObject< UCHARIMAGE::ImageDimension > ImageMaskSpatialObjectType;
00083
00085 itkSetMacro(OtsuPercentileThreshold, double);
00086 itkGetConstMacro(OtsuPercentileThreshold, double);
00088 itkSetMacro(ThresholdCorrectionFactor, double);
00089 itkGetConstMacro(ThresholdCorrectionFactor, double);
00092 itkSetMacro(ClosingSize, double);
00093 itkGetConstMacro(ClosingSize, double);
00096 itkSetMacro(DilateSize, double);
00097 itkGetConstMacro(DilateSize, double);
00098
00099
00100
00101 ImageMaskPointer GetSpatialObjectROI(void)
00102 {
00103 if ( m_ResultMaskPointer.IsNull() )
00104
00105
00106 {
00107 typedef itk::CastImageFilter< OutputImageType, UCHARIMAGE > CastImageFilter;
00108 typename CastImageFilter::Pointer castFilter = CastImageFilter::New();
00109 castFilter->SetInput( this->GetOutput() );
00110 castFilter->Update();
00111
00112
00113 typename ImageMaskSpatialObjectType::Pointer mask = ImageMaskSpatialObjectType::New();
00114 mask->SetImage( castFilter->GetOutput() );
00115 mask->ComputeObjectToWorldTransform();
00116 m_ResultMaskPointer = dynamic_cast< ImageMaskSpatialObjectType * >( mask.GetPointer() );
00117 }
00118 return m_ResultMaskPointer;
00119 }
00120 typename UCHARIMAGE::ConstPointer GetBinaryImageROI()
00121 {
00122 ImageMaskPointer tmp = this->GetSpatialObjectROI();
00123 typename UCHARIMAGE::ConstPointer rval;
00124 if(tmp.IsNotNull())
00125 {
00126 typename itk::ImageMaskSpatialObject<3>::Pointer imso =
00127 dynamic_cast<itk::ImageMaskSpatialObject<3> *>
00128 (tmp.GetPointer());
00129 if(imso.IsNotNull())
00130 {
00131 rval = imso->GetImage();
00132 }
00133 }
00134 return rval;
00135 }
00136 #ifdef ITK_USE_CONCEPT_CHECKING
00137
00138 itkConceptMacro( SameDimensionCheck,
00139 ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) );
00141 #endif
00142 protected:
00143 BRAINSROIAutoImageFilter();
00144 virtual ~BRAINSROIAutoImageFilter() {}
00145 void PrintSelf(std::ostream & os, Indent indent) const;
00146
00147 void GenerateData();
00148
00149 private:
00150 BRAINSROIAutoImageFilter(const Self &);
00151 void operator=(const Self &);
00152
00153 double m_OtsuPercentileThreshold;
00154 double m_ThresholdCorrectionFactor;
00155 double m_ClosingSize;
00156 double m_DilateSize;
00157 ImageMaskPointer m_ResultMaskPointer;
00158 };
00159 }
00160
00161 #ifndef ITK_MANUAL_INSTANTIATION
00162 # include "itkBRAINSROIAutoImageFilter.txx"
00163 #endif
00164
00165 #endif