ITK  5.3.0
Insight Toolkit
itkLabelMapContourOverlayImageFilter.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 itkLabelMapContourOverlayImageFilter_h
19 #define itkLabelMapContourOverlayImageFilter_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 LabelMapContourOverlayImageFilter : public LabelMapFilter<TLabelMap, TOutputImage>
61 {
62 public:
63  ITK_DISALLOW_COPY_AND_MOVE(LabelMapContourOverlayImageFilter);
64 
70 
72  using LabelMapType = TLabelMap;
76  using LabelMapPixelType = typename LabelMapType::PixelType;
77  using LabelObjectType = typename LabelMapType::LabelObjectType;
78  using LabelType = typename LabelObjectType::LabelType;
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 LabelMapDimension = TLabelMap::ImageDimension;
100  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
101  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
102 
103  enum
104  {
105  PLAIN = 0,
106  CONTOUR = 1,
107  SLICE_CONTOUR = 2
108  };
109 
110  enum
111  {
112  HIGH_LABEL_ON_TOP = 0,
113  LOW_LABEL_ON_TOP = 1
114  };
115 
117  itkNewMacro(Self);
118 
121 
123  void
124  SetFeatureImage(TFeatureImage * input)
125  {
126  // Process object is not const-correct so the const casting is required.
127  this->SetNthInput(1, const_cast<TFeatureImage *>(input));
128  }
129 
131  FeatureImageType *
133  {
134  return itkDynamicCastInDebugMode<FeatureImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
135  }
136 
138  void
139  SetInput1(TLabelMap * input)
140  {
141  this->SetInput(input);
142  }
143 
145  void
146  SetInput2(TFeatureImage * input)
147  {
148  this->SetFeatureImage(input);
149  }
150 
154  itkSetMacro(Opacity, double);
155  itkGetConstReferenceMacro(Opacity, double);
160  itkSetMacro(Type, int);
161  itkGetConstReferenceMacro(Type, int);
166  itkSetMacro(Priority, int);
167  itkGetConstReferenceMacro(Priority, int);
172  itkSetMacro(DilationRadius, SizeType);
173  itkGetConstReferenceMacro(DilationRadius, SizeType);
178  itkSetMacro(ContourThickness, SizeType);
179  itkGetConstReferenceMacro(ContourThickness, SizeType);
184  itkSetMacro(SliceDimension, int);
185  itkGetConstReferenceMacro(SliceDimension, int);
191  virtual void
192  SetFunctor(const FunctorType & functor)
193  {
194  if (m_Functor != functor)
195  {
196  m_Functor = functor;
197  this->Modified();
198  }
199  }
200  FunctorType &
202  {
203  return m_Functor;
204  }
205  const FunctorType &
206  GetFunctor() const
207  {
208  return m_Functor;
209  }
212 protected:
214  ~LabelMapContourOverlayImageFilter() override = default;
215 
219  void
220  GenerateInputRequestedRegion() override;
221 
223  void
224  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
225 
226  void
227  BeforeThreadedGenerateData() override;
228 
229  void
230  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
231 
232  // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
233  void
235  {
236  Superclass::DynamicThreadedGenerateData(outputRegion);
237  }
238 
239  void
240  GenerateData() override;
241 
242  void
243  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
244 
245  void
246  GenerateOutputInformation() override;
247 
248  void
249  PrintSelf(std::ostream & os, Indent indent) const override;
250 
251  LabelMapType *
252  GetLabelMap() override
253  {
254  return m_TempImage;
255  }
256 
257 private:
258  double m_Opacity;
259  int m_Type;
265 
267 
268 }; // end of class
269 
270 } // end namespace itk
271 
272 #ifndef ITK_MANUAL_INSTANTIATION
273 # include "itkLabelMapContourOverlayImageFilter.hxx"
274 #endif
275 
276 #endif
itk::LabelMapContourOverlayImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkLabelMapContourOverlayImageFilter.h:80
itk::LabelMapContourOverlayImageFilter::GetLabelMap
LabelMapType * GetLabelMap() override
Definition: itkLabelMapContourOverlayImageFilter.h:252
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:92
itk::LabelMapContourOverlayImageFilter::LabelMapType
TLabelMap LabelMapType
Definition: itkLabelMapContourOverlayImageFilter.h:72
itk::LabelMapContourOverlayImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkLabelMapContourOverlayImageFilter.h:92
itk::LabelMapContourOverlayImageFilter::SetInput2
void SetInput2(TFeatureImage *input)
Definition: itkLabelMapContourOverlayImageFilter.h:146
itk::LabelMapContourOverlayImageFilter::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkLabelMapContourOverlayImageFilter.h:91
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:93
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itkRGBPixel.h
itk::Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType >
itk::LabelMapContourOverlayImageFilter::LabelMapPixelType
typename LabelMapType::PixelType LabelMapPixelType
Definition: itkLabelMapContourOverlayImageFilter.h:76
itk::LabelMapContourOverlayImageFilter::m_Functor
FunctorType m_Functor
Definition: itkLabelMapContourOverlayImageFilter.h:264
itk::LabelMapContourOverlayImageFilter::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkLabelMapContourOverlayImageFilter.h:81
itkLabelOverlayFunctor.h
itk::LabelMapContourOverlayImageFilter::LabelObjectType
typename LabelMapType::LabelObjectType LabelObjectType
Definition: itkLabelMapContourOverlayImageFilter.h:77
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::LabelMapContourOverlayImageFilter::m_Opacity
double m_Opacity
Definition: itkLabelMapContourOverlayImageFilter.h:258
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LabelMapContourOverlayImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapContourOverlayImageFilter.h:88
itk::LabelMapContourOverlayImageFilter::RegionType
typename OutputImageType::RegionType RegionType
Definition: itkLabelMapContourOverlayImageFilter.h:93
itk::LabelMapContourOverlayImageFilter::FeatureImageRegionType
typename FeatureImageType::RegionType FeatureImageRegionType
Definition: itkLabelMapContourOverlayImageFilter.h:83
itk::LabelMapContourOverlayImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: itkLabelMapContourOverlayImageFilter.h:201
itk::LabelMapContourOverlayImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: itkLabelMapContourOverlayImageFilter.h:206
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::LabelMapContourOverlayImageFilter::m_TempImage
LabelMapPointer m_TempImage
Definition: itkLabelMapContourOverlayImageFilter.h:266
itk::LabelMapContourOverlayImageFilter::SuperclassDynamicTGD
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Definition: itkLabelMapContourOverlayImageFilter.h:234
itk::LabelMapContourOverlayImageFilter::LabelMapPointer
typename LabelMapType::Pointer LabelMapPointer
Definition: itkLabelMapContourOverlayImageFilter.h:73
itk::LabelMapFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkLabelMapFilter.h:57
itk::LabelMapContourOverlayImageFilter::GetFeatureImage
FeatureImageType * GetFeatureImage()
Definition: itkLabelMapContourOverlayImageFilter.h:132
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelMapContourOverlayImageFilter::LabelMapConstPointer
typename LabelMapType::ConstPointer LabelMapConstPointer
Definition: itkLabelMapContourOverlayImageFilter.h:74
itk::LabelMapContourOverlayImageFilter::SetFeatureImage
void SetFeatureImage(TFeatureImage *input)
Definition: itkLabelMapContourOverlayImageFilter.h:124
FunctorType
Functor::Add2< typename TInputImage1::PixelType, typename TInputImage2::PixelType, typename TOutputImage::PixelType > FunctorType
Definition: itkAddImageFilter.h:96
itk::LabelMapContourOverlayImageFilter::m_ContourThickness
SizeType m_ContourThickness
Definition: itkLabelMapContourOverlayImageFilter.h:261
itk::LabelMapContourOverlayImageFilter::m_DilationRadius
SizeType m_DilationRadius
Definition: itkLabelMapContourOverlayImageFilter.h:262
itk::LabelMapContourOverlayImageFilter::SetInput1
void SetInput1(TLabelMap *input)
Definition: itkLabelMapContourOverlayImageFilter.h:139
itk::LabelMapContourOverlayImageFilter::m_SliceDimension
int m_SliceDimension
Definition: itkLabelMapContourOverlayImageFilter.h:263
itk::LabelMapContourOverlayImageFilter::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkLabelMapContourOverlayImageFilter.h:82
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::LabelMapContourOverlayImageFilter::FunctorType
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
Definition: itkLabelMapContourOverlayImageFilter.h:96
itk::LabelMapContourOverlayImageFilter::SetFunctor
virtual void SetFunctor(const FunctorType &functor)
Definition: itkLabelMapContourOverlayImageFilter.h:192
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::LabelMapContourOverlayImageFilter::LabelMapRegionType
typename LabelMapType::RegionType LabelMapRegionType
Definition: itkLabelMapContourOverlayImageFilter.h:75
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapContourOverlayImageFilter::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkLabelMapContourOverlayImageFilter.h:84
itk::LabelMapContourOverlayImageFilter::LabelType
typename LabelObjectType::LabelType LabelType
Definition: itkLabelMapContourOverlayImageFilter.h:78
AddImageFilter
Definition: itkAddImageFilter.h:80
itk::LabelMapContourOverlayImageFilter
Apply a colormap to the contours (outlines) of each object in a label map and superimpose it on top o...
Definition: itkLabelMapContourOverlayImageFilter.h:60
itk::LabelMapContourOverlayImageFilter::m_Type
int m_Type
Definition: itkLabelMapContourOverlayImageFilter.h:259
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::LabelMapContourOverlayImageFilter::m_Priority
int m_Priority
Definition: itkLabelMapContourOverlayImageFilter.h:260
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293