ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkBinaryContourImageFilter.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 itkBinaryContourImageFilter_h
19 #define itkBinaryContourImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
22 #include "itkConceptChecking.h"
23 #include "itkBarrier.h"
24 #include <vector>
25 
26 namespace itk
27 {
53 template< typename TInputImage, typename TOutputImage >
54 class ITK_TEMPLATE_EXPORT BinaryContourImageFilter:
55  public InPlaceImageFilter< TInputImage, TOutputImage >
56 {
57 public:
65 
70 
74  itkNewMacro(Self);
75 
79  typedef TInputImage InputImageType;
80  typedef typename InputImageType::Pointer InputImagePointer;
81  typedef typename InputImageType::ConstPointer InputImageConstPointer;
84  typedef typename InputImageType::OffsetType OffsetType;
85  typedef typename InputImageType::PixelType InputImagePixelType;
86  typedef typename InputImageType::InternalPixelType InputInternalPixelType;
87 
88  typedef TOutputImage OutputImageType;
89  typedef typename OutputImageType::Pointer OutputImagePointer;
90  typedef typename OutputImageType::RegionType RegionType;
93  typedef typename OutputImageType::OffsetType OutputOffsetType;
94  typedef typename OutputImageType::PixelType OutputImagePixelType;
95  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
96 
97  itkStaticConstMacro(ImageDimension, unsigned int,
98  OutputImageType::ImageDimension);
99 
100 #ifdef ITK_USE_CONCEPT_CHECKING
101  itkStaticConstMacro(InputImageDimension, unsigned int,
102  InputImageType::ImageDimension);
103 
104  // Concept checking -- input and output dimensions must be the same
105  itkConceptMacro( SameDimension,
106  ( Concept::SameDimension< itkGetStaticConstMacro(ImageDimension),
107  itkGetStaticConstMacro(OutputImageDimension) > ) );
108 #endif
109 
116  itkSetMacro(FullyConnected, bool);
117  itkGetConstReferenceMacro(FullyConnected, bool);
118  itkBooleanMacro(FullyConnected);
120 
125  itkSetMacro(BackgroundValue, OutputImagePixelType);
126  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
128 
133  itkSetMacro(ForegroundValue, InputImagePixelType);
134  itkGetConstMacro(ForegroundValue, InputImagePixelType);
136 
137 protected:
138 
141 
142  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
143 
147  void BeforeThreadedGenerateData() ITK_OVERRIDE;
148 
149  void AfterThreadedGenerateData() ITK_OVERRIDE;
150 
151  void ThreadedGenerateData(const RegionType & outputRegionForThread,
152  ThreadIdType threadId) ITK_OVERRIDE;
153 
157  void GenerateInputRequestedRegion() ITK_OVERRIDE;
158 
163  void EnlargeOutputRequestedRegion( DataObject * itkNotUsed(output) ) ITK_OVERRIDE;
164 
165 private:
166  BinaryContourImageFilter(const Self &); //Purposefully not implemented
167  void operator = ( const Self &); //Purposefully not implemented
168 
169  // types to support the run length encoding of lines
170  struct runLength
171  {
172  runLength( const OffsetValueType& iLength, const IndexType& iWhere ) :
173  m_Length( iLength ), m_Where( iWhere ) {}
174 
175  // run length information - may be a more type safe way of doing this
177 
178  // Index of the start of the run
180  };
181 
182  typedef std::vector< runLength > LineEncodingType;
183  typedef typename LineEncodingType::iterator LineEncodingIterator;
184  typedef typename LineEncodingType::const_iterator LineEncodingConstIterator;
185 
186  // the map storing lines
187  typedef std::vector< LineEncodingType > LineMapType;
188 
189  typedef std::vector< OffsetValueType > OffsetVec;
190 
191  bool CheckNeighbors(const OutputIndexType & A,
192  const OutputIndexType & B);
193 
194  void CompareLines(LineEncodingType & current,
195  const LineEncodingType & Neighbour);
196 
197  void SetupLineOffsets(OffsetVec & LineOffsets);
198 
199  void Wait();
200 
202 
206 
210 };
211 } // end namespace itk
212 
213 #ifndef ITK_MANUAL_INSTANTIATION
214 #include "itkBinaryContourImageFilter.hxx"
215 #endif
216 
217 #endif
InputImageType::ConstPointer InputImageConstPointer
OutputImageType::SizeType OutputSizeType
InputImageType::OffsetType OffsetType
signed long OffsetValueType
Definition: itkIntTypes.h:154
OutputImageType::InternalPixelType OutputInternalPixelType
OutputImageType::IndexType OutputIndexType
Base class for all process objects that output image data.
InputImageType::InternalPixelType InputInternalPixelType
LineEncodingType::iterator LineEncodingIterator
OutputImageType::PixelType OutputImagePixelType
OutputImageType::RegionType RegionType
InPlaceImageFilter< TInputImage, TOutputImage > Superclass
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
runLength(const OffsetValueType &iLength, const IndexType &iWhere)
OutputImageType::Pointer OutputImagePointer
InputImageType::PixelType InputImagePixelType
InputImageType::PixelType InputImagePixelType
std::vector< OffsetValueType > OffsetVec
Base class for filters that take an image as input and produce an image as output.
std::vector< LineEncodingType > LineMapType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Labels the pixels on the border of the objects in a binary image.
Base class for filters that take an image as input and overwrite that image as the output...
#define itkConceptMacro(name, concept)
LineEncodingType::const_iterator LineEncodingConstIterator
Base class for all data objects in ITK.
SmartPointer< const Self > ConstPointer
OutputImageType::PixelType OutputImagePixelType
OutputImageType::OffsetType OutputOffsetType