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 __itkStatisticsRelabelImageFilter_h 00019 #define __itkStatisticsRelabelImageFilter_h 00020 00021 #include "itkLabelImageToLabelMapFilter.h" 00022 #include "itkStatisticsLabelMapFilter.h" 00023 #include "itkStatisticsRelabelLabelMapFilter.h" 00024 #include "itkLabelMapToLabelImageFilter.h" 00025 00026 namespace itk 00027 { 00044 template< class TInputImage, class TFeatureImage > 00045 class ITK_EXPORT StatisticsRelabelImageFilter: 00046 public ImageToImageFilter< TInputImage, TInputImage > 00047 { 00048 public: 00050 typedef StatisticsRelabelImageFilter Self; 00051 typedef ImageToImageFilter< TInputImage, TInputImage > Superclass; 00052 typedef SmartPointer< Self > Pointer; 00053 typedef SmartPointer< const Self > ConstPointer; 00054 00056 typedef TInputImage InputImageType; 00057 typedef TInputImage OutputImageType; 00058 typedef typename InputImageType::Pointer InputImagePointer; 00059 typedef typename InputImageType::ConstPointer InputImageConstPointer; 00060 typedef typename InputImageType::RegionType InputImageRegionType; 00061 typedef typename InputImageType::PixelType InputImagePixelType; 00062 typedef typename OutputImageType::Pointer OutputImagePointer; 00063 typedef typename OutputImageType::ConstPointer OutputImageConstPointer; 00064 typedef typename OutputImageType::RegionType OutputImageRegionType; 00065 typedef typename OutputImageType::PixelType OutputImagePixelType; 00066 00067 typedef TFeatureImage FeatureImageType; 00068 typedef typename FeatureImageType::Pointer FeatureImagePointer; 00069 typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer; 00070 typedef typename FeatureImageType::PixelType FeatureImagePixelType; 00071 00073 itkStaticConstMacro(InputImageDimension, unsigned int, 00074 TInputImage::ImageDimension); 00075 itkStaticConstMacro(OutputImageDimension, unsigned int, 00076 TInputImage::ImageDimension); 00077 itkStaticConstMacro(ImageDimension, unsigned int, 00078 TInputImage::ImageDimension); 00080 00081 typedef StatisticsLabelObject< InputImagePixelType, itkGetStaticConstMacro(ImageDimension) > LabelObjectType; 00082 typedef LabelMap< LabelObjectType > LabelMapType; 00083 typedef LabelImageToLabelMapFilter< InputImageType, LabelMapType > LabelizerType; 00084 typedef StatisticsLabelMapFilter< LabelMapType, TFeatureImage > LabelObjectValuatorType; 00085 typedef typename LabelObjectType::AttributeType AttributeType; 00086 typedef StatisticsRelabelLabelMapFilter< LabelMapType > RelabelType; 00087 typedef LabelMapToLabelImageFilter< LabelMapType, OutputImageType > BinarizerType; 00088 00090 itkNewMacro(Self); 00091 00093 itkTypeMacro(StatisticsRelabelImageFilter, 00094 ImageToImageFilter); 00095 00096 #ifdef ITK_USE_CONCEPT_CHECKING 00097 00098 itkConceptMacro( InputEqualityComparableCheck, 00099 ( Concept::EqualityComparable< InputImagePixelType > ) ); 00100 itkConceptMacro( IntConvertibleToInputCheck, 00101 ( Concept::Convertible< int, InputImagePixelType > ) ); 00102 itkConceptMacro( InputOStreamWritableCheck, 00103 ( Concept::OStreamWritable< InputImagePixelType > ) ); 00104 00106 #endif 00107 00112 itkSetMacro(BackgroundValue, OutputImagePixelType); 00113 itkGetConstMacro(BackgroundValue, OutputImagePixelType); 00115 00121 itkGetConstMacro(ReverseOrdering, bool); 00122 itkSetMacro(ReverseOrdering, bool); 00123 itkBooleanMacro(ReverseOrdering); 00125 00129 itkGetConstMacro(Attribute, AttributeType); 00130 itkSetMacro(Attribute, AttributeType); 00131 void SetAttribute(const std::string & s) 00132 { 00133 this->SetAttribute( LabelObjectType::GetAttributeFromName(s) ); 00134 } 00136 00138 void SetFeatureImage(TFeatureImage *input) 00139 { 00140 // Process object is not const-correct so the const casting is required. 00141 this->SetNthInput( 1, const_cast< TFeatureImage * >( input ) ); 00142 } 00143 00145 FeatureImageType * GetFeatureImage() 00146 { 00147 return static_cast< FeatureImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) ); 00148 } 00149 00151 void SetInput1(InputImageType *input) 00152 { 00153 this->SetInput(input); 00154 } 00155 00157 void SetInput2(FeatureImageType *input) 00158 { 00159 this->SetFeatureImage(input); 00160 } 00161 00162 protected: 00163 StatisticsRelabelImageFilter(); 00164 ~StatisticsRelabelImageFilter() {} 00165 void PrintSelf(std::ostream & os, Indent indent) const; 00166 00170 void GenerateInputRequestedRegion(); 00171 00173 void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ); 00174 00177 void GenerateData(); 00178 00179 private: 00180 StatisticsRelabelImageFilter(const Self &); //purposely not implemented 00181 void operator=(const Self &); //purposely not implemented 00182 00183 OutputImagePixelType m_BackgroundValue; 00184 bool m_ReverseOrdering; 00185 AttributeType m_Attribute; 00186 }; // end of class 00187 } // end namespace itk 00188 00189 #ifndef ITK_MANUAL_INSTANTIATION 00190 #include "itkStatisticsRelabelImageFilter.hxx" 00191 #endif 00192 00193 #endif 00194