ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLabelMapToBinaryImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
44 template< typename TInputImage, typename TOutputImage >
45 class ITK_TEMPLATE_EXPORT LabelMapToBinaryImageFilter:
46  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 
101  {
102  // Process object is not const-correct so the const casting is required.
103  this->SetNthInput( 1, const_cast< OutputImageType * >( input ) );
104  }
105 
107  {
108  return static_cast< OutputImageType * >( const_cast< DataObject * >( this->ProcessObject::GetInput(1) ) );
109  }
110 
112  void SetInput1(const InputImageType *input)
113  {
114  this->SetInput(input);
115  }
116 
118  void SetInput2(const OutputImageType *input)
119  {
120  this->SetBackgroundImage(input);
121  }
122 
123 protected:
125  ~LabelMapToBinaryImageFilter() override = default;
126 
130  void GenerateInputRequestedRegion() override;
131 
133  void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) ) override;
134 
135  void GenerateData() override;
136 
137  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
138 
139  //part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
140  void SuperclassDynamicTGD(const OutputImageRegionType & outputRegion)
141  {
142  Superclass::DynamicThreadedGenerateData(outputRegion);
143  }
144 
145  void ThreadedProcessLabelObject(LabelObjectType *labelObject) override;
146 
147  void PrintSelf(std::ostream & os, Indent indent) const override;
148 
149 private:
152 }; // end of class
153 } // end namespace itk
154 
155 #ifndef ITK_MANUAL_INSTANTIATION
156 #include "itkLabelMapToBinaryImageFilter.hxx"
157 #endif
158 
159 #endif
typename OutputImageType::Pointer OutputImagePointer
typename InputImageType::LabelObjectType LabelObjectType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename OutputImageType::ConstPointer OutputImageConstPointer
void SetInput1(const InputImageType *input)
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
void SetInput2(const OutputImageType *input)
Base class for filters that take an image as input and overwrite that image as the output...
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
typename OutputImageType::IndexType IndexType
typename InputImageType::RegionType InputImageRegionType
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Base class for filters that take an image as input and produce an image as output.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void SetBackgroundImage(const OutputImageType *input)
typename InputImageType::ConstPointer InputImageConstPointer
Base class for all data objects in ITK.
Convert a LabelMap to a binary image.