ITK  5.3.0
Insight Toolkit
itkLabelMapMaskImageFilter.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 itkLabelMapMaskImageFilter_h
19 #define itkLabelMapMaskImageFilter_h
20 
21 #include "itkLabelMapFilter.h"
22 
23 namespace itk
24 {
25 
46 template <typename TInputImage, typename TOutputImage>
47 class ITK_TEMPLATE_EXPORT LabelMapMaskImageFilter : public LabelMapFilter<TInputImage, TOutputImage>
48 {
49 public:
50  ITK_DISALLOW_COPY_AND_MOVE(LabelMapMaskImageFilter);
51 
57 
59  using InputImageType = TInputImage;
60  using OutputImageType = TOutputImage;
61  using InputImagePointer = typename InputImageType::Pointer;
62  using InputImageConstPointer = typename InputImageType::ConstPointer;
64  using InputImagePixelType = typename InputImageType::PixelType;
65  using LabelObjectType = typename InputImageType::LabelObjectType;
66  using LabelType = typename LabelObjectType::LabelType;
67  using LengthType = typename LabelObjectType::LengthType;
68 
69  using OutputImagePointer = typename OutputImageType::Pointer;
70  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
72  using OutputImagePixelType = typename OutputImageType::PixelType;
76 
77 
79  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
80  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
81  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
82 
84  itkNewMacro(Self);
85 
88 
90  void
91  SetFeatureImage(const TOutputImage * input)
92  {
93  // Process object is not const-correct so the const casting is required.
94  this->SetNthInput(1, const_cast<TOutputImage *>(input));
95  }
96 
98  const OutputImageType *
100  {
101  return static_cast<OutputImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
102  }
103 
105  void
106  SetInput1(const TInputImage * input)
107  {
108  this->SetInput(input);
109  }
110 
112  void
113  SetInput2(const TOutputImage * input)
114  {
115  this->SetFeatureImage(input);
116  }
117 
122  itkSetMacro(BackgroundValue, OutputImagePixelType);
123  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
125 
129  itkSetMacro(Label, InputImagePixelType);
130  itkGetConstMacro(Label, InputImagePixelType);
132 
136  itkSetMacro(Negated, bool);
137  itkGetConstReferenceMacro(Negated, bool);
138  itkBooleanMacro(Negated);
140 
144  itkSetMacro(Crop, bool);
145  itkGetConstReferenceMacro(Crop, bool);
146  itkBooleanMacro(Crop);
148 
153  itkSetMacro(CropBorder, SizeType);
154  itkGetConstReferenceMacro(CropBorder, SizeType);
156 
157 protected:
159  ~LabelMapMaskImageFilter() override = default;
160 
164  void
165  GenerateInputRequestedRegion() override;
166 
168  void
169  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
170 
171  void
172  GenerateOutputInformation() override;
173 
174  void
175  GenerateData() override;
176 
177  void
178  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
179 
180  // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
181  void
183  {
184  Superclass::DynamicThreadedGenerateData(outputRegion);
185  }
186 
187  void
188  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
189 
190  void
191  PrintSelf(std::ostream & os, Indent indent) const override;
192 
193 private:
196  bool m_Negated{ false };
197  bool m_Crop{ false };
199 
201 }; // end of class
202 
203 } // end namespace itk
204 
205 #ifndef ITK_MANUAL_INSTANTIATION
206 # include "itkLabelMapMaskImageFilter.hxx"
207 #endif
208 
209 #endif
itk::LabelMapFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapFilter.h:84
itk::LabelMapMaskImageFilter::LabelType
typename LabelObjectType::LabelType LabelType
Definition: itkLabelMapMaskImageFilter.h:66
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::LabelMapMaskImageFilter::m_CropBorder
SizeType m_CropBorder
Definition: itkLabelMapMaskImageFilter.h:198
itk::LabelMapMaskImageFilter::GetFeatureImage
const OutputImageType * GetFeatureImage()
Definition: itkLabelMapMaskImageFilter.h:99
itk::LabelMapMaskImageFilter::SetInput2
void SetInput2(const TOutputImage *input)
Definition: itkLabelMapMaskImageFilter.h:113
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::LabelMapMaskImageFilter::m_Label
InputImagePixelType m_Label
Definition: itkLabelMapMaskImageFilter.h:194
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LabelMapMaskImageFilter::SuperclassDynamicTGD
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
Definition: itkLabelMapMaskImageFilter.h:182
itk::LabelMapFilter::LabelObjectType
typename InputImageType::LabelObjectType LabelObjectType
Definition: itkLabelMapFilter.h:80
itkLabelMapFilter.h
itk::LabelMapMaskImageFilter::m_CropTimeStamp
TimeStamp m_CropTimeStamp
Definition: itkLabelMapMaskImageFilter.h:200
itk::ImageToImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::LabelMapMaskImageFilter
Mask and image with a LabelMap.
Definition: itkLabelMapMaskImageFilter.h:47
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::LabelMapMaskImageFilter::LengthType
typename LabelObjectType::LengthType LengthType
Definition: itkLabelMapMaskImageFilter.h:67
itk::LabelMapMaskImageFilter::m_BackgroundValue
OutputImagePixelType m_BackgroundValue
Definition: itkLabelMapMaskImageFilter.h:195
itk::LabelMapMaskImageFilter::SetInput1
void SetInput1(const TInputImage *input)
Definition: itkLabelMapMaskImageFilter.h:106
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::LabelMapMaskImageFilter::RegionType
typename OutputImageType::RegionType RegionType
Definition: itkLabelMapMaskImageFilter.h:75
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::TimeStamp
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
itk::LabelMapMaskImageFilter::IndexType
typename OutputImageType::IndexType IndexType
Definition: itkLabelMapMaskImageFilter.h:73
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
Label
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::LabelMapMaskImageFilter::SizeType
typename OutputImageType::SizeType SizeType
Definition: itkLabelMapMaskImageFilter.h:74
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapMaskImageFilter::SetFeatureImage
void SetFeatureImage(const TOutputImage *input)
Definition: itkLabelMapMaskImageFilter.h:91
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