18 #ifndef __itkMaskImageFilter2_h 19 #define __itkMaskImageFilter2_h 21 #include "itkBinaryFunctorImageFilter.h" 22 #include "itkNumericTraits.h" 23 #include "itkVariableLengthVector.h" 35 template<
typename TInput,
typename TMask,
typename TOutput = TInput >
43 m_MaskingValue = NumericTraits< TMask >::ZeroValue();
44 InitializeOutsideValue( static_cast<TOutput*>(
nullptr ) );
54 return !( *
this != other );
57 inline TOutput
operator()(
const TInput & A,
const TMask & B)
const 59 if ( B == m_MaskingValue )
61 return static_cast< TOutput
>( A );
65 return m_OutsideValue;
72 m_OutsideValue = outsideValue;
78 return m_OutsideValue;
84 m_MaskingValue = maskingValue;
89 return m_MaskingValue;
94 template <
typename TPixelType >
95 void InitializeOutsideValue( TPixelType * )
97 this->m_OutsideValue = NumericTraits< TPixelType >::ZeroValue();
100 template <
typename TValue >
107 TOutput m_OutsideValue;
108 TMask m_MaskingValue;
143 template<
typename TInputImage,
typename TMaskImage,
typename TOutputImage = TInputImage >
146 BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage,
148 typename TInputImage::PixelType,
149 typename TMaskImage::PixelType,
150 typename TOutputImage::PixelType > >
156 typedef BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage,
158 typename TInputImage::PixelType,
159 typename TMaskImage::PixelType,
160 typename TOutputImage::PixelType >
171 BinaryFunctorImageFilter);
183 this->SetNthInput( 1, const_cast< MaskImageType * >( maskImage ) );
187 return static_cast<const MaskImageType*
>(this->ProcessObject::GetInput(1));
196 this->GetFunctor().SetOutsideValue(outsideValue);
202 return this->GetFunctor().GetOutsideValue();
211 this->GetFunctor().SetMaskingValue(maskingValue);
218 return this->GetFunctor().GetMaskingValue();
223 typedef typename TOutputImage::PixelType PixelType;
224 this->CheckOutsideValue( static_cast<PixelType*>(
nullptr) );
227 #ifdef ITK_USE_CONCEPT_CHECKING 229 itkConceptMacro( MaskEqualityComparableCheck,
230 ( Concept::EqualityComparable< typename TMaskImage::PixelType > ) );
231 itkConceptMacro( InputConvertibleToOutputCheck,
232 ( Concept::Convertible<
typename TInputImage::PixelType,
233 typename TOutputImage::PixelType > ) );
241 void PrintSelf(std::ostream & os, Indent indent)
const override 243 Superclass::PrintSelf(os, indent);
244 os << indent <<
"OutsideValue: " << this->
GetOutsideValue() << std::endl;
249 void operator=(
const Self &);
251 template <
typename TPixelType >
252 void CheckOutsideValue(
const TPixelType * ) {}
254 template <
typename TValue >
263 this->GetFunctor().GetOutsideValue();
265 zeroVector.Fill( NumericTraits< TValue >::ZeroValue() );
267 if ( currentValue == zeroVector )
269 zeroVector.SetSize( this->GetOutput()->GetVectorLength() );
270 zeroVector.Fill( NumericTraits< TValue >::ZeroValue() );
271 this->GetFunctor().SetOutsideValue( zeroVector );
274 this->GetOutput()->GetVectorLength() )
277 <<
"Number of components in OutsideValue: " 279 <<
" is not the same as the " 280 <<
"number of components in the image: " 281 << this->GetOutput()->GetVectorLength());
void SetOutsideValue(const typename TOutputImage::PixelType &outsideValue)
void SetMaskImage(const MaskImageType *maskImage)
#define MITKIMAGESTATISTICS_EXPORT
SmartPointer< Self > Pointer
const MaskImageType * GetMaskImage()
const TOutputImage::PixelType & GetOutsideValue() const
void PrintSelf(std::ostream &os, Indent indent) const override
SmartPointer< const Self > ConstPointer
void SetMaskingValue(const typename TMaskImage::PixelType &maskingValue)
const TMaskImage::PixelType & GetMaskingValue() const
~MaskImageFilter2() override
BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage, Functor::MaskInput2< typename TInputImage::PixelType, typename TMaskImage::PixelType, typename TOutputImage::PixelType > > Superclass
void BeforeThreadedGenerateData() override