Orfeo Toolbox  3.16
itkBinaryContourImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkBinaryContourImageFilter.h,v $
5  Language: C++
6  Date: $Date: 2009-04-23 03:43:41 $
7  Version: $Revision: 1.2 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __itkBinaryContourImageFilter_h
19 #define __itkBinaryContourImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
22 #include "itkImage.h"
23 #include "itkConceptChecking.h"
24 #include <vector>
25 #include <map>
26 #include "itkProgressReporter.h"
27 #include "itkBarrier.h"
28 
29 namespace itk
30 {
31 
51 template <class TInputImage, class TOutputImage>
53  public InPlaceImageFilter< TInputImage, TOutputImage >
54 {
55 public:
61 
65  typedef typename Superclass::InputImagePointer InputImagePointer;
66 
71  typedef typename TOutputImage::PixelType OutputPixelType;
72  typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
73  typedef typename TInputImage::PixelType InputPixelType;
74  typedef typename TInputImage::InternalPixelType InputInternalPixelType;
75 
76  itkStaticConstMacro(ImageDimension, unsigned int,
77  TOutputImage::ImageDimension);
78  itkStaticConstMacro(OutputImageDimension, unsigned int,
79  TOutputImage::ImageDimension);
80  itkStaticConstMacro(InputImageDimension, unsigned int,
81  TInputImage::ImageDimension);
82 
86  typedef TInputImage InputImageType;
87  typedef typename TInputImage::IndexType IndexType;
88  typedef typename TInputImage::SizeType SizeType;
89  typedef typename TInputImage::OffsetType OffsetType;
90  typedef typename TInputImage::PixelType InputImagePixelType;
91 
92  typedef TOutputImage OutputImageType;
93  typedef typename TOutputImage::RegionType RegionType;
94  typedef typename TOutputImage::IndexType OutputIndexType;
95  typedef typename TOutputImage::SizeType OutputSizeType;
96  typedef typename TOutputImage::OffsetType OutputOffsetType;
97  typedef typename TOutputImage::PixelType OutputImagePixelType;
98 
99  typedef std::list<IndexType> ListType;
100 
106 
111 
115  itkNewMacro(Self);
116 
123  itkSetMacro(FullyConnected, bool);
124  itkGetConstReferenceMacro(FullyConnected, bool);
125  itkBooleanMacro(FullyConnected);
126 
127  // Concept checking -- input and output dimensions must be the same
128  itkConceptMacro(SameDimension,
129  (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),
130  itkGetStaticConstMacro(OutputImageDimension)>));
131 
136  itkSetMacro(BackgroundValue, OutputImagePixelType);
137  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
138 
143  itkSetMacro(ForegroundValue, InputImagePixelType);
144  itkGetConstMacro(ForegroundValue, InputImagePixelType);
145 
146 protected:
148  {
149  m_FullyConnected = false;
150  m_ForegroundValue = NumericTraits< InputImagePixelType >::max();
151  m_BackgroundValue = NumericTraits< OutputImagePixelType >::Zero;
152  m_NumberOfThreads = 0;
153  this->SetInPlace( false );
154  }
157  void PrintSelf(std::ostream& os, Indent indent) const;
158 
162  void BeforeThreadedGenerateData ();
163  void AfterThreadedGenerateData ();
164  void ThreadedGenerateData (const RegionType& outputRegionForThread, int threadId);
165 
169  void GenerateInputRequestedRegion();
170 
175  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
176 
177 private:
181 
182  // some additional types
183  typedef typename TOutputImage::RegionType::SizeType OutSizeType;
184 
185  // types to support the run length encoding of lines
186  class runLength
187  {
188  public:
189  // run length information - may be a more type safe way of doing this
190  long int length;
191  typename InputImageType::IndexType where; // Index of the start of the run
192  };
193 
194  typedef std::vector<runLength> lineEncoding;
195 
196  // the map storing lines
197  typedef std::vector<lineEncoding> LineMapType;
198 
199  typedef std::vector<long> OffsetVec;
200 
201  // the types to support union-find operations
202  typedef std::vector<unsigned long int> UnionFindType;
203 
204  bool CheckNeighbors(const OutputIndexType &A,
205  const OutputIndexType &B);
206 
207  void CompareLines(lineEncoding &current, const lineEncoding &Neighbour);
208 
209 
210  void SetupLineOffsets(OffsetVec &LineOffsets);
211 
212  void Wait()
213  {
214  if( m_NumberOfThreads > 1 )
215  {
216  m_Barrier->Wait();
217  }
218  }
219 
224 };
225 
226 } // end namespace itk
227 
228 #ifndef ITK_MANUAL_INSTANTIATION
230 #endif
231 
232 #endif

Generated at Sat Feb 2 2013 23:25:58 for Orfeo Toolbox with doxygen 1.8.1.1