Medical Imaging Interaction Toolkit  2021.10.99-9c07a326
Medical Imaging Interaction Toolkit
itkMultiOutputNaryFunctorImageFilter.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef __itkMultiOutputNaryFunctorImageFilter_h
14 #define __itkMultiOutputNaryFunctorImageFilter_h
15 
16 #include "itkImageToImageFilter.h"
17 #include "itkImageIterator.h"
18 #include "itkArray.h"
19 
20 namespace itk
21 {
41 template< class TInputImage, class TOutputImage, class TFunction, class TMaskImage = ::itk::Image<unsigned char, TInputImage::ImageDimension> >
43  public ImageToImageFilter< TInputImage, TOutputImage >
44 
45 {
46 public:
49  typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
53  itkNewMacro(Self);
54 
56  itkTypeMacro(MultiOutputNaryFunctorImageFilter, ImageToImageFilter);
57 
59  typedef TFunction FunctorType;
60  typedef TInputImage InputImageType;
61  typedef typename InputImageType::Pointer InputImagePointer;
62  typedef typename InputImageType::RegionType InputImageRegionType;
63  typedef typename InputImageType::PixelType InputImagePixelType;
64  typedef TOutputImage OutputImageType;
65  typedef typename OutputImageType::Pointer OutputImagePointer;
66  typedef typename OutputImageType::RegionType OutputImageRegionType;
67  typedef typename OutputImageType::PixelType OutputImagePixelType;
68  typedef typename FunctorType::InputPixelArrayType NaryInputArrayType;
69  typedef typename FunctorType::OutputPixelArrayType NaryOutputArrayType;
70  typedef TMaskImage MaskImageType;
71  typedef typename MaskImageType::Pointer MaskImagePointer;
72  typedef typename MaskImageType::RegionType MaskImageRegionType;
73 
78  FunctorType & GetFunctor() { return m_Functor; }
79 
86  void SetFunctor(FunctorType & functor)
87  {
88  if ( m_Functor != functor )
89  {
90  m_Functor = functor;
91  this->ActualizeOutputs();
92  this->Modified();
93  }
94  }
95 
96  itkSetObjectMacro(Mask, MaskImageType);
97  itkGetConstObjectMacro(Mask, MaskImageType);
98 
100  itkStaticConstMacro(
101  InputImageDimension, unsigned int, TInputImage::ImageDimension);
102  itkStaticConstMacro(
103  OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
104 
105 #ifdef ITK_USE_CONCEPT_CHECKING
106 
107  itkConceptMacro( SameDimensionCheck,
108  ( Concept::SameDimension< InputImageDimension, OutputImageDimension > ) );
109  itkConceptMacro( OutputHasZeroCheck,
110  ( Concept::HasZero< OutputImagePixelType > ) );
112 #endif
113 protected:
116 
127  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
128  ThreadIdType threadId) override;
129 
131  void ActualizeOutputs();
132 
133 private:
134  MultiOutputNaryFunctorImageFilter(const Self &); //purposely not implemented
135  void operator=(const Self &); //purposely not implemented
136 
137  FunctorType m_Functor;
138  MaskImagePointer m_Mask;
139 };
140 } // end namespace itk
141 
142 #ifndef ITK_MANUAL_INSTANTIATION
143 #include "itkMultiOutputNaryFunctorImageFilter.tpp"
144 #endif
145 
146 #endif
Perform a generic pixel-wise operation on N images and produces m output images.
ImageToImageFilter< TInputImage, TOutputImage > Superclass