ITK  6.0.0
Insight Toolkit
itkBinaryImageToLevelSetImageAdaptor.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 {
50 template <typename TInputImage, typename TLevelSet>
51 class ITK_TEMPLATE_EXPORT BinaryImageToLevelSetImageAdaptor{};
52 
53 
56 template <typename TInputImage, typename TLevelSetImage>
57 class ITK_TEMPLATE_EXPORT BinaryImageToLevelSetImageAdaptor<TInputImage, LevelSetDenseImage<TLevelSetImage>>
58  : public BinaryImageToLevelSetImageAdaptorBase<TInputImage, LevelSetDenseImage<TLevelSetImage>>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
62 
64 
69 
71  itkNewMacro(Self);
72 
74  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
75 
76  using InputImageType = TInputImage;
77  using InputImagePixelType = typename InputImageType::PixelType;
82 
83  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
84 
87 
90 
93  itkSetObjectMacro(SignedDistanceTransformFilter, SignedDistanceTransformFilterType);
94  itkGetModifiableObjectMacro(SignedDistanceTransformFilter, SignedDistanceTransformFilterType);
100  void
101  Initialize() override;
102 
103 protected:
106 
109 
110 private:
111  SignedDistanceTransformFilterPointer m_SignedDistanceTransformFilter{};
112 };
113 
115 
122 template <typename TInput, typename TOutput>
124  : public BinaryImageToLevelSetImageAdaptorBase<TInput, TOutput>
125 {
126 public:
127  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToSparseLevelSetImageAdaptorBase);
128 
133 
135  itkOverrideGetNameOfClassMacro(BinaryImageToSparseLevelSetImageAdaptorBase);
136 
137  using typename Superclass::InputImageType;
138  using typename Superclass::InputImagePixelType;
139  using typename Superclass::InputImageIndexType;
140  using typename Superclass::InputImagePointer;
141  using typename Superclass::InputImageRegionType;
142  using typename Superclass::InputPixelRealType;
143 
144  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
145 
146  using typename Superclass::LevelSetType;
147  using typename Superclass::LevelSetPointer;
148 
151 
153  using LayerIdType = typename LevelSetLabelObjectType::LabelType;
157 
160 
164 
167 
168  using LayerPairType = std::pair<LevelSetInputType, LevelSetOutputType>;
169 
172 
174 
175 protected:
177  : Superclass()
178  {}
179  ~BinaryImageToSparseLevelSetImageAdaptorBase() override = default;
180 
182 
183  InternalImagePointer m_InternalImage{};
184 };
185 
187 
189 template <typename TInput, typename TOutput>
190 class ITK_TEMPLATE_EXPORT
191  BinaryImageToLevelSetImageAdaptor<TInput, WhitakerSparseLevelSetImage<TOutput, TInput::ImageDimension>>
193  WhitakerSparseLevelSetImage<TOutput, TInput::ImageDimension>>
194 {
195 public:
196  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
197 
199 
204 
205 
207  itkNewMacro(Self);
208 
210  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
211 
212  using typename Superclass::InputImageType;
213  using typename Superclass::InputImagePixelType;
214  using typename Superclass::InputImageIndexType;
215  using typename Superclass::InputImagePointer;
216  using typename Superclass::InputImageRegionType;
217  using typename Superclass::InputPixelRealType;
218 
219  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
220 
221  using typename Superclass::LevelSetPointer;
222 
223  using typename Superclass::LevelSetInputType;
224  using typename Superclass::LevelSetOutputType;
225 
226  using typename Superclass::LevelSetLabelObjectType;
227  using typename Superclass::LayerIdType;
228  using typename Superclass::LevelSetLabelObjectPointer;
229  using typename Superclass::LevelSetLabelObjectLengthType;
230  using typename Superclass::LevelSetLabelObjectLineType;
231 
232  using typename Superclass::LevelSetLabelMapType;
233  using typename Superclass::LevelSetLabelMapPointer;
234 
235  using typename Superclass::LevelSetLayerType;
236  using typename Superclass::LevelSetLayerIterator;
237  using typename Superclass::LevelSetLayerConstIterator;
238 
239  using typename Superclass::InternalImageType;
240  using typename Superclass::InternalImagePointer;
241 
242  using typename Superclass::LayerPairType;
243 
244  using typename Superclass::InputIteratorType;
245  using typename Superclass::InternalIteratorType;
246 
247  using typename Superclass::NeighborhoodIteratorType;
248 
249  void
250  Initialize() override;
251 
252 protected:
255 
258 
259 private:
261  void
262  PropagateToOuterLayers(LayerIdType layerToBeScanned, LayerIdType outputLayer, LayerIdType testValue);
263 
265  void
266  FindActiveLayer();
267 
269  void
270  FindPlusOneMinusOneLayer();
271 };
274 
277 template <typename TInput>
278 class ITK_TEMPLATE_EXPORT BinaryImageToLevelSetImageAdaptor<TInput, ShiSparseLevelSetImage<TInput::ImageDimension>>
279  : public BinaryImageToSparseLevelSetImageAdaptorBase<TInput, ShiSparseLevelSetImage<TInput::ImageDimension>>
280 {
281 public:
282  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
283 
285 
290 
292  itkNewMacro(Self);
293 
295  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
296 
297  using typename Superclass::InputImageType;
298 
299  using typename Superclass::InputImagePixelType;
300  using typename Superclass::InputImageIndexType;
301  using typename Superclass::InputImagePointer;
302  using typename Superclass::InputImageRegionType;
303  using typename Superclass::InputPixelRealType;
304 
305  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
306 
307  // using typename Superclass::LevelSetType;
308  using typename Superclass::LevelSetPointer;
309 
310  using typename Superclass::LevelSetInputType;
311  using typename Superclass::LevelSetOutputType;
312 
313  using typename Superclass::LevelSetLabelObjectType;
314  using typename Superclass::LayerIdType;
315  using typename Superclass::LevelSetLabelObjectPointer;
316  using typename Superclass::LevelSetLabelObjectLengthType;
317  using typename Superclass::LevelSetLabelObjectLineType;
318 
319  using typename Superclass::LevelSetLabelMapType;
320  using typename Superclass::LevelSetLabelMapPointer;
321 
322  using typename Superclass::LevelSetLayerType;
323  using typename Superclass::LevelSetLayerIterator;
324  using typename Superclass::LevelSetLayerConstIterator;
325 
326  using typename Superclass::InternalImageType;
327  using typename Superclass::InternalImagePointer;
328 
329  using typename Superclass::LayerPairType;
330 
331  using typename Superclass::InputIteratorType;
332  using typename Superclass::InternalIteratorType;
333 
334  using typename Superclass::NeighborhoodIteratorType;
335 
336  void
337  Initialize() override;
338 
339 protected:
342 
345 
347  void
348  FindActiveLayer();
349 
350 private:
351 };
352 
353 
355 
357 template <typename TInput>
358 class ITK_TEMPLATE_EXPORT BinaryImageToLevelSetImageAdaptor<TInput, MalcolmSparseLevelSetImage<TInput::ImageDimension>>
359  : public BinaryImageToSparseLevelSetImageAdaptorBase<TInput, MalcolmSparseLevelSetImage<TInput::ImageDimension>>
360 {
361 public:
362  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
363 
365 
370 
371 
373  itkNewMacro(Self);
374 
376  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
377 
378  using typename Superclass::InputImageType;
379 
380  using typename Superclass::InputImagePixelType;
381  using typename Superclass::InputImageIndexType;
382  using typename Superclass::InputImagePointer;
383  using typename Superclass::InputImageRegionType;
384  using typename Superclass::InputPixelRealType;
385 
386  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
387 
388 
389  using typename Superclass::LevelSetPointer;
390  using typename Superclass::LevelSetInputType;
391  using typename Superclass::LevelSetOutputType;
392 
393  using typename Superclass::LevelSetLabelObjectType;
394  using typename Superclass::LayerIdType;
395  using typename Superclass::LevelSetLabelObjectPointer;
396  using typename Superclass::LevelSetLabelObjectLengthType;
397  using typename Superclass::LevelSetLabelObjectLineType;
398 
399  using typename Superclass::LevelSetLabelMapType;
400  using typename Superclass::LevelSetLabelMapPointer;
401 
402  using typename Superclass::LevelSetLayerType;
403  using typename Superclass::LevelSetLayerIterator;
404  using typename Superclass::LevelSetLayerConstIterator;
405 
406  using typename Superclass::InternalImageType;
407  using typename Superclass::InternalImagePointer;
408 
409  using typename Superclass::LayerPairType;
410 
411  using typename Superclass::InputIteratorType;
412  using typename Superclass::InternalIteratorType;
413 
414  using typename Superclass::NeighborhoodIteratorType;
415 
416  void
417  Initialize() override;
418 
419 protected:
422 
425 
427  void
428  FindActiveLayer();
429 
431  void
432  CreateMinimalInterface();
433 };
434 
435 } // namespace itk
436 
437 #ifndef ITK_MANUAL_INSTANTIATION
438 # include "itkBinaryImageToLevelSetImageAdaptor.hxx"
439 #endif
440 #endif // itkBinaryImageToLevelSetImageAdaptorBase_h
itk::BinaryImageToLevelSetImageAdaptor
Converts one binary image to the appropriate level-set type provided by the template argument TLevelS...
Definition: itkBinaryImageToLevelSetImageAdaptor.h:51
itk::WhitakerSparseLevelSetImage
Derived class for the sparse-field representation of level-set function.
Definition: itkWhitakerSparseLevelSetImage.h:41
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:68
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::InputImageType
TInputImage InputImageType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:76
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LayerPairType
std::pair< LevelSetInputType, LevelSetOutputType > LayerPairType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:168
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLayerIterator
typename LevelSetType::LayerIterator LevelSetLayerIterator
Definition: itkBinaryImageToLevelSetImageAdaptor.h:162
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelMapType
typename LevelSetType::LabelMapType LevelSetLabelMapType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:158
itk::LevelSetDenseImage
Base class for the "dense" representation of a level-set function on one image.
Definition: itkLevelSetDenseImage.h:41
itk::LevelSetDenseImage::ImageType
TImage ImageType
Definition: itkLevelSetDenseImage.h:47
itk::LevelSetSparseImage< int8_t, VDimension >::LabelObjectLineType
typename LabelObjectType::LineType LabelObjectLineType
Definition: itkLevelSetSparseImage.h:70
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLayerConstIterator
typename LevelSetType::LayerConstIterator LevelSetLayerConstIterator
Definition: itkBinaryImageToLevelSetImageAdaptor.h:163
itkWhitakerSparseLevelSetImage.h
itk::BinaryImageToSparseLevelSetImageAdaptorBase::BinaryImageToSparseLevelSetImageAdaptorBase
BinaryImageToSparseLevelSetImageAdaptorBase()
Definition: itkBinaryImageToLevelSetImageAdaptor.h:176
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetOutputType
typename LevelSetType::OutputType LevelSetOutputType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:150
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetInputType
typename LevelSetType::InputType LevelSetInputType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:149
itk::LevelSetSparseImage< int8_t, VDimension >::LabelMapPointer
typename LabelMapType::Pointer LabelMapPointer
Definition: itkLevelSetSparseImage.h:73
itk::SmartPointer< Self >
itkImageRegionIteratorWithIndex.h
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:77
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::InputImageIndexType
typename InputImageType::IndexType InputImageIndexType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:78
itk::ShapedNeighborhoodIterator
A neighborhood iterator which can take on an arbitrary shape.
Definition: itkShapedNeighborhoodIterator.h:150
itkMalcolmSparseLevelSetImage.h
itk::BinaryImageToSparseLevelSetImageAdaptorBase
Abstract class for converting binary image to sparse level-set.
Definition: itkBinaryImageToLevelSetImageAdaptor.h:123
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::InternalImagePointer
typename InternalImageType::Pointer InternalImagePointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:166
itk::LabelMap
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
itk::LevelSetSparseImage< int8_t, VDimension >::LabelObjectPointer
typename LabelObjectType::Pointer LabelObjectPointer
Definition: itkLevelSetSparseImage.h:68
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::InputPixelRealType
typename NumericTraits< InputImagePixelType >::RealType InputPixelRealType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:81
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::LevelSetSparseImage< int8_t, VDimension >::LayerType
std::map< InputType, OutputType, Functor::LexicographicCompare > LayerType
Definition: itkLevelSetSparseImage.h:77
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelObjectPointer
typename LevelSetType::LabelObjectPointer LevelSetLabelObjectPointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:154
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LayerIdType
typename LevelSetLabelObjectType::LabelType LayerIdType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:153
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::SignedDistanceTransformFilterPointer
typename SignedDistanceTransformFilterType::Pointer SignedDistanceTransformFilterPointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:89
itk::LabelObject
The base class for the representation of a labeled binary object in an image.
Definition: itkLabelObject.h:65
itk::LevelSetSparseImage< int8_t, VDimension >::LabelObjectLengthType
typename LabelObjectType::LengthType LabelObjectLengthType
Definition: itkLevelSetSparseImage.h:69
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::LevelSetImageType
typename LevelSetType::ImageType LevelSetImageType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:86
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:159
itk::LevelSetSparseImage< int8_t, VDimension >::LayerIterator
typename LayerType::iterator LayerIterator
Definition: itkLevelSetSparseImage.h:78
itkBinaryImageToLevelSetImageAdaptorBase.h
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelObjectLineType
typename LevelSetType::LabelObjectLineType LevelSetLabelObjectLineType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:156
itkImageToImageFilter.h
itk::ImageRegionIteratorWithIndex
A multi-dimensional iterator templated over image type that walks pixels within a region and is speci...
Definition: itkImageRegionIteratorWithIndex.h:73
itkLevelSetDenseImage.h
itkShiSparseLevelSetImage.h
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:60
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelObjectLengthType
typename LevelSetType::LabelObjectLengthType LevelSetLabelObjectLengthType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:155
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLayerType
typename LevelSetType::LayerType LevelSetLayerType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:161
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelObjectType
typename LevelSetType::LabelObjectType LevelSetLabelObjectType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:152
itk::ShiSparseLevelSetImage
Derived class for the shi representation of level-set function.
Definition: itkShiSparseLevelSetImage.h:37
itk::LevelSetSparseImage< int8_t, VDimension >::LayerConstIterator
typename LayerType::const_iterator LayerConstIterator
Definition: itkLevelSetSparseImage.h:79
itkShapedNeighborhoodIterator.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::LevelSetPointer
typename LevelSetType::Pointer LevelSetPointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:85
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::LevelSetBase< Index< VDimension >, VDimension, int8_t, ImageBase< VDimension > >::OutputType
int8_t OutputType
Definition: itkLevelSetBase.h:59
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:79
itk::MalcolmSparseLevelSetImage
Derived class for the Malcolm representation of level-set function.
Definition: itkMalcolmSparseLevelSetImage.h:41
itk::BinaryImageToLevelSetImageAdaptorBase
Definition: itkBinaryImageToLevelSetImageAdaptorBase.h:32
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:80