ITK  4.9.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< typename TInputImage, typename TOutputImage >
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 ITK_OVERRIDE;
141 
145  void BeforeThreadedGenerateData() ITK_OVERRIDE;
146 
147  void AfterThreadedGenerateData() ITK_OVERRIDE;
148 
149  void ThreadedGenerateData(const OutputRegionType & outputRegionForThread,
150  ThreadIdType threadId) ITK_OVERRIDE;
151 
155  void GenerateInputRequestedRegion() ITK_OVERRIDE;
156 
161  void EnlargeOutputRequestedRegion( DataObject * itkNotUsed(output) ) ITK_OVERRIDE;
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(TOutputImage *output, 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
std::vector< OffsetValueType > OffsetVectorType
static const unsigned int ImageDimension
InputImageType::SizeValueType SizeValueType
static const unsigned int InputImageDimension
OffsetVectorType::const_iterator OffsetVectorConstIterator
OutputImageType::SizeType OutputSizeType
void PrintSelf(std::ostream &os, Indent indent) const override
void GenerateInputRequestedRegion() override
void SetupLineOffsets(OffsetVectorType &LineOffsets)
signed long OffsetValueType
Definition: itkIntTypes.h:154
OutputImageType::PixelType OutputImagePixelType
void EnlargeOutputRequestedRegion(DataObject *) override
Base class for all process objects that output image data.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
bool CheckNeighbors(const OutputIndexType &A, const OutputIndexType &B) const
OutputImageType::RegionType OutputRegionType
std::vector< LineEncodingType > LineMapType
SmartPointer< const Self > ConstPointer
std::vector< RunLength > LineEncodingType
OutputImageType::IndexType OutputIndexType
InputImageType::Pointer InputImagePointer
InputImageType::SizeType InputSizeType
InputImageType::IndexType InputIndexType
void CompareLines(TOutputImage *output, LineEncodingType &current, const LineEncodingType &Neighbour)
InputImageType::PixelType InputImagePixelType
OutputImageType::OffsetType OutputOffsetType
OutputImageType::PixelType OutputImagePixelType
void BeforeThreadedGenerateData() override
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
InputImageType::OffsetValueType OffsetValueType
OutputImageType::Pointer OutputImagePointer
static const unsigned int OutputImageDimension
void AfterThreadedGenerateData() override
InputImageType::PixelType InputImagePixelType
Labels the pixels on the border of the objects in a labeled image.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
LineEncodingType::iterator LineEncodingIterator
Base class for filters that take an image as input and overwrite that image as the output...
LineEncodingType::const_iterator LineEncodingConstIterator
#define itkConceptMacro(name, concept)
InputImageType::OffsetType InputOffsetType
void ThreadedGenerateData(const OutputRegionType &outputRegionForThread, ThreadIdType threadId) override
InPlaceImageFilter< TInputImage, TOutputImage > Superclass
Base class for all data objects in ITK.
InputImageType::PixelType InputPixelType