ITK  4.9.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 
51 template<typename TLabelMap, typename TFeatureImage, typename TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
53  public LabelMapFilter<TLabelMap, TOutputImage>
54 {
55 public:
61 
63  typedef TLabelMap LabelMapType;
64  typedef typename LabelMapType::Pointer LabelMapPointer;
65  typedef typename LabelMapType::ConstPointer LabelMapConstPointer;
66  typedef typename LabelMapType::RegionType LabelMapRegionType;
67  typedef typename LabelMapType::PixelType LabelMapPixelType;
68  typedef typename LabelMapType::LabelObjectType LabelObjectType;
69  typedef typename LabelObjectType::LabelType LabelType;
70  typedef typename LabelObjectType::LengthType LengthType;
71 
72  typedef TFeatureImage FeatureImageType;
73  typedef typename FeatureImageType::Pointer FeatureImagePointer;
74  typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
75  typedef typename FeatureImageType::RegionType FeatureImageRegionType;
76  typedef typename FeatureImageType::PixelType FeatureImagePixelType;
77 
78  typedef TOutputImage OutputImageType;
79  typedef typename OutputImageType::Pointer OutputImagePointer;
80  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
81  typedef typename OutputImageType::RegionType OutputImageRegionType;
82  typedef typename OutputImageType::PixelType OutputImagePixelType;
83  typedef typename OutputImageType::IndexType IndexType;
84  typedef typename OutputImageType::SizeType SizeType;
85  typedef typename OutputImageType::RegionType RegionType;
86 
88 
90  itkStaticConstMacro(InputImageDimension, unsigned int,
91  TLabelMap::ImageDimension);
92  itkStaticConstMacro(OutputImageDimension, unsigned int,
93  TOutputImage::ImageDimension);
94  itkStaticConstMacro(ImageDimension, unsigned int,
95  TOutputImage::ImageDimension);
97 
99  itkNewMacro(Self);
100 
102  itkTypeMacro(LabelMapOverlayImageFilter,
104 
106  void SetFeatureImage(const TFeatureImage *input)
107  {
108  // Process object is not const-correct so the const casting is required.
109  this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
110  }
111 
114  {
115  return static_cast<FeatureImageType*>((this->ProcessObject::GetInput(1)));
116  }
117 
119  void SetInput1(const TLabelMap *input)
120  {
121  this->SetInput( input );
122  }
123 
125  void SetInput2(const TFeatureImage *input)
126  {
127  this->SetFeatureImage( input );
128  }
129 
133  itkSetMacro( Opacity, double );
134  itkGetConstReferenceMacro( Opacity, double );
136 
140  virtual void SetFunctor(const FunctorType& functor)
141  {
142  if ( m_Functor != functor )
143  {
144  m_Functor = functor;
145  this->Modified();
146  }
147  }
149  const FunctorType & GetFunctor() const { return m_Functor; }
151 
152 protected:
155 
159  void GenerateInputRequestedRegion() ITK_OVERRIDE;
160 
162  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) ITK_OVERRIDE;
163 
164  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
165 
166  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
167 
168  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE;
169 
170  virtual void GenerateOutputInformation() ITK_OVERRIDE;
171 
172  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
173 
174 private:
175  LabelMapOverlayImageFilter(const Self&) ITK_DELETE_FUNCTION;
176  void operator=(const Self&) ITK_DELETE_FUNCTION;
177 
178  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)
void EnlargeOutputRequestedRegion(DataObject *) override
LabelMapFilter< TLabelMap, TOutputImage > Superclass
virtual void SetFunctor(const FunctorType &functor)
virtual void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
Base class for all process objects that output image data.
LabelMapType::ConstPointer LabelMapConstPointer
virtual void BeforeThreadedGenerateData() override
OutputImageType::ConstPointer OutputImageConstPointer
FeatureImageType::PixelType FeatureImagePixelType
FeatureImageType::RegionType FeatureImageRegionType
OutputImageType::PixelType OutputImagePixelType
virtual void SetInput(const InputImageType *image)
LabelMapType::LabelObjectType LabelObjectType
virtual void Modified() const
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...
virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
void SetInput2(const TFeatureImage *input)
static const unsigned int OutputImageDimension
FeatureImageType::ConstPointer FeatureImageConstPointer
Base class for filters that take an image as input and produce an image as output.
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void GenerateOutputInformation() override
void GenerateInputRequestedRegion() override
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
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