ITK  4.13.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 "itkBarrier.h"
23 #include "itkLabelOverlayFunctor.h"
24 #include "itkRGBPixel.h"
25 
26 namespace itk {
27 
57 template<typename TLabelMap, typename TFeatureImage, typename TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
58 class ITK_TEMPLATE_EXPORT LabelMapContourOverlayImageFilter :
59  public LabelMapFilter<TLabelMap, TOutputImage>
60 {
61 public:
67 
69  typedef TLabelMap LabelMapType;
70  typedef typename LabelMapType::Pointer LabelMapPointer;
71  typedef typename LabelMapType::ConstPointer LabelMapConstPointer;
72  typedef typename LabelMapType::RegionType LabelMapRegionType;
73  typedef typename LabelMapType::PixelType LabelMapPixelType;
74  typedef typename LabelMapType::LabelObjectType LabelObjectType;
75  typedef typename LabelObjectType::LabelType LabelType;
76 
77  typedef TFeatureImage FeatureImageType;
78  typedef typename FeatureImageType::Pointer FeatureImagePointer;
79  typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
80  typedef typename FeatureImageType::RegionType FeatureImageRegionType;
81  typedef typename FeatureImageType::PixelType FeatureImagePixelType;
82 
83  typedef TOutputImage OutputImageType;
84  typedef typename OutputImageType::Pointer OutputImagePointer;
85  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
86  typedef typename OutputImageType::RegionType OutputImageRegionType;
87  typedef typename OutputImageType::PixelType OutputImagePixelType;
90  typedef typename OutputImageType::RegionType RegionType;
91 
93 
95  itkStaticConstMacro(LabelMapDimension, unsigned int,
96  TLabelMap::ImageDimension);
97  itkStaticConstMacro(OutputImageDimension, unsigned int,
98  TOutputImage::ImageDimension);
99  itkStaticConstMacro(ImageDimension, unsigned int,
100  TOutputImage::ImageDimension);
102 
103  enum
104  {
105  PLAIN = 0,
106  CONTOUR = 1,
107  SLICE_CONTOUR=2
108  };
109 
110  enum
111  {
112  HIGH_LABEL_ON_TOP = 0,
113  LOW_LABEL_ON_TOP = 1
114  };
115 
117  itkNewMacro(Self);
118 
122 
124  void SetFeatureImage(TFeatureImage *input)
125  {
126  // Process object is not const-correct so the const casting is required.
127  this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
128  }
129 
132  {
133  return itkDynamicCastInDebugMode<FeatureImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
134  }
135 
137  void SetInput1(TLabelMap *input)
138  {
139  this->SetInput( input );
140  }
141 
143  void SetInput2(TFeatureImage *input)
144  {
145  this->SetFeatureImage( input );
146  }
147 
151  itkSetMacro( Opacity, double );
152  itkGetConstReferenceMacro( Opacity, double );
154 
157  itkSetMacro( Type, int );
158  itkGetConstReferenceMacro( Type, int );
160 
163  itkSetMacro( Priority, int );
164  itkGetConstReferenceMacro( Priority, int );
166 
169  itkSetMacro( DilationRadius, SizeType );
170  itkGetConstReferenceMacro( DilationRadius, SizeType );
172 
175  itkSetMacro( ContourThickness, SizeType );
176  itkGetConstReferenceMacro( ContourThickness, SizeType );
178 
181  itkSetMacro( SliceDimension, int );
182  itkGetConstReferenceMacro( SliceDimension, int );
184 
188  virtual void SetFunctor(const FunctorType & functor)
189  {
190  if ( m_Functor != functor )
191  {
192  m_Functor = functor;
193  this->Modified();
194  }
195  }
196  FunctorType & GetFunctor() { return m_Functor; }
197  const FunctorType & GetFunctor() const { return m_Functor; }
199 
200 protected:
203 
207  void GenerateInputRequestedRegion() ITK_OVERRIDE;
208 
210  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) ITK_OVERRIDE;
211 
212  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
213 
214  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
215 
216  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE;
217 
218  virtual void GenerateOutputInformation() ITK_OVERRIDE;
219 
220  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
221 
222  virtual LabelMapType * GetLabelMap() ITK_OVERRIDE
223  {
224  return m_TempImage;
225  }
226 
227 private:
228  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapContourOverlayImageFilter);
229 
230  double m_Opacity;
232  int m_Type;
238 
240 
241 }; // end of class
242 
243 } // end namespace itk
244 
245 #ifndef ITK_MANUAL_INSTANTIATION
246 #include "itkLabelMapContourOverlayImageFilter.hxx"
247 #endif
248 
249 #endif
LabelMapFilter< TLabelMap, TOutputImage > Superclass
Apply a colormap to the contours (outlines) of each object in a label map and superimpose it on top o...
Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
virtual void SetFunctor(const FunctorType &functor)
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.
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.