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 __itkBinaryImageToStatisticsLabelMapFilter_h 00019 #define __itkBinaryImageToStatisticsLabelMapFilter_h 00020 00021 #include "itkStatisticsLabelObject.h" 00022 #include "itkBinaryImageToLabelMapFilter.h" 00023 #include "itkStatisticsLabelMapFilter.h" 00024 00025 namespace itk 00026 { 00040 template< class TInputImage, class TFeatureImage, class TOutputImage = 00041 LabelMap< StatisticsLabelObject< SizeValueType, ::itk::GetImageDimension< TInputImage >::ImageDimension > > > 00042 class ITK_EXPORT BinaryImageToStatisticsLabelMapFilter: 00043 public ImageToImageFilter< TInputImage, TOutputImage > 00044 { 00045 public: 00047 typedef BinaryImageToStatisticsLabelMapFilter Self; 00048 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00049 typedef SmartPointer< Self > Pointer; 00050 typedef SmartPointer< const Self > ConstPointer; 00051 00053 typedef TInputImage InputImageType; 00054 typedef typename InputImageType::Pointer InputImagePointer; 00055 typedef typename InputImageType::ConstPointer InputImageConstPointer; 00056 typedef typename InputImageType::RegionType InputImageRegionType; 00057 typedef typename InputImageType::PixelType InputImagePixelType; 00058 00059 typedef TOutputImage OutputImageType; 00060 typedef typename OutputImageType::Pointer OutputImagePointer; 00061 typedef typename OutputImageType::ConstPointer OutputImageConstPointer; 00062 typedef typename OutputImageType::RegionType OutputImageRegionType; 00063 typedef typename OutputImageType::PixelType OutputImagePixelType; 00064 typedef typename OutputImageType::LabelObjectType LabelObjectType; 00065 00066 typedef TFeatureImage FeatureImageType; 00067 typedef typename FeatureImageType::Pointer FeatureImagePointer; 00068 typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer; 00069 typedef typename FeatureImageType::PixelType FeatureImagePixelType; 00070 00072 itkStaticConstMacro(InputImageDimension, unsigned int, 00073 TInputImage::ImageDimension); 00074 itkStaticConstMacro(OutputImageDimension, unsigned int, 00075 TInputImage::ImageDimension); 00076 itkStaticConstMacro(ImageDimension, unsigned int, 00077 TInputImage::ImageDimension); 00079 00080 typedef BinaryImageToLabelMapFilter< InputImageType, OutputImageType > LabelizerType; 00081 typedef StatisticsLabelMapFilter< OutputImageType, FeatureImageType > LabelObjectValuatorType; 00082 00084 itkNewMacro(Self); 00085 00087 itkTypeMacro(BinaryImageToStatisticsLabelMapFilter, 00088 ImageToImageFilter); 00089 00096 itkSetMacro(FullyConnected, bool); 00097 itkGetConstReferenceMacro(FullyConnected, bool); 00098 itkBooleanMacro(FullyConnected); 00100 00101 #ifdef ITK_USE_CONCEPT_CHECKING 00102 00103 itkConceptMacro( InputEqualityComparableCheck, 00104 ( Concept::EqualityComparable< InputImagePixelType > ) ); 00105 itkConceptMacro( IntConvertibleToInputCheck, 00106 ( Concept::Convertible< int, InputImagePixelType > ) ); 00107 itkConceptMacro( InputOStreamWritableCheck, 00108 ( Concept::OStreamWritable< InputImagePixelType > ) ); 00109 00111 #endif 00112 00117 itkSetMacro(OutputBackgroundValue, OutputImagePixelType); 00118 itkGetConstMacro(OutputBackgroundValue, OutputImagePixelType); 00120 00125 itkSetMacro(InputForegroundValue, InputImagePixelType); 00126 itkGetConstMacro(InputForegroundValue, InputImagePixelType); 00128 00133 itkSetMacro(ComputeFeretDiameter, bool); 00134 itkGetConstReferenceMacro(ComputeFeretDiameter, bool); 00135 itkBooleanMacro(ComputeFeretDiameter); 00137 00142 itkSetMacro(ComputePerimeter, bool); 00143 itkGetConstReferenceMacro(ComputePerimeter, bool); 00144 itkBooleanMacro(ComputePerimeter); 00146 00148 void SetFeatureImage(const TFeatureImage *input) 00149 { 00150 // Process object is not const-correct so the const casting is required. 00151 this->SetNthInput( 1, const_cast< TFeatureImage * >( input ) ); 00152 } 00153 00155 const FeatureImageType * GetFeatureImage() 00156 { 00157 return static_cast< const FeatureImageType * >( this->ProcessObject::GetInput(1) ); 00158 } 00159 00161 void SetInput1(const InputImageType *input) 00162 { 00163 this->SetInput(input); 00164 } 00165 00167 void SetInput2(const FeatureImageType *input) 00168 { 00169 this->SetFeatureImage(input); 00170 } 00171 00178 itkSetMacro(ComputeHistogram, bool); 00179 itkGetConstReferenceMacro(ComputeHistogram, bool); 00180 itkBooleanMacro(ComputeHistogram); 00182 00188 itkSetMacro(NumberOfBins, unsigned int); 00189 itkGetConstReferenceMacro(NumberOfBins, unsigned int); 00190 protected: 00191 BinaryImageToStatisticsLabelMapFilter(); 00192 ~BinaryImageToStatisticsLabelMapFilter() {} 00193 void PrintSelf(std::ostream & os, Indent indent) const; 00195 00199 void GenerateInputRequestedRegion(); 00200 00202 void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ); 00203 00206 void GenerateData(); 00207 00208 private: 00209 BinaryImageToStatisticsLabelMapFilter(const Self &); //purposely not 00210 // implemented 00211 void operator=(const Self &); //purposely not 00212 // implemented 00213 00214 bool m_FullyConnected; 00215 OutputImagePixelType m_OutputBackgroundValue; 00216 InputImagePixelType m_InputForegroundValue; 00217 bool m_ComputeFeretDiameter; 00218 bool m_ComputePerimeter; 00219 unsigned int m_NumberOfBins; 00220 bool m_ComputeHistogram; 00221 }; // end of class 00222 } // end namespace itk 00223 00224 #ifndef ITK_MANUAL_INSTANTIATION 00225 #include "itkBinaryImageToStatisticsLabelMapFilter.hxx" 00226 #endif 00227 00228 #endif 00229