ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLabelMapOverlayImageFilter.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 itkLabelMapOverlayImageFilter_h
19 #define itkLabelMapOverlayImageFilter_h
20 
21 #include "itkLabelMapFilter.h"
22 #include "itkLabelOverlayFunctor.h"
23 #include "itkRGBPixel.h"
24 
25 namespace itk {
26 
51 template<typename TLabelMap, typename TFeatureImage, typename TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
52 class ITK_TEMPLATE_EXPORT LabelMapOverlayImageFilter :
53  public LabelMapFilter<TLabelMap, TOutputImage>
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapOverlayImageFilter);
57 
63 
65  using LabelMapType = TLabelMap;
66  using LabelMapPointer = typename LabelMapType::Pointer;
67  using LabelMapConstPointer = typename LabelMapType::ConstPointer;
69  using LabelMapPixelType = typename LabelMapType::PixelType;
70  using LabelObjectType = typename LabelMapType::LabelObjectType;
71  using LabelType = typename LabelObjectType::LabelType;
72  using LengthType = typename LabelObjectType::LengthType;
73 
74  using FeatureImageType = TFeatureImage;
75  using FeatureImagePointer = typename FeatureImageType::Pointer;
76  using FeatureImageConstPointer = typename FeatureImageType::ConstPointer;
78  using FeatureImagePixelType = typename FeatureImageType::PixelType;
79 
80  using OutputImageType = TOutputImage;
81  using OutputImagePointer = typename OutputImageType::Pointer;
82  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
84  using OutputImagePixelType = typename OutputImageType::PixelType;
88 
90 
92  static constexpr unsigned int InputImageDimension = TLabelMap::ImageDimension;
93  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
94  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
95 
97  itkNewMacro(Self);
98 
100  itkTypeMacro(LabelMapOverlayImageFilter,
102 
104  void SetFeatureImage(const TFeatureImage *input)
105  {
106  // Process object is not const-correct so the const casting is required.
107  this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
108  }
109 
112  {
113  return static_cast<FeatureImageType*>((this->ProcessObject::GetInput(1)));
114  }
115 
117  void SetInput1(const TLabelMap *input)
118  {
119  this->SetInput( input );
120  }
121 
123  void SetInput2(const TFeatureImage *input)
124  {
125  this->SetFeatureImage( input );
126  }
127 
131  itkSetMacro( Opacity, double );
132  itkGetConstReferenceMacro( Opacity, double );
134 
138  virtual void SetFunctor(const FunctorType& functor)
139  {
140  if ( m_Functor != functor )
141  {
142  m_Functor = functor;
143  this->Modified();
144  }
145  }
146  FunctorType & GetFunctor() { return m_Functor; }
147  const FunctorType & GetFunctor() const { return m_Functor; }
149 
150 protected:
152  ~LabelMapOverlayImageFilter() override = default;
153 
157  void GenerateInputRequestedRegion() override;
158 
160  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) override;
161 
162  void GenerateData() override;
163 
164  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
165 
166  //part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
167  void SuperclassDynamicTGD(const OutputImageRegionType & outputRegion)
168  {
169  Superclass::DynamicThreadedGenerateData(outputRegion);
170  }
171 
172  void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override;
173 
174  void GenerateOutputInformation() override;
175 
176  void PrintSelf(std::ostream& os, Indent indent) const override;
177 
178 private:
179  double m_Opacity;
181 
182 }; // end of class
183 
184 } // end namespace itk
185 
186 #ifndef ITK_MANUAL_INSTANTIATION
187 #include "itkLabelMapOverlayImageFilter.hxx"
188 #endif
189 
190 #endif
void SetFeatureImage(const TFeatureImage *input)
typename FeatureImageType::ConstPointer FeatureImageConstPointer
typename LabelMapType::ConstPointer LabelMapConstPointer
typename OutputImageType::Pointer OutputImagePointer
typename LabelMapType::LabelObjectType LabelObjectType
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
typename FeatureImageType::PixelType FeatureImagePixelType
virtual void SetFunctor(const FunctorType &functor)
typename FeatureImageType::Pointer FeatureImagePointer
typename Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
typename OutputImageType::IndexType IndexType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename LabelMapType::PixelType LabelMapPixelType
typename OutputImageType::RegionType RegionType
Base class for all process objects that output image data.
typename OutputImageType::ConstPointer OutputImageConstPointer
typename OutputImageType::PixelType OutputImagePixelType
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename LabelObjectType::LengthType LengthType
Apply a colormap to a label map and superimpose it on an image.
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.
void SetInput2(const TFeatureImage *input)
typename LabelMapType::Pointer LabelMapPointer
Base class for filters that take an image as input and produce an image as output.
typename LabelObjectType::LabelType LabelType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename LabelMapType::RegionType LabelMapRegionType
typename FeatureImageType::RegionType FeatureImageRegionType
Base class for all data objects in ITK.
typename OutputImageType::SizeType SizeType