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 
54 
57 template <typename TInputImage, typename TLevelSetImage>
58 class ITK_TEMPLATE_EXPORT BinaryImageToLevelSetImageAdaptor<TInputImage, LevelSetDenseImage<TLevelSetImage>>
59  : public BinaryImageToLevelSetImageAdaptorBase<TInputImage, LevelSetDenseImage<TLevelSetImage>>
60 {
61 public:
62  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
63 
65 
70 
72  itkNewMacro(Self);
73 
75  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
76 
77  using InputImageType = TInputImage;
78  using InputImagePixelType = typename InputImageType::PixelType;
83 
84  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
85 
88 
91 
94  itkSetObjectMacro(SignedDistanceTransformFilter, SignedDistanceTransformFilterType);
95  itkGetModifiableObjectMacro(SignedDistanceTransformFilter, SignedDistanceTransformFilterType);
101  void
102  Initialize() override;
103 
104 protected:
107 
110 
111 private:
112  SignedDistanceTransformFilterPointer m_SignedDistanceTransformFilter{};
113 };
114 
116 
123 template <typename TInput, typename TOutput>
125  : public BinaryImageToLevelSetImageAdaptorBase<TInput, TOutput>
126 {
127 public:
128  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToSparseLevelSetImageAdaptorBase);
129 
134 
136  itkOverrideGetNameOfClassMacro(BinaryImageToSparseLevelSetImageAdaptorBase);
137 
138  using typename Superclass::InputImageType;
139  using typename Superclass::InputImagePixelType;
140  using typename Superclass::InputImageIndexType;
141  using typename Superclass::InputImagePointer;
142  using typename Superclass::InputImageRegionType;
143  using typename Superclass::InputPixelRealType;
144 
145  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
146 
147  using typename Superclass::LevelSetType;
148  using typename Superclass::LevelSetPointer;
149 
152 
154  using LayerIdType = typename LevelSetLabelObjectType::LabelType;
158 
161 
165 
168 
169  using LayerPairType = std::pair<LevelSetInputType, LevelSetOutputType>;
170 
173 
175 
176 protected:
178  : Superclass()
179  {}
180  ~BinaryImageToSparseLevelSetImageAdaptorBase() override = default;
181 
183 
184  InternalImagePointer m_InternalImage{};
185 };
186 
188 
190 template <typename TInput, typename TOutput>
191 class ITK_TEMPLATE_EXPORT
192  BinaryImageToLevelSetImageAdaptor<TInput, WhitakerSparseLevelSetImage<TOutput, TInput::ImageDimension>>
194  WhitakerSparseLevelSetImage<TOutput, TInput::ImageDimension>>
195 {
196 public:
197  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
198 
200 
205 
206 
208  itkNewMacro(Self);
209 
211  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
212 
213  using typename Superclass::InputImageType;
214  using typename Superclass::InputImagePixelType;
215  using typename Superclass::InputImageIndexType;
216  using typename Superclass::InputImagePointer;
217  using typename Superclass::InputImageRegionType;
218  using typename Superclass::InputPixelRealType;
219 
220  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
221 
222  using typename Superclass::LevelSetPointer;
223 
224  using typename Superclass::LevelSetInputType;
225  using typename Superclass::LevelSetOutputType;
226 
227  using typename Superclass::LevelSetLabelObjectType;
228  using typename Superclass::LayerIdType;
229  using typename Superclass::LevelSetLabelObjectPointer;
230  using typename Superclass::LevelSetLabelObjectLengthType;
231  using typename Superclass::LevelSetLabelObjectLineType;
232 
233  using typename Superclass::LevelSetLabelMapType;
234  using typename Superclass::LevelSetLabelMapPointer;
235 
236  using typename Superclass::LevelSetLayerType;
237  using typename Superclass::LevelSetLayerIterator;
238  using typename Superclass::LevelSetLayerConstIterator;
239 
240  using typename Superclass::InternalImageType;
241  using typename Superclass::InternalImagePointer;
242 
243  using typename Superclass::LayerPairType;
244 
245  using typename Superclass::InputIteratorType;
246  using typename Superclass::InternalIteratorType;
247 
248  using typename Superclass::NeighborhoodIteratorType;
249 
250  void
251  Initialize() override;
252 
253 protected:
256 
259 
260 private:
262  void
263  PropagateToOuterLayers(LayerIdType layerToBeScanned, LayerIdType outputLayer, LayerIdType testValue);
264 
266  void
267  FindActiveLayer();
268 
270  void
271  FindPlusOneMinusOneLayer();
272 };
275 
278 template <typename TInput>
279 class ITK_TEMPLATE_EXPORT BinaryImageToLevelSetImageAdaptor<TInput, ShiSparseLevelSetImage<TInput::ImageDimension>>
280  : public BinaryImageToSparseLevelSetImageAdaptorBase<TInput, ShiSparseLevelSetImage<TInput::ImageDimension>>
281 {
282 public:
283  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
284 
286 
291 
293  itkNewMacro(Self);
294 
296  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
297 
298  using typename Superclass::InputImageType;
299 
300  using typename Superclass::InputImagePixelType;
301  using typename Superclass::InputImageIndexType;
302  using typename Superclass::InputImagePointer;
303  using typename Superclass::InputImageRegionType;
304  using typename Superclass::InputPixelRealType;
305 
306  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
307 
308  // using typename Superclass::LevelSetType;
309  using typename Superclass::LevelSetPointer;
310 
311  using typename Superclass::LevelSetInputType;
312  using typename Superclass::LevelSetOutputType;
313 
314  using typename Superclass::LevelSetLabelObjectType;
315  using typename Superclass::LayerIdType;
316  using typename Superclass::LevelSetLabelObjectPointer;
317  using typename Superclass::LevelSetLabelObjectLengthType;
318  using typename Superclass::LevelSetLabelObjectLineType;
319 
320  using typename Superclass::LevelSetLabelMapType;
321  using typename Superclass::LevelSetLabelMapPointer;
322 
323  using typename Superclass::LevelSetLayerType;
324  using typename Superclass::LevelSetLayerIterator;
325  using typename Superclass::LevelSetLayerConstIterator;
326 
327  using typename Superclass::InternalImageType;
328  using typename Superclass::InternalImagePointer;
329 
330  using typename Superclass::LayerPairType;
331 
332  using typename Superclass::InputIteratorType;
333  using typename Superclass::InternalIteratorType;
334 
335  using typename Superclass::NeighborhoodIteratorType;
336 
337  void
338  Initialize() override;
339 
340 protected:
343 
346 
348  void
349  FindActiveLayer();
350 
351 private:
352 };
353 
354 
356 
358 template <typename TInput>
359 class ITK_TEMPLATE_EXPORT BinaryImageToLevelSetImageAdaptor<TInput, MalcolmSparseLevelSetImage<TInput::ImageDimension>>
360  : public BinaryImageToSparseLevelSetImageAdaptorBase<TInput, MalcolmSparseLevelSetImage<TInput::ImageDimension>>
361 {
362 public:
363  ITK_DISALLOW_COPY_AND_MOVE(BinaryImageToLevelSetImageAdaptor);
364 
366 
371 
372 
374  itkNewMacro(Self);
375 
377  itkOverrideGetNameOfClassMacro(BinaryImageToLevelSetImageAdaptor);
378 
379  using typename Superclass::InputImageType;
380 
381  using typename Superclass::InputImagePixelType;
382  using typename Superclass::InputImageIndexType;
383  using typename Superclass::InputImagePointer;
384  using typename Superclass::InputImageRegionType;
385  using typename Superclass::InputPixelRealType;
386 
387  static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
388 
389 
390  using typename Superclass::LevelSetPointer;
391  using typename Superclass::LevelSetInputType;
392  using typename Superclass::LevelSetOutputType;
393 
394  using typename Superclass::LevelSetLabelObjectType;
395  using typename Superclass::LayerIdType;
396  using typename Superclass::LevelSetLabelObjectPointer;
397  using typename Superclass::LevelSetLabelObjectLengthType;
398  using typename Superclass::LevelSetLabelObjectLineType;
399 
400  using typename Superclass::LevelSetLabelMapType;
401  using typename Superclass::LevelSetLabelMapPointer;
402 
403  using typename Superclass::LevelSetLayerType;
404  using typename Superclass::LevelSetLayerIterator;
405  using typename Superclass::LevelSetLayerConstIterator;
406 
407  using typename Superclass::InternalImageType;
408  using typename Superclass::InternalImagePointer;
409 
410  using typename Superclass::LayerPairType;
411 
412  using typename Superclass::InputIteratorType;
413  using typename Superclass::InternalIteratorType;
414 
415  using typename Superclass::NeighborhoodIteratorType;
416 
417  void
418  Initialize() override;
419 
420 protected:
423 
426 
428  void
429  FindActiveLayer();
430 
432  void
433  CreateMinimalInterface();
434 };
435 
436 } // namespace itk
437 
438 #ifndef ITK_MANUAL_INSTANTIATION
439 # include "itkBinaryImageToLevelSetImageAdaptor.hxx"
440 #endif
441 #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:77
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LayerPairType
std::pair< LevelSetInputType, LevelSetOutputType > LayerPairType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:169
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLayerIterator
typename LevelSetType::LayerIterator LevelSetLayerIterator
Definition: itkBinaryImageToLevelSetImageAdaptor.h:163
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelMapType
typename LevelSetType::LabelMapType LevelSetLabelMapType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:159
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:164
itkWhitakerSparseLevelSetImage.h
itk::BinaryImageToSparseLevelSetImageAdaptorBase::BinaryImageToSparseLevelSetImageAdaptorBase
BinaryImageToSparseLevelSetImageAdaptorBase()
Definition: itkBinaryImageToLevelSetImageAdaptor.h:177
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetOutputType
typename LevelSetType::OutputType LevelSetOutputType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:151
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetInputType
typename LevelSetType::InputType LevelSetInputType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:150
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:78
itk::BinaryImageToLevelSetImageAdaptor< TInputImage, LevelSetDenseImage< TLevelSetImage > >::InputImageIndexType
typename InputImageType::IndexType InputImageIndexType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:79
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:124
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::InternalImagePointer
typename InternalImageType::Pointer InternalImagePointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:167
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:82
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:155
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LayerIdType
typename LevelSetLabelObjectType::LabelType LayerIdType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:154
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:90
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:87
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelMapPointer
typename LevelSetType::LabelMapPointer LevelSetLabelMapPointer
Definition: itkBinaryImageToLevelSetImageAdaptor.h:160
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:157
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:156
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLayerType
typename LevelSetType::LayerType LevelSetLayerType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:162
itk::BinaryImageToSparseLevelSetImageAdaptorBase< TInput, ShiSparseLevelSetImage< TInput::ImageDimension > >::LevelSetLabelObjectType
typename LevelSetType::LabelObjectType LevelSetLabelObjectType
Definition: itkBinaryImageToLevelSetImageAdaptor.h:153
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:86
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:80
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:81