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 __itkOtsuMultipleThresholdsImageFilter_h 00019 #define __itkOtsuMultipleThresholdsImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkFixedArray.h" 00023 #include "itkOtsuMultipleThresholdsCalculator.h" 00024 #include "itkScalarImageToHistogramGenerator.h" 00025 00026 namespace itk 00027 { 00047 template< class TInputImage, class TOutputImage > 00048 class ITK_EXPORT OtsuMultipleThresholdsImageFilter: 00049 public ImageToImageFilter< TInputImage, TOutputImage > 00050 { 00051 public: 00053 typedef OtsuMultipleThresholdsImageFilter Self; 00054 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00055 typedef SmartPointer< Self > Pointer; 00056 typedef SmartPointer< const Self > ConstPointer; 00057 00059 itkNewMacro(Self); 00060 00062 itkTypeMacro(OtsuMultipleThresholdsImageFilter, ImageToImageFilter); 00063 00065 typedef typename TInputImage::PixelType InputPixelType; 00066 typedef typename TOutputImage::PixelType OutputPixelType; 00067 00069 typedef typename TInputImage::Pointer InputImagePointer; 00070 typedef typename TOutputImage::Pointer OutputImagePointer; 00071 00072 typedef typename TInputImage::SizeType InputSizeType; 00073 typedef typename TInputImage::IndexType InputIndexType; 00074 typedef typename TInputImage::RegionType InputImageRegionType; 00075 typedef typename TOutputImage::SizeType OutputSizeType; 00076 typedef typename TOutputImage::IndexType OutputIndexType; 00077 typedef typename TOutputImage::RegionType OutputImageRegionType; 00078 00080 typedef itk::Statistics::ScalarImageToHistogramGenerator< TInputImage > HistogramGeneratorType; 00081 typedef typename HistogramGeneratorType::HistogramType HistogramType; 00082 typedef OtsuMultipleThresholdsCalculator< HistogramType > OtsuCalculatorType; 00083 typedef typename OtsuCalculatorType::OutputType ThresholdVectorType; 00084 00086 itkStaticConstMacro(InputImageDimension, unsigned int, 00087 TInputImage::ImageDimension); 00088 itkStaticConstMacro(OutputImageDimension, unsigned int, 00089 TOutputImage::ImageDimension); 00091 00093 itkSetClampMacro( NumberOfHistogramBins, SizeValueType, 1, NumericTraits< SizeValueType >::max() ); 00094 itkGetConstMacro(NumberOfHistogramBins, SizeValueType); 00096 00098 itkSetClampMacro( NumberOfThresholds, SizeValueType, 1, NumericTraits< SizeValueType >::max() ); 00099 itkGetConstMacro(NumberOfThresholds, SizeValueType); 00101 00103 itkSetClampMacro( LabelOffset, OutputPixelType, NumericTraits< OutputPixelType >::Zero, 00104 NumericTraits< OutputPixelType >::max() ); 00105 itkGetConstMacro(LabelOffset, OutputPixelType); 00107 00109 const ThresholdVectorType & GetThresholds() const 00110 { 00111 return m_Thresholds; 00112 } 00113 00114 #ifdef ITK_USE_CONCEPT_CHECKING 00115 00116 itkConceptMacro( OutputComparableCheck, 00117 ( Concept::Comparable< OutputPixelType > ) ); 00118 itkConceptMacro( OutputOStreamWritableCheck, 00119 ( Concept::OStreamWritable< OutputPixelType > ) ); 00120 00122 #endif 00123 protected: 00124 OtsuMultipleThresholdsImageFilter(); 00125 ~OtsuMultipleThresholdsImageFilter(){} 00126 void PrintSelf(std::ostream & os, Indent indent) const; 00128 00129 void GenerateInputRequestedRegion(); 00130 00131 void GenerateData(); 00132 00133 private: 00134 OtsuMultipleThresholdsImageFilter(const Self &); //purposely not implemented 00135 void operator=(const Self &); //purposely not implemented 00136 00137 SizeValueType m_NumberOfHistogramBins; 00138 SizeValueType m_NumberOfThresholds; 00139 OutputPixelType m_LabelOffset; 00140 ThresholdVectorType m_Thresholds; 00141 }; // end of class 00142 } // end namespace itk 00143 00144 #ifndef ITK_MANUAL_INSTANTIATION 00145 #include "itkOtsuMultipleThresholdsImageFilter.hxx" 00146 #endif 00147 00148 #endif 00149