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 __itkObjectMorphologyImageFilter_h 00019 #define __itkObjectMorphologyImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkNeighborhoodIterator.h" 00023 #include "itkConstSliceIterator.h" 00024 #include "itkConstantBoundaryCondition.h" 00025 #include "itkImageRegionIterator.h" 00026 00027 namespace itk 00028 { 00072 template< class TInputImage, class TOutputImage, class TKernel > 00073 class ITK_EXPORT ObjectMorphologyImageFilter: 00074 public ImageToImageFilter< TInputImage, TOutputImage > 00075 { 00076 public: 00078 typedef ObjectMorphologyImageFilter Self; 00079 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00080 typedef SmartPointer< Self > Pointer; 00081 typedef SmartPointer< const Self > ConstPointer; 00082 00084 itkTypeMacro(ObjectMorphologyImageFilter, ImageToImageFilter); 00085 00087 typedef TInputImage InputImageType; 00088 typedef TOutputImage OutputImageType; 00089 typedef typename TInputImage::RegionType RegionType; 00090 typedef typename TInputImage::SizeType SizeType; 00091 typedef typename TInputImage::IndexType IndexType; 00092 typedef typename TInputImage::PixelType PixelType; 00093 00094 typedef typename Superclass::OutputImageRegionType OutputImageRegionType; 00095 00096 typedef ImageBoundaryCondition< InputImageType > * 00097 ImageBoundaryConditionPointerType; 00098 typedef ImageBoundaryCondition< InputImageType > const * 00099 ImageBoundaryConditionConstPointerType; 00100 typedef ConstantBoundaryCondition< InputImageType > 00101 DefaultBoundaryConditionType; 00102 00104 itkStaticConstMacro(ImageDimension, unsigned int, 00105 TInputImage::ImageDimension); 00106 itkStaticConstMacro(OutputImageDimension, unsigned int, 00107 TOutputImage::ImageDimension); 00108 itkStaticConstMacro(KernelDimension, unsigned int, 00109 TKernel::NeighborhoodDimension); 00111 00113 typedef ConstNeighborhoodIterator< TInputImage > 00114 InputNeighborhoodIteratorType; 00115 typedef NeighborhoodIterator< TOutputImage > 00116 OutputNeighborhoodIteratorType; 00117 00119 typedef TKernel KernelType; 00120 00122 typedef typename KernelType::ConstIterator KernelIteratorType; 00123 00125 typedef typename KernelType::SizeType RadiusType; 00126 00128 itkSetMacro(Kernel, KernelType); 00129 00131 itkGetConstReferenceMacro(Kernel, KernelType); 00132 00134 itkGetConstMacro(ObjectValue, PixelType); 00135 00137 itkSetMacro(ObjectValue, PixelType); 00138 00144 void GenerateInputRequestedRegion(); 00145 00152 void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i) 00153 { m_BoundaryCondition = i; } 00154 00156 void ResetBoundaryCondition() 00157 { m_BoundaryCondition = &m_DefaultBoundaryCondition; } 00158 00160 itkGetConstMacro(BoundaryCondition, ImageBoundaryConditionPointerType); 00161 00166 itkSetMacro(UseBoundaryCondition, bool); 00167 00172 itkGetConstMacro(UseBoundaryCondition, bool); 00173 00174 #ifdef ITK_USE_CONCEPT_CHECKING 00175 00176 itkConceptMacro( SameDimensionCheck1, 00177 ( Concept::SameDimension< ImageDimension, OutputImageDimension > ) ); 00178 itkConceptMacro( SameDimensionCheck2, 00179 ( Concept::SameDimension< ImageDimension, KernelDimension > ) ); 00180 itkConceptMacro( OutputInputEqualityComparableCheck, 00181 ( Concept::EqualityComparable< typename TOutputImage::PixelType, 00182 PixelType > ) ); 00183 itkConceptMacro( InputConvertibleToOutputCheck, 00184 ( Concept::Convertible< PixelType, typename TOutputImage::PixelType > ) ); 00185 itkConceptMacro( IntConvertibleToOutputCheck, 00186 ( Concept::Convertible< int, typename TOutputImage::PixelType > ) ); 00187 itkConceptMacro( InputEqualityComparable, 00188 ( Concept::EqualityComparable< PixelType > ) ); 00189 itkConceptMacro( InputOStreamWritableCheck, 00190 ( Concept::OStreamWritable< PixelType > ) ); 00191 00193 #endif 00194 protected: 00195 ObjectMorphologyImageFilter(); 00196 ~ObjectMorphologyImageFilter() {} 00197 void PrintSelf(std::ostream & os, Indent indent) const; 00199 00201 void ThreadedGenerateData(const OutputImageRegionType & 00202 outputRegionForThread, 00203 ThreadIdType threadId); 00204 00207 virtual void Evaluate(OutputNeighborhoodIteratorType & nit, 00208 const KernelType & kernel) = 0; 00209 00213 bool IsObjectPixelOnBoundary(const InputNeighborhoodIteratorType & nit); 00214 00217 ImageBoundaryConditionPointerType m_BoundaryCondition; 00218 00220 DefaultBoundaryConditionType m_DefaultBoundaryCondition; 00221 00223 bool m_UseBoundaryCondition; 00224 00226 KernelType m_Kernel; 00227 00229 PixelType m_ObjectValue; 00230 00231 void BeforeThreadedGenerateData(); 00232 00233 private: 00234 ObjectMorphologyImageFilter(const Self &); //purposely not implemented 00235 void operator=(const Self &); //purposely not implemented 00236 }; // end of class 00237 } // end namespace itk 00238 00239 #ifndef ITK_MANUAL_INSTANTIATION 00240 #include "itkObjectMorphologyImageFilter.hxx" 00241 #endif 00242 00243 #endif 00244