ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLabelMapMaskImageFilter.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 itkLabelMapMaskImageFilter_h
19 #define itkLabelMapMaskImageFilter_h
20 
21 #include "itkLabelMapFilter.h"
22 
23 namespace itk {
24 
45 template<typename TInputImage, typename TOutputImage>
46 class ITK_TEMPLATE_EXPORT LabelMapMaskImageFilter :
47  public LabelMapFilter<TInputImage, TOutputImage>
48 {
49 public:
50  ITK_DISALLOW_COPY_AND_ASSIGN(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 SetFeatureImage(const TOutputImage *input)
91  {
92  // Process object is not const-correct so the const casting is required.
93  this->SetNthInput( 1, const_cast<TOutputImage *>(input) );
94  }
95 
98  {
99  return static_cast<OutputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
100  }
101 
103  void SetInput1(const TInputImage *input)
104  {
105  this->SetInput( input );
106  }
107 
109  void SetInput2(const TOutputImage *input)
110  {
111  this->SetFeatureImage( input );
112  }
113 
118  itkSetMacro(BackgroundValue, OutputImagePixelType);
119  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
121 
125  itkSetMacro(Label, InputImagePixelType);
126  itkGetConstMacro(Label, InputImagePixelType);
128 
132  itkSetMacro(Negated, bool);
133  itkGetConstReferenceMacro(Negated, bool);
134  itkBooleanMacro(Negated);
136 
140  itkSetMacro(Crop, bool);
141  itkGetConstReferenceMacro(Crop, bool);
142  itkBooleanMacro(Crop);
144 
149  itkSetMacro(CropBorder, SizeType);
150  itkGetConstReferenceMacro(CropBorder, SizeType);
152 
153 protected:
155  ~LabelMapMaskImageFilter() override = default;
156 
160  void GenerateInputRequestedRegion() override;
161 
163  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) override;
164 
165  void GenerateOutputInformation() override;
166 
167  void GenerateData() override;
168 
169  void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override;
170 
171  //part of a compile error workaround for GCC 4.8.5-28 (Red Hat) from 20150623
172  void SuperclassDynamicTGD(const OutputImageRegionType & outputRegion)
173  {
174  Superclass::DynamicThreadedGenerateData(outputRegion);
175  }
176 
177  void ThreadedProcessLabelObject( LabelObjectType * labelObject ) override;
178 
179  void PrintSelf(std::ostream& os, Indent indent) const override;
180 
181 private:
184  bool m_Negated{ false };
185  bool m_Crop{ false };
187 
189 }; // end of class
190 
191 } // end namespace itk
192 
193 #ifndef ITK_MANUAL_INSTANTIATION
194 #include "itkLabelMapMaskImageFilter.hxx"
195 #endif
196 
197 #endif
typename OutputImageType::Pointer OutputImagePointer
void SetInput1(const TInputImage *input)
void SetInput2(const TOutputImage *input)
typename InputImageType::LabelObjectType LabelObjectType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename LabelObjectType::LengthType LengthType
typename OutputImageType::RegionType RegionType
Base class for all process objects that output image data.
void SetFeatureImage(const TOutputImage *input)
typename OutputImageType::ConstPointer OutputImageConstPointer
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
typename OutputImageType::SizeType SizeType
TOutputImage OutputImageType
typename LabelObjectType::LabelType LabelType
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
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 InputImageType::RegionType InputImageRegionType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void SuperclassDynamicTGD(const OutputImageRegionType &outputRegion)
const OutputImageType * GetFeatureImage()
typename OutputImageType::IndexType IndexType
typename InputImageType::ConstPointer InputImageConstPointer
Base class for all data objects in ITK.
Mask and image with a LabelMap.