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;
139 template<
typename TInputImage,
typename TMaskImage,
typename TOutputImage = TInputImage >
142 BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage,
144 typename TInputImage::PixelType,
145 typename TMaskImage::PixelType,
146 typename TOutputImage::PixelType > >
152 typedef BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage,
154 typename TInputImage::PixelType,
155 typename TMaskImage::PixelType,
156 typename TOutputImage::PixelType >
167 BinaryFunctorImageFilter);
179 this->SetNthInput( 1, const_cast< MaskImageType * >( maskImage ) );
183 return static_cast<const MaskImageType*
>(this->ProcessObject::GetInput(1));
192 this->GetFunctor().SetOutsideValue(outsideValue);
198 return this->GetFunctor().GetOutsideValue();
207 this->GetFunctor().SetMaskingValue(maskingValue);
214 return this->GetFunctor().GetMaskingValue();
219 typedef typename TOutputImage::PixelType PixelType;
220 this->CheckOutsideValue( static_cast<PixelType*>(
nullptr) );
223 #ifdef ITK_USE_CONCEPT_CHECKING 225 itkConceptMacro( MaskEqualityComparableCheck,
226 ( Concept::EqualityComparable< typename TMaskImage::PixelType > ) );
227 itkConceptMacro( InputConvertibleToOutputCheck,
228 ( Concept::Convertible<
typename TInputImage::PixelType,
229 typename TOutputImage::PixelType > ) );
237 void PrintSelf(std::ostream & os, Indent indent)
const override 239 Superclass::PrintSelf(os, indent);
240 os << indent <<
"OutsideValue: " << this->
GetOutsideValue() << std::endl;
245 void operator=(
const Self &);
247 template <
typename TPixelType >
248 void CheckOutsideValue(
const TPixelType * ) {}
250 template <
typename TValue >
259 this->GetFunctor().GetOutsideValue();
261 zeroVector.Fill( NumericTraits< TValue >::ZeroValue() );
263 if ( currentValue == zeroVector )
265 zeroVector.SetSize( this->GetOutput()->GetVectorLength() );
266 zeroVector.Fill( NumericTraits< TValue >::ZeroValue() );
267 this->GetFunctor().SetOutsideValue( zeroVector );
270 this->GetOutput()->GetVectorLength() )
273 <<
"Number of components in OutsideValue: " 275 <<
" is not the same as the " 276 <<
"number of components in the image: " 277 << 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