ITK  4.13.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 #include "itkBarrier.h"
23 
24 namespace itk {
25 
46 template<typename TInputImage, typename TOutputImage>
47 class ITK_TEMPLATE_EXPORT LabelMapMaskImageFilter :
48  public LabelMapFilter<TInputImage, TOutputImage>
49 {
50 public:
56 
58  typedef TInputImage InputImageType;
59  typedef TOutputImage OutputImageType;
60  typedef typename InputImageType::Pointer InputImagePointer;
61  typedef typename InputImageType::ConstPointer InputImageConstPointer;
62  typedef typename InputImageType::RegionType InputImageRegionType;
63  typedef typename InputImageType::PixelType InputImagePixelType;
64  typedef typename InputImageType::LabelObjectType LabelObjectType;
65  typedef typename LabelObjectType::LabelType LabelType;
66  typedef typename LabelObjectType::LengthType LengthType;
67 
68  typedef typename OutputImageType::Pointer OutputImagePointer;
69  typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
70  typedef typename OutputImageType::RegionType OutputImageRegionType;
71  typedef typename OutputImageType::PixelType OutputImagePixelType;
74  typedef typename OutputImageType::RegionType RegionType;
75 
76 
78  itkStaticConstMacro(InputImageDimension, unsigned int,
79  TInputImage::ImageDimension);
80  itkStaticConstMacro(OutputImageDimension, unsigned int,
81  TOutputImage::ImageDimension);
82  itkStaticConstMacro(ImageDimension, unsigned int,
83  TOutputImage::ImageDimension);
85 
87  itkNewMacro(Self);
88 
91 
93  void SetFeatureImage(const TOutputImage *input)
94  {
95  // Process object is not const-correct so the const casting is required.
96  this->SetNthInput( 1, const_cast<TOutputImage *>(input) );
97  }
98 
101  {
102  return static_cast<OutputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
103  }
104 
106  void SetInput1(const TInputImage *input)
107  {
108  this->SetInput( input );
109  }
110 
112  void SetInput2(const TOutputImage *input)
113  {
114  this->SetFeatureImage( input );
115  }
116 
121  itkSetMacro(BackgroundValue, OutputImagePixelType);
122  itkGetConstMacro(BackgroundValue, OutputImagePixelType);
124 
128  itkSetMacro(Label, InputImagePixelType);
129  itkGetConstMacro(Label, InputImagePixelType);
131 
135  itkSetMacro(Negated, bool);
136  itkGetConstReferenceMacro(Negated, bool);
137  itkBooleanMacro(Negated);
139 
143  itkSetMacro(Crop, bool);
144  itkGetConstReferenceMacro(Crop, bool);
145  itkBooleanMacro(Crop);
147 
152  itkSetMacro(CropBorder, SizeType);
153  itkGetConstReferenceMacro(CropBorder, SizeType);
155 
156 protected:
158  ~LabelMapMaskImageFilter() ITK_OVERRIDE {};
159 
163  void GenerateInputRequestedRegion() ITK_OVERRIDE;
164 
166  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) ITK_OVERRIDE;
167 
168  virtual void GenerateOutputInformation() ITK_OVERRIDE;
169 
170  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
171 
172  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
173 
174  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE;
175 
176  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
177 
178 private:
179  ITK_DISALLOW_COPY_AND_ASSIGN(LabelMapMaskImageFilter);
180 
181  InputImagePixelType m_Label;
182  OutputImagePixelType m_BackgroundValue;
183  bool m_Negated;
184  bool m_Crop;
185  SizeType m_CropBorder;
186 
187  TimeStamp m_CropTimeStamp;
188 
189  typename Barrier::Pointer m_Barrier;
190 
191 }; // end of class
192 
193 } // end namespace itk
194 
195 #ifndef ITK_MANUAL_INSTANTIATION
196 #include "itkLabelMapMaskImageFilter.hxx"
197 #endif
198 
199 #endif
OutputImageType::IndexType IndexType
void SetInput1(const TInputImage *input)
void SetInput2(const TOutputImage *input)
LabelObjectType::LengthType LengthType
Base class for all process objects that output image data.
void SetFeatureImage(const TOutputImage *input)
OutputImageType::ConstPointer OutputImageConstPointer
InputImageType::RegionType InputImageRegionType
InputImageType::Pointer InputImagePointer
LabelObjectType::LabelType LabelType
InputImageType::ConstPointer InputImageConstPointer
SmartPointer< const Self > ConstPointer
LabelMapFilter< TInputImage, TOutputImage > Superclass
OutputImageType::RegionType RegionType
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:59
OutputImageType::PixelType OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
Base class for filters that take an image as input and overwrite that image as the output...
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
InputImageType::PixelType InputImagePixelType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
InputImageType::LabelObjectType LabelObjectType
const OutputImageType * GetFeatureImage()
OutputImageType::SizeType SizeType
TOutputImage OutputImageType
InputImageType::PixelType InputImagePixelType
Base class for all data objects in ITK.
Mask and image with a LabelMap.
OutputImageType::Pointer OutputImagePointer
OutputImageType::RegionType OutputImageRegionType
Standard barrier class implementation for synchronizing the execution of threads. ...
Definition: itkBarrier.h:41