ITK  5.2.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 {
48 template <typename TInputImage,
49  typename TOutputImage = LabelMap<LabelObject<typename TInputImage::PixelType, TInputImage::ImageDimension>>>
50 class ITK_TEMPLATE_EXPORT LabelImageToLabelMapFilter : public ImageToImageFilter<TInputImage, TOutputImage>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_ASSIGN(LabelImageToLabelMapFilter);
54 
60 
62  using InputImageType = TInputImage;
63  using OutputImageType = TOutputImage;
64  using InputImagePointer = typename InputImageType::Pointer;
65  using InputImageConstPointer = typename InputImageType::ConstPointer;
67  using InputImagePixelType = typename InputImageType::PixelType;
69 
70  using OutputImagePointer = typename OutputImageType::Pointer;
71  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
73  using OutputImagePixelType = typename OutputImageType::PixelType;
74  using LabelObjectType = typename OutputImageType::LabelObjectType;
75  using LengthType = typename LabelObjectType::LengthType;
76 
78  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
79  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
80 
82  itkNewMacro(Self);
83 
86 
91  itkSetMacro(BackgroundValue, OutputImagePixelType);
92  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
94 
95 #ifdef ITK_USE_CONCEPT_CHECKING
97 #endif
98 
99 protected:
101  ~LabelImageToLabelMapFilter() override = default;
102  void
103  PrintSelf(std::ostream & os, Indent indent) const override;
104 
108  void
109  GenerateInputRequestedRegion() override;
110 
112  void
113  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
114 
115  void
116  BeforeThreadedGenerateData() override;
117 
118  void
119  ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) override;
120 
121  void
123  {
124  itkExceptionMacro("This class requires threadId so it must use classic multi-threading model");
125  }
126 
127  void
128  AfterThreadedGenerateData() override;
129 
130 private:
132 
133  typename std::vector<OutputImagePointer> m_TemporaryImages;
134 }; // end of class
135 } // end namespace itk
136 
137 #ifndef ITK_MANUAL_INSTANTIATION
138 # include "itkLabelImageToLabelMapFilter.hxx"
139 #endif
140 
141 #endif
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::LabelImageToLabelMapFilter::m_TemporaryImages
std::vector< OutputImagePointer > m_TemporaryImages
Definition: itkLabelImageToLabelMapFilter.h:133
itk::LabelImageToLabelMapFilter
convert a labeled image to a label collection image
Definition: itkLabelImageToLabelMapFilter.h:50
itk::LabelImageToLabelMapFilter::LengthType
typename LabelObjectType::LengthType LengthType
Definition: itkLabelImageToLabelMapFilter.h:75
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Concept::SameDimension
Definition: itkConceptChecking.h:692
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:68
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itkLabelObject.h
itk::LabelImageToLabelMapFilter::LabelObjectType
typename OutputImageType::LabelObjectType LabelObjectType
Definition: itkLabelImageToLabelMapFilter.h:74
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
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:131
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelImageToLabelMapFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelImageToLabelMapFilter.h:71
itk::LabelImageToLabelMapFilter::DynamicThreadedGenerateData
void DynamicThreadedGenerateData(const OutputImageRegionType &) override
Definition: itkLabelImageToLabelMapFilter.h:122
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