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*>( ITK_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,
171 BinaryFunctorImageFilter);
183 this->SetNthInput( 1, const_cast< MaskImageType * >( maskImage ) );
187 return static_cast<const MaskImageType*
>(this->ProcessObject::GetInput(1));
193 if ( this->GetOutsideValue() != outsideValue )
196 this->GetFunctor().SetOutsideValue(outsideValue);
202 return this->GetFunctor().GetOutsideValue();
208 if ( this->GetMaskingValue() != maskingValue )
211 this->GetFunctor().SetMaskingValue(maskingValue);
218 return this->GetFunctor().GetMaskingValue();
224 this->CheckOutsideValue( static_cast<PixelType*>(ITK_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,
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 >
255 void CheckOutsideValue(
const VariableLengthVector< TValue > * )
262 VariableLengthVector< TValue > currentValue =
263 this->GetFunctor().GetOutsideValue();
264 VariableLengthVector< TValue > zeroVector( currentValue.GetSize() );
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 );
273 else if ( this->GetFunctor().GetOutsideValue().GetSize() !=
274 this->GetOutput()->GetVectorLength() )
277 <<
"Number of components in OutsideValue: "
278 << this->GetFunctor().GetOutsideValue().GetSize()
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)
void BeforeThreadedGenerateData()
void PrintSelf(std::ostream &os, Indent indent) const
#define MITKIMAGESTATISTICS_EXPORT
SmartPointer< Self > Pointer
const MaskImageType * GetMaskImage()
virtual ~MaskImageFilter2()
SmartPointer< const Self > ConstPointer
void SetMaskingValue(const typename TMaskImage::PixelType &maskingValue)
const TOutputImage::PixelType & GetOutsideValue() const
BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage, Functor::MaskInput2< typename TInputImage::PixelType, typename TMaskImage::PixelType, typename TOutputImage::PixelType > > Superclass
const TMaskImage::PixelType & GetMaskingValue() const