ITK  6.0.0
Insight Toolkit
itkLabelMapToBinaryImageFilter.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 #ifndef itkLabelMapToBinaryImageFilter_h
19 #define itkLabelMapToBinaryImageFilter_h
20 
21 #include "itkLabelMapFilter.h"
22 
23 namespace itk
24 {
44 template <typename TInputImage, typename TOutputImage>
45 class ITK_TEMPLATE_EXPORT LabelMapToBinaryImageFilter : public LabelMapFilter<TInputImage, TOutputImage>
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_MOVE(LabelMapToBinaryImageFilter);
49 
55 
57  using InputImageType = TInputImage;
58  using OutputImageType = TOutputImage;
62  using InputImagePixelType = typename InputImageType::PixelType;
63  using LabelObjectType = typename InputImageType::LabelObjectType;
64 
68  using OutputImagePixelType = typename OutputImageType::PixelType;
70 
72  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
73  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
74 
76  itkNewMacro(Self);
77 
79  itkOverrideGetNameOfClassMacro(LabelMapToBinaryImageFilter);
80 
85  itkSetMacro(BackgroundValue, OutputImagePixelType);
86  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
93  itkSetMacro(ForegroundValue, OutputImagePixelType);
94  itkGetConstMacro(ForegroundValue, OutputImagePixelType);
99  void
101  {
102  // Process object is not const-correct so the const casting is required.
103  this->SetNthInput(1, const_cast<OutputImageType *>(input));
104  }
105 
106  OutputImageType *
108  {
109  return static_cast<OutputImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
110  }
111 
113  void
114  SetInput1(const InputImageType * input)
115  {
116  this->SetInput(input);
117  }
118 
120  void
121  SetInput2(const OutputImageType * input)
122  {
123  this->SetBackgroundImage(input);
124  }
125 
126 protected:
128  ~LabelMapToBinaryImageFilter() override = default;
129 
133  void
134  GenerateInputRequestedRegion() override;
135 
137  void
138  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
139 
140  void
141  GenerateData() override;
142 
143  void
144  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
145 
146  // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
147  void
149  {
150  Superclass::DynamicThreadedGenerateData(outputRegion);
151  }
152 
153  void
154  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
155 
156  void
157  PrintSelf(std::ostream & os, Indent indent) const override;
158 
159 private:
160  OutputImagePixelType m_BackgroundValue{};
161  OutputImagePixelType m_ForegroundValue{};
162 }; // end of class
163 } // end namespace itk
164 
165 #ifndef ITK_MANUAL_INSTANTIATION
166 # include "itkLabelMapToBinaryImageFilter.hxx"
167 #endif
168 
169 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::LabelMapFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapFilter.h:84
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::LabelMapToBinaryImageFilter
Convert a LabelMap to a binary image.
Definition: itkLabelMapToBinaryImageFilter.h:45
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LabelMapFilter::LabelObjectType
typename InputImageType::LabelObjectType LabelObjectType
Definition: itkLabelMapFilter.h:80
itkLabelMapFilter.h
itk::ImageToImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
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::LabelMapFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkLabelMapFilter.h:57
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::LabelMapToBinaryImageFilter::SuperclassDynamicTGD
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Definition: itkLabelMapToBinaryImageFilter.h:148
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::LabelMapToBinaryImageFilter::SetInput1
void SetInput1(const InputImageType *input)
Definition: itkLabelMapToBinaryImageFilter.h:114
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::LabelMapToBinaryImageFilter::GetBackgroundImage
OutputImageType * GetBackgroundImage()
Definition: itkLabelMapToBinaryImageFilter.h:107
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::LabelMapToBinaryImageFilter::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkLabelMapToBinaryImageFilter.h:69
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::LabelMapToBinaryImageFilter::SetInput2
void SetInput2(const OutputImageType *input)
Definition: itkLabelMapToBinaryImageFilter.h:121
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapToBinaryImageFilter::SetBackgroundImage
void SetBackgroundImage(const OutputImageType *input)
Definition: itkLabelMapToBinaryImageFilter.h:100
itk::ImageToImageFilter::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::ProcessObject::GetInput
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
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