ITK  6.0.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  * https://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 
56 template <typename TLabelMap,
57  typename TFeatureImage,
58  typename TOutputImage = Image<RGBPixel<typename TFeatureImage::PixelType>, TFeatureImage::ImageDimension>>
59 class ITK_TEMPLATE_EXPORT LabelMapOverlayImageFilter : public LabelMapFilter<TLabelMap, TOutputImage>
60 {
61 public:
62  ITK_DISALLOW_COPY_AND_MOVE(LabelMapOverlayImageFilter);
63 
69 
71  using LabelMapType = TLabelMap;
75  using LabelMapPixelType = typename LabelMapType::PixelType;
76  using LabelObjectType = typename LabelMapType::LabelObjectType;
77  using LabelType = typename LabelObjectType::LabelType;
78  using LengthType = typename LabelObjectType::LengthType;
79 
80  using FeatureImageType = TFeatureImage;
84  using FeatureImagePixelType = typename FeatureImageType::PixelType;
85 
86  using OutputImageType = TOutputImage;
90  using OutputImagePixelType = typename OutputImageType::PixelType;
94 
95  using FunctorType =
97 
99  static constexpr unsigned int InputImageDimension = TLabelMap::ImageDimension;
100  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
101  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
102 
104  itkNewMacro(Self);
105 
107  itkOverrideGetNameOfClassMacro(LabelMapOverlayImageFilter);
108 
110  void
111  SetFeatureImage(const TFeatureImage * input)
112  {
113  // Process object is not const-correct so the const casting is required.
114  this->SetNthInput(1, const_cast<TFeatureImage *>(input));
115  }
116 
118  const FeatureImageType *
120  {
121  return static_cast<FeatureImageType *>((this->ProcessObject::GetInput(1)));
122  }
123 
125  void
126  SetInput1(const TLabelMap * input)
127  {
128  this->SetInput(input);
129  }
130 
132  void
133  SetInput2(const TFeatureImage * input)
134  {
135  this->SetFeatureImage(input);
136  }
137 
141  itkSetMacro(Opacity, double);
142  itkGetConstReferenceMacro(Opacity, double);
148  virtual void
149  SetFunctor(const FunctorType & functor)
150  {
151  if (m_Functor != functor)
152  {
153  m_Functor = functor;
154  this->Modified();
155  }
156  }
157  FunctorType &
159  {
160  return m_Functor;
161  }
162  const FunctorType &
163  GetFunctor() const
164  {
165  return m_Functor;
166  }
169 protected:
171  ~LabelMapOverlayImageFilter() override = default;
172 
176  void
177  GenerateInputRequestedRegion() override;
178 
180  void
181  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
182 
183  void
184  GenerateData() override;
185 
186  void
187  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
188 
189  // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
190  void
192  {
193  Superclass::DynamicThreadedGenerateData(outputRegion);
194  }
195 
196  void
197  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
198 
199  void
200  GenerateOutputInformation() override;
201 
202  void
203  PrintSelf(std::ostream & os, Indent indent) const override;
204 
205 private:
206  double m_Opacity{};
207  FunctorType m_Functor{};
208 
209 }; // end of class
210 
211 } // end namespace itk
212 
213 #ifndef ITK_MANUAL_INSTANTIATION
214 # include "itkLabelMapOverlayImageFilter.hxx"
215 #endif
216 
217 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::LabelMapOverlayImageFilter::LabelObjectType
typename LabelMapType::LabelObjectType LabelObjectType
Definition: itkLabelMapOverlayImageFilter.h:76
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:149
itk::LabelMapOverlayImageFilter::SetInput2
void SetInput2(const TFeatureImage *input)
Definition: itkLabelMapOverlayImageFilter.h:133
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:78
itkLabelMapFilter.h
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
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:82
itk::LabelMapFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkLabelMapFilter.h:57
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelMapOverlayImageFilter::FeatureImageRegionType
typename FeatureImageType::RegionType FeatureImageRegionType
Definition: itkLabelMapOverlayImageFilter.h:83
itk::LabelMapOverlayImageFilter::SuperclassDynamicTGD
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Definition: itkLabelMapOverlayImageFilter.h:191
itk::LabelMapOverlayImageFilter::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkLabelMapOverlayImageFilter.h:84
itk::LabelMapOverlayImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapOverlayImageFilter.h:88
itk::LabelMapOverlayImageFilter::LabelMapRegionType
typename LabelMapType::RegionType LabelMapRegionType
Definition: itkLabelMapOverlayImageFilter.h:74
FunctorType
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkAddImageFilter.h:97
itk::LabelMapOverlayImageFilter::FunctorType
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
Definition: itkLabelMapOverlayImageFilter.h:96
itk::LabelMapOverlayImageFilter::LabelMapType
TLabelMap LabelMapType
Definition: itkLabelMapOverlayImageFilter.h:71
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::LabelMapOverlayImageFilter::SetInput1
void SetInput1(const TLabelMap *input)
Definition: itkLabelMapOverlayImageFilter.h:126
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::LabelMapOverlayImageFilter::RegionType
typename OutputImageType::RegionType RegionType
Definition: itkLabelMapOverlayImageFilter.h:93
itk::LabelMapOverlayImageFilter::SetFeatureImage
void SetFeatureImage(const TFeatureImage *input)
Definition: itkLabelMapOverlayImageFilter.h:111
itk::LabelMapOverlayImageFilter::LabelMapPixelType
typename LabelMapType::PixelType LabelMapPixelType
Definition: itkLabelMapOverlayImageFilter.h:75
itk::LabelMapOverlayImageFilter::LabelMapPointer
typename LabelMapType::Pointer LabelMapPointer
Definition: itkLabelMapOverlayImageFilter.h:72
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapOverlayImageFilter::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkLabelMapOverlayImageFilter.h:91
itk::LabelMapOverlayImageFilter::GetFeatureImage
const FeatureImageType * GetFeatureImage()
Definition: itkLabelMapOverlayImageFilter.h:119
itk::LabelMapOverlayImageFilter
Apply a colormap to a label map and superimpose it on an image.
Definition: itkLabelMapOverlayImageFilter.h:59
itk::LabelMapOverlayImageFilter::LabelMapConstPointer
typename LabelMapType::ConstPointer LabelMapConstPointer
Definition: itkLabelMapOverlayImageFilter.h:73
itk::LabelMapOverlayImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkLabelMapOverlayImageFilter.h:80
itk::LabelMapOverlayImageFilter::LabelType
typename LabelObjectType::LabelType LabelType
Definition: itkLabelMapOverlayImageFilter.h:77
itk::LabelMapOverlayImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: itkLabelMapOverlayImageFilter.h:163
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::LabelMapOverlayImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: itkLabelMapOverlayImageFilter.h:158
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:81
itk::LabelMapOverlayImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkLabelMapOverlayImageFilter.h:92