ITK  4.8.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>
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;
72  typedef typename OutputImageType::IndexType IndexType;
73  typedef typename OutputImageType::SizeType SizeType;
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 
90  itkTypeMacro(LabelMapMaskImageFilter,
92 
94  void SetFeatureImage(const TOutputImage *input)
95  {
96  // Process object is not const-correct so the const casting is required.
97  this->SetNthInput( 1, const_cast<TOutputImage *>(input) );
98  }
99 
102  {
103  return static_cast<OutputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
104  }
105 
107  void SetInput1(const TInputImage *input)
108  {
109  this->SetInput( input );
110  }
111 
113  void 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:
160 
164  void GenerateInputRequestedRegion() ITK_OVERRIDE;
165 
167  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output)) ITK_OVERRIDE;
168 
169  virtual void GenerateOutputInformation() ITK_OVERRIDE;
170 
171  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
172 
173  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
174 
175  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject ) ITK_OVERRIDE;
176 
177  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
178 
179 private:
180  LabelMapMaskImageFilter(const Self&); //purposely not implemented
181  void operator=(const Self&); //purposely not implemented
182 
185  bool m_Negated;
186  bool m_Crop;
188 
190 
192 
193 }; // end of class
194 
195 } // end namespace itk
196 
197 #ifndef ITK_MANUAL_INSTANTIATION
198 #include "itkLabelMapMaskImageFilter.hxx"
199 #endif
200 
201 #endif
void EnlargeOutputRequestedRegion(DataObject *) override
OutputImageType::IndexType IndexType
virtual void BeforeThreadedGenerateData() override
void SetInput1(const TInputImage *input)
void SetInput2(const TOutputImage *input)
virtual void GenerateOutputInformation() override
LabelObjectType::LengthType LengthType
Base class for all process objects that output image data.
void SetFeatureImage(const TOutputImage *input)
OutputImageType::ConstPointer OutputImageConstPointer
static const unsigned int OutputImageDimension
InputImageType::RegionType InputImageRegionType
InputImageType::Pointer InputImagePointer
LabelObjectType::LabelType LabelType
InputImageType::ConstPointer InputImageConstPointer
virtual void SetInput(const InputImageType *image)
SmartPointer< const Self > ConstPointer
LabelMapFilter< TInputImage, TOutputImage > Superclass
OutputImageType::RegionType RegionType
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:58
OutputImageType::PixelType OutputImagePixelType
OutputImageType::PixelType OutputImagePixelType
virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
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
Base class for filters that take an image as input and produce an image as output.
static const unsigned int InputImageDimension
void GenerateInputRequestedRegion() override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
InputImageType::LabelObjectType LabelObjectType
static const unsigned int ImageDimension
const OutputImageType * GetFeatureImage()
virtual void SetNthInput(DataObjectPointerArraySizeType num, DataObject *input)
OutputImageType::SizeType SizeType
TOutputImage OutputImageType
InputImageType::PixelType InputImagePixelType
void PrintSelf(std::ostream &os, Indent indent) const override
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