ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLabelMapContourOverlayImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 
56 template<typename TLabelMap, typename TFeatureImage, typename TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
57 class ITK_TEMPLATE_EXPORT LabelMapContourOverlayImageFilter :
58  public LabelMapFilter<TLabelMap, TOutputImage>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapContourOverlayImageFilter);
62 
68 
70  using LabelMapType = TLabelMap;
71  using LabelMapPointer = typename LabelMapType::Pointer;
72  using LabelMapConstPointer = typename LabelMapType::ConstPointer;
74  using LabelMapPixelType = typename LabelMapType::PixelType;
75  using LabelObjectType = typename LabelMapType::LabelObjectType;
76  using LabelType = typename LabelObjectType::LabelType;
77 
78  using FeatureImageType = TFeatureImage;
79  using FeatureImagePointer = typename FeatureImageType::Pointer;
80  using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
82  using FeatureImagePixelType = typename FeatureImageType::PixelType;
83 
84  using OutputImageType = TOutputImage;
85  using OutputImagePointer = typename OutputImageType::Pointer;
86  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
88  using OutputImagePixelType = typename OutputImageType::PixelType;
92 
94 
96  static constexpr unsigned int LabelMapDimension = TLabelMap::ImageDimension;
97  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
98  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
99 
100  enum
101  {
102  PLAIN = 0,
103  CONTOUR = 1,
104  SLICE_CONTOUR=2
105  };
106 
107  enum
108  {
109  HIGH_LABEL_ON_TOP = 0,
110  LOW_LABEL_ON_TOP = 1
111  };
112 
114  itkNewMacro(Self);
115 
119 
121  void SetFeatureImage(TFeatureImage *input)
122  {
123  // Process object is not const-correct so the const casting is required.
124  this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
125  }
126 
129  {
130  return itkDynamicCastInDebugMode<FeatureImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
131  }
132 
134  void SetInput1(TLabelMap *input)
135  {
136  this->SetInput( input );
137  }
138 
140  void SetInput2(TFeatureImage *input)
141  {
142  this->SetFeatureImage( input );
143  }
144 
148  itkSetMacro( Opacity, double );
149  itkGetConstReferenceMacro( Opacity, double );
151 
154  itkSetMacro( Type, int );
155  itkGetConstReferenceMacro( Type, int );
157 
160  itkSetMacro( Priority, int );
161  itkGetConstReferenceMacro( Priority, int );
163 
166  itkSetMacro( DilationRadius, SizeType );
167  itkGetConstReferenceMacro( DilationRadius, SizeType );
169 
172  itkSetMacro( ContourThickness, SizeType );
173  itkGetConstReferenceMacro( ContourThickness, SizeType );
175 
178  itkSetMacro( SliceDimension, int );
179  itkGetConstReferenceMacro( SliceDimension, int );
181 
185  virtual void SetFunctor(const FunctorType & functor)
186  {
187  if ( m_Functor != functor )
188  {
189  m_Functor = functor;
190  this->Modified();
191  }
192  }
193  FunctorType & GetFunctor() { return m_Functor; }
194  const FunctorType & GetFunctor() const { return m_Functor; }
196 
197 protected:
199  ~LabelMapContourOverlayImageFilter() override = default;
200 
204  void GenerateInputRequestedRegion() override;
205 
207  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) override;
208 
209  void BeforeThreadedGenerateData() override;
210 
211  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
212 
213  //part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
214  void SuperclassDynamicTGD(const OutputImageRegionType & outputRegion)
215  {
216  Superclass::DynamicThreadedGenerateData(outputRegion);
217  }
218 
219  void GenerateData() override;
220 
221  void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override;
222 
223  void GenerateOutputInformation() override;
224 
225  void PrintSelf(std::ostream& os, Indent indent) const override;
226 
228  {
229  return m_TempImage;
230  }
231 
232 private:
233  double m_Opacity;
234  int m_Type;
240 
242 
243 }; // end of class
244 
245 } // end namespace itk
246 
247 #ifndef ITK_MANUAL_INSTANTIATION
248 #include "itkLabelMapContourOverlayImageFilter.hxx"
249 #endif
250 
251 #endif
typename OutputImageType::Pointer OutputImagePointer
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
typename FeatureImageType::RegionType FeatureImageRegionType
typename FeatureImageType::ConstPointer FeatureImageConstPointer
Apply a colormap to the contours (outlines) of each object in a label map and superimpose it on top o...
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename LabelMapType::LabelObjectType LabelObjectType
typename OutputImageType::PixelType OutputImagePixelType
virtual void SetFunctor(const FunctorType &functor)
typename FeatureImageType::PixelType FeatureImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Base class for filters that take an image as input and overwrite that image as the output...
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename LabelMapType::ConstPointer LabelMapConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Base class for all data objects in ITK.