ITK  5.2.0
Insight Toolkit
itkLabelMapOverlayImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkLabelMapOverlayImageFilter_h
19 #define itkLabelMapOverlayImageFilter_h
20 
21 #include "itkLabelMapFilter.h"
22 #include "itkLabelOverlayFunctor.h"
23 #include "itkRGBPixel.h"
24 
25 namespace itk
26 {
27 
57 template <typename TLabelMap,
58  typename TFeatureImage,
59  typename TOutputImage = Image<RGBPixel<typename TFeatureImage::PixelType>, TFeatureImage::ImageDimension>>
60 class ITK_TEMPLATE_EXPORT LabelMapOverlayImageFilter : public LabelMapFilter<TLabelMap, TOutputImage>
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapOverlayImageFilter);
64 
70 
72  using LabelMapType = TLabelMap;
73  using LabelMapPointer = typename LabelMapType::Pointer;
74  using LabelMapConstPointer = typename LabelMapType::ConstPointer;
76  using LabelMapPixelType = typename LabelMapType::PixelType;
77  using LabelObjectType = typename LabelMapType::LabelObjectType;
78  using LabelType = typename LabelObjectType::LabelType;
79  using LengthType = typename LabelObjectType::LengthType;
80 
81  using FeatureImageType = TFeatureImage;
82  using FeatureImagePointer = typename FeatureImageType::Pointer;
83  using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
85  using FeatureImagePixelType = typename FeatureImageType::PixelType;
86 
87  using OutputImageType = TOutputImage;
88  using OutputImagePointer = typename OutputImageType::Pointer;
89  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
91  using OutputImagePixelType = typename OutputImageType::PixelType;
95 
96  using FunctorType =
98 
100  static constexpr unsigned int InputImageDimension = TLabelMap::ImageDimension;
101  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
102  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
103 
105  itkNewMacro(Self);
106 
109 
111  void
112  SetFeatureImage(const TFeatureImage * input)
113  {
114  // Process object is not const-correct so the const casting is required.
115  this->SetNthInput(1, const_cast<TFeatureImage *>(input));
116  }
117 
119  const FeatureImageType *
121  {
122  return static_cast<FeatureImageType *>((this->ProcessObject::GetInput(1)));
123  }
124 
126  void
127  SetInput1(const TLabelMap * input)
128  {
129  this->SetInput(input);
130  }
131 
133  void
134  SetInput2(const TFeatureImage * input)
135  {
136  this->SetFeatureImage(input);
137  }
138 
142  itkSetMacro(Opacity, double);
143  itkGetConstReferenceMacro(Opacity, double);
145 
149  virtual void
150  SetFunctor(const FunctorType & functor)
151  {
152  if (m_Functor != functor)
153  {
154  m_Functor = functor;
155  this->Modified();
156  }
157  }
158  FunctorType &
160  {
161  return m_Functor;
162  }
163  const FunctorType &
164  GetFunctor() const
165  {
166  return m_Functor;
167  }
169 
170 protected:
172  ~LabelMapOverlayImageFilter() override = default;
173 
177  void
178  GenerateInputRequestedRegion() override;
179 
181  void
182  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
183 
184  void
185  GenerateData() override;
186 
187  void
188  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
189 
190  // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
191  void
193  {
194  Superclass::DynamicThreadedGenerateData(outputRegion);
195  }
196 
197  void
198  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
199 
200  void
201  GenerateOutputInformation() override;
202 
203  void
204  PrintSelf(std::ostream & os, Indent indent) const override;
205 
206 private:
207  double m_Opacity;
209 
210 }; // end of class
211 
212 } // end namespace itk
213 
214 #ifndef ITK_MANUAL_INSTANTIATION
215 # include "itkLabelMapOverlayImageFilter.hxx"
216 #endif
217 
218 #endif
itk::LabelMapOverlayImageFilter::LabelObjectType
typename LabelMapType::LabelObjectType LabelObjectType
Definition: itkLabelMapOverlayImageFilter.h:77
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itkRGBPixel.h
itk::Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType >
itk::LabelMapOverlayImageFilter::SetFunctor
virtual void SetFunctor(const FunctorType &functor)
Definition: itkLabelMapOverlayImageFilter.h:150
itk::LabelMapOverlayImageFilter::SetInput2
void SetInput2(const TFeatureImage *input)
Definition: itkLabelMapOverlayImageFilter.h:134
itkLabelOverlayFunctor.h
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LabelMapOverlayImageFilter::LengthType
typename LabelObjectType::LengthType LengthType
Definition: itkLabelMapOverlayImageFilter.h:79
itkLabelMapFilter.h
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::LabelMapOverlayImageFilter::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkLabelMapOverlayImageFilter.h:83
itk::LabelMapFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkLabelMapFilter.h:58
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelMapOverlayImageFilter::FeatureImageRegionType
typename FeatureImageType::RegionType FeatureImageRegionType
Definition: itkLabelMapOverlayImageFilter.h:84
itk::LabelMapOverlayImageFilter::SuperclassDynamicTGD
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Definition: itkLabelMapOverlayImageFilter.h:192
itk::LabelMapOverlayImageFilter::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkLabelMapOverlayImageFilter.h:85
itk::LabelMapOverlayImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapOverlayImageFilter.h:89
itk::LabelMapOverlayImageFilter::LabelMapRegionType
typename LabelMapType::RegionType LabelMapRegionType
Definition: itkLabelMapOverlayImageFilter.h:75
itk::LabelMapOverlayImageFilter::m_Functor
FunctorType m_Functor
Definition: itkLabelMapOverlayImageFilter.h:208
itk::LabelMapOverlayImageFilter::FunctorType
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
Definition: itkLabelMapOverlayImageFilter.h:97
itk::LabelMapOverlayImageFilter::LabelMapType
TLabelMap LabelMapType
Definition: itkLabelMapOverlayImageFilter.h:72
itk::LabelMapOverlayImageFilter::m_Opacity
double m_Opacity
Definition: itkLabelMapOverlayImageFilter.h:207
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::LabelMapOverlayImageFilter::SetInput1
void SetInput1(const TLabelMap *input)
Definition: itkLabelMapOverlayImageFilter.h:127
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::LabelMapOverlayImageFilter::RegionType
typename OutputImageType::RegionType RegionType
Definition: itkLabelMapOverlayImageFilter.h:94
itk::LabelMapOverlayImageFilter::SetFeatureImage
void SetFeatureImage(const TFeatureImage *input)
Definition: itkLabelMapOverlayImageFilter.h:112
itk::LabelMapOverlayImageFilter::LabelMapPixelType
typename LabelMapType::PixelType LabelMapPixelType
Definition: itkLabelMapOverlayImageFilter.h:76
itk::LabelMapOverlayImageFilter::LabelMapPointer
typename LabelMapType::Pointer LabelMapPointer
Definition: itkLabelMapOverlayImageFilter.h:73
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapOverlayImageFilter::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkLabelMapOverlayImageFilter.h:92
itk::LabelMapOverlayImageFilter::GetFeatureImage
const FeatureImageType * GetFeatureImage()
Definition: itkLabelMapOverlayImageFilter.h:120
itk::LabelMapOverlayImageFilter
Apply a colormap to a label map and superimpose it on an image.
Definition: itkLabelMapOverlayImageFilter.h:60
itk::LabelMapOverlayImageFilter::LabelMapConstPointer
typename LabelMapType::ConstPointer LabelMapConstPointer
Definition: itkLabelMapOverlayImageFilter.h:74
itk::LabelMapOverlayImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkLabelMapOverlayImageFilter.h:81
itk::LabelMapOverlayImageFilter::LabelType
typename LabelObjectType::LabelType LabelType
Definition: itkLabelMapOverlayImageFilter.h:78
itk::LabelMapOverlayImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: itkLabelMapOverlayImageFilter.h:164
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::LabelMapOverlayImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: itkLabelMapOverlayImageFilter.h:159
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itk::LabelMapOverlayImageFilter::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkLabelMapOverlayImageFilter.h:82
itk::LabelMapOverlayImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkLabelMapOverlayImageFilter.h:93