ITK  4.3.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<class TInputImage, class TOutputImage>
47 class ITK_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;
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 
101  const OutputImageType * GetFeatureImage()
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();
165 
167  void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
168 
169  virtual void GenerateOutputInformation();
170 
171  virtual void BeforeThreadedGenerateData();
172 
173  virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId );
174 
175  virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject );
176 
177  void PrintSelf(std::ostream& os, Indent indent) const;
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
202