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 __itkNeighborhoodOperatorImageFilter_h 00019 #define __itkNeighborhoodOperatorImageFilter_h 00020 00021 #include "itkImageToImageFilter.h" 00022 #include "itkNeighborhoodOperator.h" 00023 #include "itkImage.h" 00024 #include "itkZeroFluxNeumannBoundaryCondition.h" 00025 00026 namespace itk 00027 { 00050 template< class TInputImage, class TOutputImage, class TOperatorValueType = typename TOutputImage::PixelType > 00051 class ITK_EXPORT NeighborhoodOperatorImageFilter: 00052 public ImageToImageFilter< TInputImage, TOutputImage > 00053 { 00054 public: 00056 typedef NeighborhoodOperatorImageFilter 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(NeighborhoodOperatorImageFilter, ImageToImageFilter); 00066 00069 typedef typename TOutputImage::PixelType OutputPixelType; 00070 typedef typename TOutputImage::InternalPixelType OutputInternalPixelType; 00071 typedef typename TInputImage::PixelType InputPixelType; 00072 typedef typename TInputImage::InternalPixelType InputInternalPixelType; 00073 typedef TOperatorValueType OperatorValueType; 00074 00075 typedef typename NumericTraits<InputPixelType>::ValueType InputPixelValueType; 00076 typedef typename NumericTraits<OutputPixelType>::RealType ComputingPixelType; 00077 00080 itkStaticConstMacro(ImageDimension, unsigned int, 00081 TOutputImage::ImageDimension); 00082 itkStaticConstMacro(InputImageDimension, unsigned int, 00083 TInputImage::ImageDimension); 00085 00087 typedef TInputImage InputImageType; 00088 typedef TOutputImage OutputImageType; 00089 typedef typename InputImageType::Pointer InputImagePointer; 00090 00092 typedef ImageBoundaryCondition< InputImageType > * 00093 ImageBoundaryConditionPointerType; 00094 00096 typedef ZeroFluxNeumannBoundaryCondition< InputImageType > DefaultBoundaryCondition; 00097 00099 typedef typename Superclass::OutputImageRegionType OutputImageRegionType; 00100 00102 typedef Neighborhood< OperatorValueType, 00103 itkGetStaticConstMacro(ImageDimension) > OutputNeighborhoodType; 00104 00108 void SetOperator(const OutputNeighborhoodType & p) 00109 { 00110 m_Operator = p; 00111 this->Modified(); 00112 } 00114 00116 const OutputNeighborhoodType & GetOperator() const 00117 { return m_Operator; } 00118 00124 void OverrideBoundaryCondition(const ImageBoundaryConditionPointerType i) 00125 { m_BoundsCondition = i; } 00126 00128 ImageBoundaryConditionPointerType GetBoundaryCondition() 00129 { return m_BoundsCondition; } 00130 00138 virtual void GenerateInputRequestedRegion() 00139 throw ( InvalidRequestedRegionError ); 00140 00141 #ifdef ITK_USE_CONCEPT_CHECKING 00142 00143 itkConceptMacro( SameDimensionCheck, 00144 ( Concept::SameDimension< InputImageDimension, ImageDimension > ) ); 00145 itkConceptMacro( OperatorConvertibleToOutputCheck, 00146 ( Concept::Convertible< OperatorValueType, OutputPixelType > ) ); 00147 itkConceptMacro( InputConvertibleToOperatorCheck, 00148 ( Concept::Convertible< InputPixelValueType, OperatorValueType > ) ); 00149 itkConceptMacro( OperatorMultiplyOperatorCheck, 00150 ( Concept::MultiplyOperator< OperatorValueType > ) ); 00151 itkConceptMacro( OperatorAdditiveOperatorsCheck, 00152 ( Concept::AdditiveOperators< OperatorValueType > ) ); 00153 00155 #endif 00156 protected: 00157 NeighborhoodOperatorImageFilter() 00158 { m_BoundsCondition = static_cast< ImageBoundaryConditionPointerType >( &m_DefaultBoundaryCondition ); } 00159 virtual ~NeighborhoodOperatorImageFilter() {} 00161 00173 void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, 00174 ThreadIdType threadId); 00175 00176 void PrintSelf(std::ostream & os, Indent indent) const 00177 { Superclass::PrintSelf(os, indent); } 00178 private: 00179 NeighborhoodOperatorImageFilter(const Self &); //purposely not implemented 00180 void operator=(const Self &); //purposely not implemented 00181 00183 OutputNeighborhoodType m_Operator; 00184 00187 ImageBoundaryConditionPointerType m_BoundsCondition; 00188 00190 DefaultBoundaryCondition m_DefaultBoundaryCondition; 00191 }; 00192 } // end namespace itk 00193 00194 #ifndef ITK_MANUAL_INSTANTIATION 00195 #include "itkNeighborhoodOperatorImageFilter.hxx" 00196 #endif 00197 00198 #endif 00199