ITK  5.1.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 
47 template <typename TInputImage, typename TOutputImage>
48 class ITK_TEMPLATE_EXPORT LabelMapMaskImageFilter : public LabelMapFilter<TInputImage, TOutputImage>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapMaskImageFilter);
52 
58 
60  using InputImageType = TInputImage;
61  using OutputImageType = TOutputImage;
62  using InputImagePointer = typename InputImageType::Pointer;
63  using InputImageConstPointer = typename InputImageType::ConstPointer;
65  using InputImagePixelType = typename InputImageType::PixelType;
66  using LabelObjectType = typename InputImageType::LabelObjectType;
67  using LabelType = typename LabelObjectType::LabelType;
68  using LengthType = typename LabelObjectType::LengthType;
69 
70  using OutputImagePointer = typename OutputImageType::Pointer;
71  using OutputImageConstPointer = typename OutputImageType::ConstPointer;
73  using OutputImagePixelType = typename OutputImageType::PixelType;
77 
78 
80  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
81  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
82  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
83 
85  itkNewMacro(Self);
86 
89 
91  void
92  SetFeatureImage(const TOutputImage * input)
93  {
94  // Process object is not const-correct so the const casting is required.
95  this->SetNthInput(1, const_cast<TOutputImage *>(input));
96  }
97 
99  const OutputImageType *
101  {
102  return static_cast<OutputImageType *>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
103  }
104 
106  void
107  SetInput1(const TInputImage * input)
108  {
109  this->SetInput(input);
110  }
111 
113  void
114  SetInput2(const TOutputImage * input)
115  {
116  this->SetFeatureImage(input);
117  }
118 
123  itkSetMacro(BackgroundValue, OutputImagePixelType);
124  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
126 
130  itkSetMacro(Label, InputImagePixelType);
131  itkGetConstMacro(Label, InputImagePixelType);
133 
137  itkSetMacro(Negated, bool);
138  itkGetConstReferenceMacro(Negated, bool);
139  itkBooleanMacro(Negated);
141 
145  itkSetMacro(Crop, bool);
146  itkGetConstReferenceMacro(Crop, bool);
147  itkBooleanMacro(Crop);
149 
154  itkSetMacro(CropBorder, SizeType);
155  itkGetConstReferenceMacro(CropBorder, SizeType);
157 
158 protected:
160  ~LabelMapMaskImageFilter() override = default;
161 
165  void
166  GenerateInputRequestedRegion() override;
167 
169  void
170  EnlargeOutputRequestedRegion(DataObject * itkNotUsed(output)) override;
171 
172  void
173  GenerateOutputInformation() override;
174 
175  void
176  GenerateData() override;
177 
178  void
179  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
180 
181  // part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
182  void
184  {
185  Superclass::DynamicThreadedGenerateData(outputRegion);
186  }
187 
188  void
189  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
190 
191  void
192  PrintSelf(std::ostream & os, Indent indent) const override;
193 
194 private:
197  bool m_Negated{ false };
198  bool m_Crop{ false };
200 
202 }; // end of class
203 
204 } // end namespace itk
205 
206 #ifndef ITK_MANUAL_INSTANTIATION
207 # include "itkLabelMapMaskImageFilter.hxx"
208 #endif
209 
210 #endif
itk::LabelMapFilter::OutputImageConstPointer
typename OutputImageType::ConstPointer OutputImageConstPointer
Definition: itkLabelMapFilter.h:85
itk::LabelMapMaskImageFilter::LabelType
typename LabelObjectType::LabelType LabelType
Definition: itkLabelMapMaskImageFilter.h:67
itk::ImageSource::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::LabelMapMaskImageFilter::m_CropBorder
SizeType m_CropBorder
Definition: itkLabelMapMaskImageFilter.h:199
itk::LabelMapMaskImageFilter::GetFeatureImage
const OutputImageType * GetFeatureImage()
Definition: itkLabelMapMaskImageFilter.h:100
itk::LabelMapMaskImageFilter::SetInput2
void SetInput2(const TOutputImage *input)
Definition: itkLabelMapMaskImageFilter.h:114
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::LabelMapMaskImageFilter::m_Label
InputImagePixelType m_Label
Definition: itkLabelMapMaskImageFilter.h:195
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:183
itk::LabelMapFilter::LabelObjectType
typename InputImageType::LabelObjectType LabelObjectType
Definition: itkLabelMapFilter.h:81
itkLabelMapFilter.h
itk::LabelMapMaskImageFilter::m_CropTimeStamp
TimeStamp m_CropTimeStamp
Definition: itkLabelMapMaskImageFilter.h:201
itk::ImageToImageFilter::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::LabelMapMaskImageFilter
Mask and image with a LabelMap.
Definition: itkLabelMapMaskImageFilter.h:48
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:68
itk::LabelMapMaskImageFilter::m_BackgroundValue
OutputImagePixelType m_BackgroundValue
Definition: itkLabelMapMaskImageFilter.h:196
itk::LabelMapMaskImageFilter::SetInput1
void SetInput1(const TInputImage *input)
Definition: itkLabelMapMaskImageFilter.h:107
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::LabelMapMaskImageFilter::RegionType
typename OutputImageType::RegionType RegionType
Definition: itkLabelMapMaskImageFilter.h:76
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:74
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: itkArray.h:26
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:75
itk::ImageSource::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::LabelMapMaskImageFilter::SetFeatureImage
void SetFeatureImage(const TOutputImage *input)
Definition: itkLabelMapMaskImageFilter.h:92
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