ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkBinaryImageToLevelSetImageAdaptor.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 
19 #ifndef itkBinaryImageToLevelSetImageAdaptor_h
20 #define itkBinaryImageToLevelSetImageAdaptor_h
21 
23 
24 #include "itkLevelSetDenseImage.h"
25 #include "itkImageToImageFilter.h"
26 
30 
33 
34 namespace itk
35 {
49 template< typename TInputImage, typename TLevelSet >
51 {};
52 
53 
56 template< typename TInputImage, typename TLevelSetImage >
58  TInputImage,
59  LevelSetDenseImage< TLevelSetImage > > :
61  TInputImage,
62  LevelSetDenseImage< TLevelSetImage > >
63 {
64 public:
66 
71  TInputImage, LevelSetType > Superclass;
72 
74  itkNewMacro( Self );
75 
78 
79  typedef TInputImage InputImageType;
80  typedef typename InputImageType::PixelType InputImagePixelType;
81  typedef typename InputImageType::IndexType InputImageIndexType;
82  typedef typename InputImageType::Pointer InputImagePointer;
83  typedef typename InputImageType::RegionType InputImageRegionType;
86 
87  itkStaticConstMacro ( ImageDimension, unsigned int,
88  InputImageType::ImageDimension );
89 
92 
95 
98  itkSetObjectMacro( SignedDistanceTransformFilter, SignedDistanceTransformFilterType );
99  itkGetModifiableObjectMacro(SignedDistanceTransformFilter, SignedDistanceTransformFilterType );
101 
105  void Initialize() ITK_OVERRIDE;
106 
107 protected:
110 
112  virtual ~BinaryImageToLevelSetImageAdaptor();
113 
114 private:
115  BinaryImageToLevelSetImageAdaptor( const Self& ) ITK_DELETE_FUNCTION;
116  void operator = ( const Self& ) ITK_DELETE_FUNCTION;
117 
118  SignedDistanceTransformFilterPointer m_SignedDistanceTransformFilter;
119 };
120 
122 
128 template< typename TInput, typename TOutput >
130  public BinaryImageToLevelSetImageAdaptorBase< TInput, TOutput >
131 {
132 public:
138 
142 
143  typedef typename Superclass::InputImageType InputImageType;
144  typedef typename Superclass::InputImagePixelType InputImagePixelType;
145  typedef typename Superclass::InputImageIndexType InputImageIndexType;
146  typedef typename Superclass::InputImagePointer InputImagePointer;
147  typedef typename Superclass::InputImageRegionType InputImageRegionType;
148  typedef typename Superclass::InputPixelRealType InputPixelRealType;
149 
150  itkStaticConstMacro ( ImageDimension, unsigned int,
151  InputImageType::ImageDimension );
152 
153  typedef typename Superclass::LevelSetType LevelSetType;
154  typedef typename Superclass::LevelSetPointer LevelSetPointer;
155 
156  typedef typename LevelSetType::InputType LevelSetInputType;
157  typedef typename LevelSetType::OutputType LevelSetOutputType;
158 
159  typedef typename LevelSetType::LabelObjectType LevelSetLabelObjectType;
160  typedef typename LevelSetLabelObjectType::LabelType LayerIdType;
161  typedef typename LevelSetType::LabelObjectPointer LevelSetLabelObjectPointer;
162  typedef typename LevelSetType::LabelObjectLengthType LevelSetLabelObjectLengthType;
163  typedef typename LevelSetType::LabelObjectLineType LevelSetLabelObjectLineType;
164 
165  typedef typename LevelSetType::LabelMapType LevelSetLabelMapType;
166  typedef typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer;
167 
168  typedef typename LevelSetType::LayerType LevelSetLayerType;
169  typedef typename LevelSetType::LayerIterator LevelSetLayerIterator;
170  typedef typename LevelSetType::LayerConstIterator LevelSetLayerConstIterator;
171 
174 
175  typedef std::pair< LevelSetInputType, LevelSetOutputType > LayerPairType;
176 
179 
181 
182 protected:
185 
186  LevelSetLabelMapPointer m_LabelMap;
187 
188  InternalImagePointer m_InternalImage;
189 
190 private:
192  void operator = ( const Self& );
193 };
194 
196 
198 template< typename TInput, typename TOutput >
200  TInput,
201  WhitakerSparseLevelSetImage< TOutput, TInput::ImageDimension > > :
203  TInput,
204  WhitakerSparseLevelSetImage< TOutput, TInput::ImageDimension > >
205  {
206 public:
209 
215 
216 
218  itkNewMacro( Self );
219 
221  itkTypeMacro( BinaryImageToLevelSetImageAdaptor,
223 
225  typedef typename Superclass::InputImagePixelType InputImagePixelType;
226  typedef typename Superclass::InputImageIndexType InputImageIndexType;
227  typedef typename Superclass::InputImagePointer InputImagePointer;
228  typedef typename Superclass::InputImageRegionType InputImageRegionType;
229  typedef typename Superclass::InputPixelRealType InputPixelRealType;
230 
231  itkStaticConstMacro ( ImageDimension, unsigned int,
232  InputImageType::ImageDimension );
233 
234  typedef typename Superclass::LevelSetPointer LevelSetPointer;
235 
236  typedef typename Superclass::LevelSetInputType LevelSetInputType;
237  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
238 
239  typedef typename Superclass::LevelSetLabelObjectType LevelSetLabelObjectType;
240  typedef typename Superclass::LayerIdType LayerIdType;
241  typedef typename Superclass::LevelSetLabelObjectPointer LevelSetLabelObjectPointer;
242  typedef typename Superclass::LevelSetLabelObjectLengthType LevelSetLabelObjectLengthType;
243  typedef typename Superclass::LevelSetLabelObjectLineType LevelSetLabelObjectLineType;
244 
245  typedef typename Superclass::LevelSetLabelMapType LevelSetLabelMapType;
246  typedef typename Superclass::LevelSetLabelMapPointer LevelSetLabelMapPointer;
247 
248  typedef typename Superclass::LevelSetLayerType LevelSetLayerType;
249  typedef typename Superclass::LevelSetLayerIterator LevelSetLayerIterator;
250  typedef typename Superclass::LevelSetLayerConstIterator LevelSetLayerConstIterator;
251 
252  typedef typename Superclass::InternalImageType InternalImageType;
253  typedef typename Superclass::InternalImagePointer InternalImagePointer;
254 
255  typedef typename Superclass::LayerPairType LayerPairType;
256 
257  typedef typename Superclass::InputIteratorType InputIteratorType;
258  typedef typename Superclass::InternalIteratorType InternalIteratorType;
259 
260  typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
261 
262  void Initialize() ITK_OVERRIDE;
263 
264 protected:
267 
269  virtual ~BinaryImageToLevelSetImageAdaptor();
270 
271 private:
272 
273  BinaryImageToLevelSetImageAdaptor( const Self& ) ITK_DELETE_FUNCTION;
274  void operator = ( const Self& ) ITK_DELETE_FUNCTION;
275 
277  void PropagateToOuterLayers( LayerIdType LayerToBeScanned, LayerIdType OutputLayer, LayerIdType TestValue );
278 
280  void FindActiveLayer();
281 
283  void FindPlusOneMinusOneLayer();
284 
285 };
286 
288 
290 template< typename TInput >
291 class BinaryImageToLevelSetImageAdaptor<
292  TInput,
293  ShiSparseLevelSetImage< TInput::ImageDimension > > :
295  TInput,
296  ShiSparseLevelSetImage< TInput::ImageDimension > >
297 {
298 public:
300 
301  typedef BinaryImageToLevelSetImageAdaptor Self;
305  TInput, LevelSetType > Superclass;
306 
308  itkNewMacro( Self );
309 
311  itkTypeMacro( BinaryImageToLevelSetImageAdaptor,
313 
315 
316  typedef typename Superclass::InputImagePixelType InputImagePixelType;
317  typedef typename Superclass::InputImageIndexType InputImageIndexType;
318  typedef typename Superclass::InputImagePointer InputImagePointer;
319  typedef typename Superclass::InputImageRegionType InputImageRegionType;
320  typedef typename Superclass::InputPixelRealType InputPixelRealType;
321 
322  itkStaticConstMacro ( ImageDimension, unsigned int,
323  InputImageType::ImageDimension );
324 
325 // typedef typename Superclass::LevelSetType LevelSetType;
326  typedef typename Superclass::LevelSetPointer LevelSetPointer;
327 
328  typedef typename Superclass::LevelSetInputType LevelSetInputType;
329  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
330 
331  typedef typename Superclass::LevelSetLabelObjectType LevelSetLabelObjectType;
332  typedef typename Superclass::LayerIdType LayerIdType;
333  typedef typename Superclass::LevelSetLabelObjectPointer LevelSetLabelObjectPointer;
334  typedef typename Superclass::LevelSetLabelObjectLengthType LevelSetLabelObjectLengthType;
335  typedef typename Superclass::LevelSetLabelObjectLineType LevelSetLabelObjectLineType;
336 
337  typedef typename Superclass::LevelSetLabelMapType LevelSetLabelMapType;
338  typedef typename Superclass::LevelSetLabelMapPointer LevelSetLabelMapPointer;
339 
340  typedef typename Superclass::LevelSetLayerType LevelSetLayerType;
341  typedef typename Superclass::LevelSetLayerIterator LevelSetLayerIterator;
342  typedef typename Superclass::LevelSetLayerConstIterator LevelSetLayerConstIterator;
343 
344  typedef typename Superclass::InternalImageType InternalImageType;
345  typedef typename Superclass::InternalImagePointer InternalImagePointer;
346 
347  typedef typename Superclass::LayerPairType LayerPairType;
348 
349  typedef typename Superclass::InputIteratorType InputIteratorType;
350  typedef typename Superclass::InternalIteratorType InternalIteratorType;
351 
352  typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
353 
354  void Initialize() ITK_OVERRIDE;
355 
356 protected:
358  BinaryImageToLevelSetImageAdaptor();
359 
361  ~BinaryImageToLevelSetImageAdaptor();
362 
364  void FindActiveLayer();
365 
366 private:
367 
368  BinaryImageToLevelSetImageAdaptor( const Self& ) ITK_DELETE_FUNCTION;
369  void operator = ( const Self& ) ITK_DELETE_FUNCTION;
370 };
371 
372 
374 
376 template< typename TInput >
377 class BinaryImageToLevelSetImageAdaptor<
378  TInput,
379  MalcolmSparseLevelSetImage< TInput::ImageDimension > > :
380  public BinaryImageToSparseLevelSetImageAdaptorBase< TInput, MalcolmSparseLevelSetImage< TInput::ImageDimension > >
381 {
382 public:
384 
385  typedef BinaryImageToLevelSetImageAdaptor Self;
389  TInput, LevelSetType > Superclass;
390 
391 
393  itkNewMacro( Self );
394 
396  itkTypeMacro( BinaryImageToLevelSetImageAdaptor,
398 
400 
401  typedef typename Superclass::InputImagePixelType InputImagePixelType;
402  typedef typename Superclass::InputImageIndexType InputImageIndexType;
403  typedef typename Superclass::InputImagePointer InputImagePointer;
404  typedef typename Superclass::InputImageRegionType InputImageRegionType;
405  typedef typename Superclass::InputPixelRealType InputPixelRealType;
406 
407  itkStaticConstMacro ( ImageDimension, unsigned int,
408  InputImageType::ImageDimension );
409 
410 
411  typedef typename Superclass::LevelSetPointer LevelSetPointer;
412  typedef typename Superclass::LevelSetInputType LevelSetInputType;
413  typedef typename Superclass::LevelSetOutputType LevelSetOutputType;
414 
415  typedef typename Superclass::LevelSetLabelObjectType LevelSetLabelObjectType;
416  typedef typename Superclass::LayerIdType LayerIdType;
417  typedef typename Superclass::LevelSetLabelObjectPointer LevelSetLabelObjectPointer;
418  typedef typename Superclass::LevelSetLabelObjectLengthType LevelSetLabelObjectLengthType;
419  typedef typename Superclass::LevelSetLabelObjectLineType LevelSetLabelObjectLineType;
420 
421  typedef typename Superclass::LevelSetLabelMapType LevelSetLabelMapType;
422  typedef typename Superclass::LevelSetLabelMapPointer LevelSetLabelMapPointer;
423 
424  typedef typename Superclass::LevelSetLayerType LevelSetLayerType;
425  typedef typename Superclass::LevelSetLayerIterator LevelSetLayerIterator;
426  typedef typename Superclass::LevelSetLayerConstIterator LevelSetLayerConstIterator;
427 
428  typedef typename Superclass::InternalImageType InternalImageType;
429  typedef typename Superclass::InternalImagePointer InternalImagePointer;
430 
431  typedef typename Superclass::LayerPairType LayerPairType;
432 
433  typedef typename Superclass::InputIteratorType InputIteratorType;
434  typedef typename Superclass::InternalIteratorType InternalIteratorType;
435 
436  typedef typename Superclass::NeighborhoodIteratorType NeighborhoodIteratorType;
437 
438  void Initialize() ITK_OVERRIDE;
439 
440 protected:
442  BinaryImageToLevelSetImageAdaptor();
443 
445  virtual ~BinaryImageToLevelSetImageAdaptor();
446 
448  void FindActiveLayer();
449 
451  void CreateMinimalInterface();
452 
453 private:
454 
455  BinaryImageToLevelSetImageAdaptor( const Self& ) ITK_DELETE_FUNCTION;
456  void operator = ( const Self& ) ITK_DELETE_FUNCTION;
457 };
458 
459 }
460 
461 #ifndef ITK_MANUAL_INSTANTIATION
462 #include "itkBinaryImageToLevelSetImageAdaptor.hxx"
463 #endif
464 #endif // itkBinaryImageToLevelSetImageAdaptorBase_h
ImageRegionIteratorWithIndex< InputImageType > InputIteratorType
Light weight base class for most itk classes.
Derived class for the shi representation of level-set function.
std::pair< LevelSetInputType, LevelSetOutputType > LayerPairType
ImageRegionIteratorWithIndex< InternalImageType > InternalIteratorType
A neighborhood iterator which can take on an arbitrary shape.
Derived class for the Malcolm representation of level-set function.
Derived class for the sparse-field representation of level-set function.
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
Base class for the &quot;dense&quot; representation of a level-set function on one image.
ShapedNeighborhoodIterator< InternalImageType > NeighborhoodIteratorType
BinaryImageToLevelSetImageAdaptorBase< TInput, TOutput > Superclass
Base class for filters that take an image as input and produce an image as output.
Abstract class for converting binary image to sparse level-set.
Define additional traits for native types such as int or float.
Base class for most ITK classes.
Definition: itkObject.h:57
Templated n-dimensional image class.
Definition: itkImage.h:75