ITK  4.2.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<class TLabelMap, class TFeatureImage, class TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
52 class ITK_EXPORT LabelMapOverlayImageFilter :
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 
113  const FeatureImageType * GetFeatureImage()
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 
137 protected:
140 
144  void GenerateInputRequestedRegion();
145 
147  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
148 
149  virtual void BeforeThreadedGenerateData();
150 
151  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId );
152 
153  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject );
154 
155  virtual void GenerateOutputInformation();
156 
157  void PrintSelf(std::ostream& os, Indent indent) const;
158 
159 
160 private:
161  LabelMapOverlayImageFilter(const Self&); //purposely not implemented
162  void operator=(const Self&); //purposely not implemented
163 
164  double m_Opacity;
166 
167 }; // end of class
168 
169 } // end namespace itk
170 
171 #ifndef ITK_MANUAL_INSTANTIATION
172 #include "itkLabelMapOverlayImageFilter.hxx"
173 #endif
174 
175 #endif
176