ITK  4.8.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 
56 template<typename TLabelMap, typename TFeatureImage, typename TOutputImage=Image< RGBPixel< typename TFeatureImage::PixelType >, TFeatureImage::ImageDimension > >
58  public LabelMapFilter<TLabelMap, TOutputImage>
59 {
60 public:
66 
68  typedef TLabelMap LabelMapType;
69  typedef typename LabelMapType::Pointer LabelMapPointer;
70  typedef typename LabelMapType::ConstPointer LabelMapConstPointer;
71  typedef typename LabelMapType::RegionType LabelMapRegionType;
72  typedef typename LabelMapType::PixelType LabelMapPixelType;
73  typedef typename LabelMapType::LabelObjectType LabelObjectType;
74  typedef typename LabelObjectType::LabelType LabelType;
75 
76  typedef TFeatureImage FeatureImageType;
77  typedef typename FeatureImageType::Pointer FeatureImagePointer;
78  typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
79  typedef typename FeatureImageType::RegionType FeatureImageRegionType;
80  typedef typename FeatureImageType::PixelType FeatureImagePixelType;
81 
82  typedef TOutputImage OutputImageType;
83  typedef typename OutputImageType::Pointer OutputImagePointer;
84  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
85  typedef typename OutputImageType::RegionType OutputImageRegionType;
86  typedef typename OutputImageType::PixelType OutputImagePixelType;
87  typedef typename OutputImageType::IndexType IndexType;
88  typedef typename OutputImageType::SizeType SizeType;
89  typedef typename OutputImageType::RegionType RegionType;
90 
92 
94  itkStaticConstMacro(LabelMapDimension, unsigned int,
95  TLabelMap::ImageDimension);
96  itkStaticConstMacro(OutputImageDimension, unsigned int,
97  TOutputImage::ImageDimension);
98  itkStaticConstMacro(ImageDimension, unsigned int,
99  TOutputImage::ImageDimension);
101 
102  enum
103  {
104  PLAIN = 0,
105  CONTOUR = 1,
107  };
108 
109  enum
110  {
113  };
114 
116  itkNewMacro(Self);
117 
121 
123  void SetFeatureImage(TFeatureImage *input)
124  {
125  // Process object is not const-correct so the const casting is required.
126  this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
127  }
128 
131  {
132  return itkDynamicCastInDebugMode<FeatureImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
133  }
134 
136  void SetInput1(TLabelMap *input)
137  {
138  this->SetInput( input );
139  }
140 
142  void SetInput2(TFeatureImage *input)
143  {
144  this->SetFeatureImage( input );
145  }
146 
150  itkSetMacro( Opacity, double );
151  itkGetConstReferenceMacro( Opacity, double );
153 
156  itkSetMacro( Type, int );
157  itkGetConstReferenceMacro( Type, int );
159 
162  itkSetMacro( Priority, int );
163  itkGetConstReferenceMacro( Priority, int );
165 
168  itkSetMacro( DilationRadius, SizeType );
169  itkGetConstReferenceMacro( DilationRadius, SizeType );
171 
174  itkSetMacro( ContourThickness, SizeType );
175  itkGetConstReferenceMacro( ContourThickness, SizeType );
177 
180  itkSetMacro( SliceDimension, int );
181  itkGetConstReferenceMacro( SliceDimension, int );
183 
187  virtual void SetFunctor(const FunctorType & functor)
188  {
189  if ( m_Functor != functor )
190  {
191  m_Functor = functor;
192  this->Modified();
193  }
194  }
196  const FunctorType & GetFunctor() const { return m_Functor; }
198 
199 protected:
202 
206  void GenerateInputRequestedRegion() ITK_OVERRIDE;
207 
209  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) ITK_OVERRIDE;
210 
211  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
212 
213  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
214 
215  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE;
216 
217  virtual void GenerateOutputInformation() ITK_OVERRIDE;
218 
219  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
220 
221  virtual LabelMapType * GetLabelMap() ITK_OVERRIDE
222  {
223  return m_TempImage;
224  }
225 
226 private:
227  LabelMapContourOverlayImageFilter(const Self&); //purposely not implemented
228  void operator=(const Self&); //purposely not implemented
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
virtual void BeforeThreadedGenerateData() override
LabelMapFilter< TLabelMap, TOutputImage > Superclass
Apply a colormap to the contours (outlines) of each object in a label map and superimpose it on top o...
void EnlargeOutputRequestedRegion(DataObject *) override
virtual void GenerateOutputInformation() override
void PrintSelf(std::ostream &os, Indent indent) const override
Functor::LabelOverlayFunctor< FeatureImagePixelType, LabelMapPixelType, OutputImagePixelType > FunctorType
virtual void SetInput(const InputImageType *image)
virtual void SetFunctor(const FunctorType &functor)
virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
virtual void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
virtual void Modified() const
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
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
Base class for all data objects in ITK.