ITK  4.13.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 "itkBarrier.h"
23 #include "itkLabelOverlayFunctor.h"
24 #include "itkRGBPixel.h"
25 
26 namespace itk {
27 
52 template<typename TLabelMap, typename TFeatureImage, typename TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
53 class ITK_TEMPLATE_EXPORT LabelMapOverlayImageFilter :
54  public LabelMapFilter<TLabelMap, TOutputImage>
55 {
56 public:
62 
64  typedef TLabelMap LabelMapType;
65  typedef typename LabelMapType::Pointer LabelMapPointer;
66  typedef typename LabelMapType::ConstPointer LabelMapConstPointer;
67  typedef typename LabelMapType::RegionType LabelMapRegionType;
68  typedef typename LabelMapType::PixelType LabelMapPixelType;
69  typedef typename LabelMapType::LabelObjectType LabelObjectType;
70  typedef typename LabelObjectType::LabelType LabelType;
71  typedef typename LabelObjectType::LengthType LengthType;
72 
73  typedef TFeatureImage FeatureImageType;
74  typedef typename FeatureImageType::Pointer FeatureImagePointer;
75  typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
76  typedef typename FeatureImageType::RegionType FeatureImageRegionType;
77  typedef typename FeatureImageType::PixelType FeatureImagePixelType;
78 
79  typedef TOutputImage OutputImageType;
80  typedef typename OutputImageType::Pointer OutputImagePointer;
81  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
82  typedef typename OutputImageType::RegionType OutputImageRegionType;
83  typedef typename OutputImageType::PixelType OutputImagePixelType;
86  typedef typename OutputImageType::RegionType RegionType;
87 
89 
91  itkStaticConstMacro(InputImageDimension, unsigned int,
92  TLabelMap::ImageDimension);
93  itkStaticConstMacro(OutputImageDimension, unsigned int,
94  TOutputImage::ImageDimension);
95  itkStaticConstMacro(ImageDimension, unsigned int,
96  TOutputImage::ImageDimension);
98 
100  itkNewMacro(Self);
101 
103  itkTypeMacro(LabelMapOverlayImageFilter,
105 
107  void SetFeatureImage(const TFeatureImage *input)
108  {
109  // Process object is not const-correct so the const casting is required.
110  this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
111  }
112 
115  {
116  return static_cast<FeatureImageType*>((this->ProcessObject::GetInput(1)));
117  }
118 
120  void SetInput1(const TLabelMap *input)
121  {
122  this->SetInput( input );
123  }
124 
126  void SetInput2(const TFeatureImage *input)
127  {
128  this->SetFeatureImage( input );
129  }
130 
134  itkSetMacro( Opacity, double );
135  itkGetConstReferenceMacro( Opacity, double );
137 
141  virtual void SetFunctor(const FunctorType& functor)
142  {
143  if ( m_Functor != functor )
144  {
145  m_Functor = functor;
146  this->Modified();
147  }
148  }
149  FunctorType & GetFunctor() { return m_Functor; }
150  const FunctorType & GetFunctor() const { return m_Functor; }
152 
153 protected:
155  ~LabelMapOverlayImageFilter() ITK_OVERRIDE {};
156 
160  void GenerateInputRequestedRegion() ITK_OVERRIDE;
161 
163  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) ITK_OVERRIDE;
164 
165  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
166 
167  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
168 
169  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE;
170 
171  virtual void GenerateOutputInformation() ITK_OVERRIDE;
172 
173  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
174 
175 private:
176  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapOverlayImageFilter);
177 
178  double m_Opacity;
179  typename Barrier::Pointer m_Barrier;
180  FunctorType m_Functor;
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)
LabelMapFilter< TLabelMap, TOutputImage > Superclass
virtual void SetFunctor(const FunctorType &functor)
Base class for all process objects that output image data.
LabelMapType::ConstPointer LabelMapConstPointer
OutputImageType::ConstPointer OutputImageConstPointer
FeatureImageType::PixelType FeatureImagePixelType
FeatureImageType::RegionType FeatureImageRegionType
OutputImageType::PixelType OutputImagePixelType
LabelMapType::LabelObjectType LabelObjectType
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...
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
void SetInput2(const TFeatureImage *input)
FeatureImageType::ConstPointer FeatureImageConstPointer
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
Base class for all data objects in ITK.
OutputImageType::RegionType OutputImageRegionType
Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
Standard barrier class implementation for synchronizing the execution of threads. ...
Definition: itkBarrier.h:41