ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkLabelContourImageFilter.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 __itkLabelContourImageFilter_h
19 #define __itkLabelContourImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
22 #include "itkImage.h"
23 #include "itkConceptChecking.h"
24 #include <vector>
25 #include "itkBarrier.h"
26 
27 namespace itk
28 {
55 template< class TInputImage, class TOutputImage >
56 class ITK_EXPORT LabelContourImageFilter:
57  public InPlaceImageFilter< TInputImage, TOutputImage >
58 {
59 public:
67 
71  itkNewMacro(Self);
72 
77 
78  itkStaticConstMacro(ImageDimension, unsigned int,
79  TOutputImage::ImageDimension);
80 
81 #ifdef ITK_USE_CONCEPT_CHECKING
82 
83  itkStaticConstMacro(InputImageDimension, unsigned int,
84  TInputImage::ImageDimension);
85 
86  itkStaticConstMacro(OutputImageDimension, unsigned int,
87  TOutputImage::ImageDimension);
88 
89  itkConceptMacro( SameDimension,
90  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageDimension),
91  itkGetStaticConstMacro(OutputImageDimension) > ) );
92 
93 #endif
94 
98  typedef TInputImage InputImageType;
99  typedef typename InputImageType::Pointer InputImagePointer;
100  typedef typename InputImageType::IndexType InputIndexType;
101  typedef typename InputImageType::SizeType InputSizeType;
102  typedef typename InputImageType::OffsetType InputOffsetType;
103  typedef typename InputImageType::PixelType InputImagePixelType;
106  typedef typename InputImageType::PixelType InputPixelType;
107 
108  typedef TOutputImage OutputImageType;
109  typedef typename OutputImageType::Pointer OutputImagePointer;
110  typedef typename OutputImageType::RegionType OutputRegionType;
111  typedef typename OutputImageType::IndexType OutputIndexType;
112  typedef typename OutputImageType::SizeType OutputSizeType;
113  typedef typename OutputImageType::OffsetType OutputOffsetType;
114  typedef typename OutputImageType::PixelType OutputImagePixelType;
115 
122  itkSetMacro(FullyConnected, bool);
123  itkGetConstReferenceMacro(FullyConnected, bool);
124  itkBooleanMacro(FullyConnected);
126 
131  itkSetMacro(BackgroundValue, OutputImagePixelType);
132  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
134 
135 protected:
136 
139 
140  void PrintSelf(std::ostream & os, Indent indent) const;
141 
145  void BeforeThreadedGenerateData();
146 
147  void AfterThreadedGenerateData();
148 
149  void ThreadedGenerateData(const OutputRegionType & outputRegionForThread,
150  ThreadIdType threadId);
151 
155  void GenerateInputRequestedRegion();
156 
161  void EnlargeOutputRequestedRegion( DataObject * itkNotUsed(output) );
162 
163 private:
164 
165  LabelContourImageFilter(const Self &);
166  void operator = ( const Self& );
167 
169  struct RunLength
170  {
171 
174 
177 
179  };
180 
181  typedef std::vector< RunLength > LineEncodingType;
182  typedef typename LineEncodingType::iterator LineEncodingIterator;
183  typedef typename LineEncodingType::const_iterator LineEncodingConstIterator;
184 
185  typedef std::vector< OffsetValueType > OffsetVectorType;
186  typedef typename OffsetVectorType::const_iterator OffsetVectorConstIterator;
187 
188  // the map storing lines
189  typedef std::vector< LineEncodingType > LineMapType;
190 
195 
196  bool CheckNeighbors(const OutputIndexType & A,
197  const OutputIndexType & B) const;
198 
199  void CompareLines(LineEncodingType & current, const LineEncodingType & Neighbour);
200 
201  void SetupLineOffsets(OffsetVectorType & LineOffsets);
202 
203  void Wait();
204 
206 
207 };
208 } // end namespace itk
209 
210 #ifndef ITK_MANUAL_INSTANTIATION
211 #include "itkLabelContourImageFilter.hxx"
212 #endif
213 
214 #endif
215