ITK  5.3.0
Insight Toolkit
itkLabelImageToLabelMapFilter.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  * 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 itkLabelImageToLabelMapFilter_h
19 #define itkLabelImageToLabelMapFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkLabelMap.h"
23 #include "itkLabelObject.h"
24 
25 namespace itk
26 {
47 template <typename TInputImage,
48  typename TOutputImage = LabelMap<LabelObject<typename TInputImage::PixelType, TInputImage::ImageDimension>>>
49 class ITK_TEMPLATE_EXPORT LabelImageToLabelMapFilter : public ImageToImageFilter<TInputImage, TOutputImage>
50 {
51 public:
52  ITK_DISALLOW_COPY_AND_MOVE(LabelImageToLabelMapFilter);
53 
59 
61  using InputImageType = TInputImage;
62  using OutputImageType = TOutputImage;
63  using InputImagePointer = typename InputImageType::Pointer;
64  using InputImageConstPointer = typename InputImageType::ConstPointer;
66  using InputImagePixelType = typename InputImageType::PixelType;
68 
69  using OutputImagePointer = typename OutputImageType::Pointer;
70  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
72  using OutputImagePixelType = typename OutputImageType::PixelType;
73  using LabelObjectType = typename OutputImageType::LabelObjectType;
74  using LengthType = typename LabelObjectType::LengthType;
75 
77  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
78  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
79 
81  itkNewMacro(Self);
82 
85 
90  itkSetMacro(BackgroundValue, OutputImagePixelType);
91  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
93 
94 #ifdef ITK_USE_CONCEPT_CHECKING
96 #endif
97 
98 protected:
100  ~LabelImageToLabelMapFilter() override = default;
101  void
102  PrintSelf(std::ostream & os, Indent indent) const override;
103 
107  void
108  GenerateInputRequestedRegion() override;
109 
111  void
112  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
113 
114  void
115  BeforeThreadedGenerateData() override;
116 
117  void
118  ThreadedGenerateData(const OutputImageRegionType & regionForThread, ThreadIdType threadId) override;
119 
120  void
122  {
123  itkExceptionMacro("This class requires threadId so it must use classic multi-threading model");
124  }
125 
126  void
127  AfterThreadedGenerateData() override;
128 
129 private:
131 
132  typename std::vector<OutputImagePointer> m_TemporaryImages;
133 }; // end of class
134 } // end namespace itk
135 
136 #ifndef ITK_MANUAL_INSTANTIATION
137 # include "itkLabelImageToLabelMapFilter.hxx"
138 #endif
139 
140 #endif
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::LabelImageToLabelMapFilter::m_TemporaryImages
std::vector< OutputImagePointer > m_TemporaryImages
Definition: itkLabelImageToLabelMapFilter.h:132
itk::LabelImageToLabelMapFilter
convert a labeled image to a label collection image
Definition: itkLabelImageToLabelMapFilter.h:49
itk::LabelImageToLabelMapFilter::LengthType
typename LabelObjectType::LengthType LengthType
Definition: itkLabelImageToLabelMapFilter.h:74
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Concept::SameDimension
Definition: itkConceptChecking.h:694
itk::ImageToImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:99
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
itkLabelMap.h
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelImageToLabelMapFilter::IndexType
typename InputImageType::IndexType IndexType
Definition: itkLabelImageToLabelMapFilter.h:67
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itkLabelObject.h
itk::LabelImageToLabelMapFilter::LabelObjectType
typename OutputImageType::LabelObjectType LabelObjectType
Definition: itkLabelImageToLabelMapFilter.h:73
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:65
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::LabelImageToLabelMapFilter::m_BackgroundValue
OutputImagePixelType m_BackgroundValue
Definition: itkLabelImageToLabelMapFilter.h:130
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelImageToLabelMapFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelImageToLabelMapFilter.h:70
itk::LabelImageToLabelMapFilter::DynamicThreadedGenerateData
void DynamicThreadedGenerateData(const OutputImageRegionType &) override
Definition: itkLabelImageToLabelMapFilter.h:121
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::ImageToImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkImageToImageFilter.h:131
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293