ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkRobustAutomaticThresholdImageFilter_h 00019 #define __itkRobustAutomaticThresholdImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkRobustAutomaticThresholdCalculator.h" 00023 00024 namespace itk 00025 { 00050 template< class TInputImage, class TGradientImage = TInputImage, class TOutputImage = TInputImage > 00051 class ITK_EXPORT RobustAutomaticThresholdImageFilter: 00052 public ImageToImageFilter< TInputImage, TOutputImage > 00053 { 00054 public: 00056 typedef RobustAutomaticThresholdImageFilter Self; 00057 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00058 typedef SmartPointer< Self > Pointer; 00059 typedef SmartPointer< const Self > ConstPointer; 00060 00062 itkNewMacro(Self); 00063 00065 itkTypeMacro(RobustAutomaticThresholdImageFilter, ImageToImageFilter); 00066 00068 typedef TInputImage InputImageType; 00069 typedef TGradientImage GradientImageType; 00070 00072 typedef typename TInputImage::PixelType InputPixelType; 00073 typedef typename TOutputImage::PixelType OutputPixelType; 00074 typedef typename TGradientImage::PixelType GradientPixelType; 00075 00077 typedef typename TInputImage::Pointer InputImagePointer; 00078 typedef typename TOutputImage::Pointer OutputImagePointer; 00079 typedef typename TGradientImage::Pointer GradientImagePointer; 00080 00081 typedef typename TInputImage::SizeType InputSizeType; 00082 typedef typename TInputImage::IndexType InputIndexType; 00083 typedef typename TInputImage::RegionType InputImageRegionType; 00084 typedef typename TOutputImage::SizeType OutputSizeType; 00085 typedef typename TOutputImage::IndexType OutputIndexType; 00086 typedef typename TOutputImage::RegionType OutputImageRegionType; 00087 00088 typedef RobustAutomaticThresholdCalculator< TInputImage, TGradientImage > 00089 CalculatorType; 00090 00092 itkStaticConstMacro(InputImageDimension, unsigned int, 00093 TInputImage::ImageDimension); 00094 itkStaticConstMacro(OutputImageDimension, unsigned int, 00095 TOutputImage::ImageDimension); 00097 00100 itkSetMacro(OutsideValue, OutputPixelType); 00101 00103 itkGetConstMacro(OutsideValue, OutputPixelType); 00104 00107 itkSetMacro(InsideValue, OutputPixelType); 00108 00110 itkGetConstMacro(InsideValue, OutputPixelType); 00111 00113 itkGetConstMacro(Threshold, InputPixelType); 00114 00115 itkSetMacro(Pow, double); 00116 itkGetConstMacro(Pow, double); 00117 00118 #ifdef ITK_USE_CONCEPT_CHECKING 00119 00120 itkConceptMacro( OutputComparableCheck, 00121 ( Concept::Comparable< OutputPixelType > ) ); 00122 itkConceptMacro( OutputOStreamWritableCheck, 00123 ( Concept::OStreamWritable< OutputPixelType > ) ); 00124 00126 #endif 00127 00129 void SetGradientImage(GradientImageType *input) 00130 { 00131 // Process object is not const-correct so the const casting is required. 00132 this->SetNthInput( 1, const_cast< GradientImageType * >( input ) ); 00133 } 00134 00136 GradientImageType * GetGradientImage() 00137 { 00138 return static_cast< GradientImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) ); 00139 } 00140 00142 void SetInput1(TInputImage *input) 00143 { 00144 this->SetInput(input); 00145 } 00146 00148 void SetInput2(GradientImageType *input) 00149 { 00150 this->SetGradientImage(input); 00151 } 00152 00153 protected: 00154 RobustAutomaticThresholdImageFilter(); 00155 ~RobustAutomaticThresholdImageFilter(){} 00156 void PrintSelf(std::ostream & os, Indent indent) const; 00157 00158 void GenerateInputRequestedRegion(); 00159 00160 void GenerateData(); 00161 00162 private: 00163 RobustAutomaticThresholdImageFilter(const Self &); //purposely not implemented 00164 void operator=(const Self &); //purposely not implemented 00165 00166 double m_Pow; 00167 InputPixelType m_Threshold; 00168 OutputPixelType m_InsideValue; 00169 OutputPixelType m_OutsideValue; 00170 }; // end of class 00171 } // end namespace itk 00172 00173 #ifndef ITK_MANUAL_INSTANTIATION 00174 #include "itkRobustAutomaticThresholdImageFilter.hxx" 00175 #endif 00176 00177 #endif 00178