ITK  5.2.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  * 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 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 
58 template <typename TLabelMap,
59  typename TFeatureImage,
60  typename TOutputImage = Image<RGBPixel<typename TFeatureImage::PixelType>, TFeatureImage::ImageDimension>>
61 class ITK_TEMPLATE_EXPORT LabelMapContourOverlayImageFilter : public LabelMapFilter<TLabelMap, TOutputImage>
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapContourOverlayImageFilter);
65 
71 
73  using LabelMapType = TLabelMap;
74  using LabelMapPointer = typename LabelMapType::Pointer;
75  using LabelMapConstPointer = typename LabelMapType::ConstPointer;
77  using LabelMapPixelType = typename LabelMapType::PixelType;
78  using LabelObjectType = typename LabelMapType::LabelObjectType;
79  using LabelType = typename LabelObjectType::LabelType;
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 LabelMapDimension = TLabelMap::ImageDimension;
101  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
102  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
103 
104  enum
105  {
106  PLAIN = 0,
107  CONTOUR = 1,
108  SLICE_CONTOUR = 2
109  };
110 
111  enum
112  {
113  HIGH_LABEL_ON_TOP = 0,
114  LOW_LABEL_ON_TOP = 1
115  };
116 
118  itkNewMacro(Self);
119 
122 
124  void
125  SetFeatureImage(TFeatureImage * input)
126  {
127  // Process object is not const-correct so the const casting is required.
128  this->SetNthInput(1, const_cast<TFeatureImage *>(input));
129  }
130 
132  FeatureImageType *
134  {
135  return itkDynamicCastInDebugMode<FeatureImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
136  }
137 
139  void
140  SetInput1(TLabelMap * input)
141  {
142  this->SetInput(input);
143  }
144 
146  void
147  SetInput2(TFeatureImage * input)
148  {
149  this->SetFeatureImage(input);
150  }
151 
155  itkSetMacro(Opacity, double);
156  itkGetConstReferenceMacro(Opacity, double);
158 
161  itkSetMacro(Type, int);
162  itkGetConstReferenceMacro(Type, int);
164 
167  itkSetMacro(Priority, int);
168  itkGetConstReferenceMacro(Priority, int);
170 
173  itkSetMacro(DilationRadius, SizeType);
174  itkGetConstReferenceMacro(DilationRadius, SizeType);
176 
179  itkSetMacro(ContourThickness, SizeType);
180  itkGetConstReferenceMacro(ContourThickness, SizeType);
182 
185  itkSetMacro(SliceDimension, int);
186  itkGetConstReferenceMacro(SliceDimension, int);
188 
192  virtual void
193  SetFunctor(const FunctorType & functor)
194  {
195  if (m_Functor != functor)
196  {
197  m_Functor = functor;
198  this->Modified();
199  }
200  }
201  FunctorType &
203  {
204  return m_Functor;
205  }
206  const FunctorType &
207  GetFunctor() const
208  {
209  return m_Functor;
210  }
212 
213 protected:
215  ~LabelMapContourOverlayImageFilter() override = default;
216 
220  void
221  GenerateInputRequestedRegion() override;
222 
224  void
225  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
226 
227  void
228  BeforeThreadedGenerateData() override;
229 
230  void
231  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
232 
233  // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
234  void
236  {
237  Superclass::DynamicThreadedGenerateData(outputRegion);
238  }
239 
240  void
241  GenerateData() override;
242 
243  void
244  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
245 
246  void
247  GenerateOutputInformation() override;
248 
249  void
250  PrintSelf(std::ostream & os, Indent indent) const override;
251 
252  LabelMapType *
253  GetLabelMap() override
254  {
255  return m_TempImage;
256  }
257 
258 private:
259  double m_Opacity;
260  int m_Type;
266 
268 
269 }; // end of class
270 
271 } // end namespace itk
272 
273 #ifndef ITK_MANUAL_INSTANTIATION
274 # include "itkLabelMapContourOverlayImageFilter.hxx"
275 #endif
276 
277 #endif
itk::LabelMapContourOverlayImageFilter::FeatureImageType
TFeatureImage FeatureImageType
Definition: itkLabelMapContourOverlayImageFilter.h:81
itk::LabelMapContourOverlayImageFilter::GetLabelMap
LabelMapType * GetLabelMap() override
Definition: itkLabelMapContourOverlayImageFilter.h:253
itk::LabelMapContourOverlayImageFilter::LabelMapType
TLabelMap LabelMapType
Definition: itkLabelMapContourOverlayImageFilter.h:73
itk::LabelMapContourOverlayImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkLabelMapContourOverlayImageFilter.h:93
itk::LabelMapContourOverlayImageFilter::SetInput2
void SetInput2(TFeatureImage *input)
Definition: itkLabelMapContourOverlayImageFilter.h:147
itk::LabelMapContourOverlayImageFilter::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkLabelMapContourOverlayImageFilter.h:92
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:77
itk::LabelMapContourOverlayImageFilter::m_Functor
FunctorType m_Functor
Definition: itkLabelMapContourOverlayImageFilter.h:265
itk::LabelMapContourOverlayImageFilter::FeatureImagePointer
typename FeatureImageType::Pointer FeatureImagePointer
Definition: itkLabelMapContourOverlayImageFilter.h:82
itkLabelOverlayFunctor.h
itk::LabelMapContourOverlayImageFilter::LabelObjectType
typename LabelMapType::LabelObjectType LabelObjectType
Definition: itkLabelMapContourOverlayImageFilter.h:78
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::LabelMapContourOverlayImageFilter::m_Opacity
double m_Opacity
Definition: itkLabelMapContourOverlayImageFilter.h:259
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LabelMapContourOverlayImageFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapContourOverlayImageFilter.h:89
itk::LabelMapContourOverlayImageFilter::RegionType
typename OutputImageType::RegionType RegionType
Definition: itkLabelMapContourOverlayImageFilter.h:94
itk::LabelMapContourOverlayImageFilter::FeatureImageRegionType
typename FeatureImageType::RegionType FeatureImageRegionType
Definition: itkLabelMapContourOverlayImageFilter.h:84
itk::LabelMapContourOverlayImageFilter::GetFunctor
FunctorType & GetFunctor()
Definition: itkLabelMapContourOverlayImageFilter.h:202
itk::LabelMapContourOverlayImageFilter::GetFunctor
const FunctorType & GetFunctor() const
Definition: itkLabelMapContourOverlayImageFilter.h:207
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::LabelMapContourOverlayImageFilter::m_TempImage
LabelMapPointer m_TempImage
Definition: itkLabelMapContourOverlayImageFilter.h:267
itk::LabelMapContourOverlayImageFilter::SuperclassDynamicTGD
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Definition: itkLabelMapContourOverlayImageFilter.h:235
itk::LabelMapContourOverlayImageFilter::LabelMapPointer
typename LabelMapType::Pointer LabelMapPointer
Definition: itkLabelMapContourOverlayImageFilter.h:74
itk::LabelMapFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkLabelMapFilter.h:58
itk::LabelMapContourOverlayImageFilter::GetFeatureImage
FeatureImageType * GetFeatureImage()
Definition: itkLabelMapContourOverlayImageFilter.h:133
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelMapContourOverlayImageFilter::LabelMapConstPointer
typename LabelMapType::ConstPointer LabelMapConstPointer
Definition: itkLabelMapContourOverlayImageFilter.h:75
itk::LabelMapContourOverlayImageFilter::SetFeatureImage
void SetFeatureImage(TFeatureImage *input)
Definition: itkLabelMapContourOverlayImageFilter.h:125
itk::LabelMapContourOverlayImageFilter::m_ContourThickness
SizeType m_ContourThickness
Definition: itkLabelMapContourOverlayImageFilter.h:262
itk::LabelMapContourOverlayImageFilter::m_DilationRadius
SizeType m_DilationRadius
Definition: itkLabelMapContourOverlayImageFilter.h:263
itk::LabelMapContourOverlayImageFilter::SetInput1
void SetInput1(TLabelMap *input)
Definition: itkLabelMapContourOverlayImageFilter.h:140
itk::LabelMapContourOverlayImageFilter::m_SliceDimension
int m_SliceDimension
Definition: itkLabelMapContourOverlayImageFilter.h:264
itk::LabelMapContourOverlayImageFilter::FeatureImageConstPointer
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Definition: itkLabelMapContourOverlayImageFilter.h:83
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::LabelMapContourOverlayImageFilter::FunctorType
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
Definition: itkLabelMapContourOverlayImageFilter.h:97
itk::LabelMapContourOverlayImageFilter::SetFunctor
virtual void SetFunctor(const FunctorType &functor)
Definition: itkLabelMapContourOverlayImageFilter.h:193
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:76
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapContourOverlayImageFilter::FeatureImagePixelType
typename FeatureImageType::PixelType FeatureImagePixelType
Definition: itkLabelMapContourOverlayImageFilter.h:85
itk::LabelMapContourOverlayImageFilter::LabelType
typename LabelObjectType::LabelType LabelType
Definition: itkLabelMapContourOverlayImageFilter.h:79
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:61
itk::LabelMapContourOverlayImageFilter::m_Type
int m_Type
Definition: itkLabelMapContourOverlayImageFilter.h:260
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
itk::LabelMapContourOverlayImageFilter::m_Priority
int m_Priority
Definition: itkLabelMapContourOverlayImageFilter.h:261
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293