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