ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLabelMapMaskImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkLabelMapMaskImageFilter_h
00019 #define __itkLabelMapMaskImageFilter_h
00020 
00021 #include "itkLabelMapFilter.h"
00022 #include "itkBarrier.h"
00023 
00024 namespace itk {
00025 
00046 template<class TInputImage, class TOutputImage>
00047 class ITK_EXPORT LabelMapMaskImageFilter :
00048     public LabelMapFilter<TInputImage, TOutputImage>
00049 {
00050 public:
00052   typedef LabelMapMaskImageFilter                   Self;
00053   typedef LabelMapFilter<TInputImage, TOutputImage> Superclass;
00054   typedef SmartPointer<Self>                        Pointer;
00055   typedef SmartPointer<const Self>                  ConstPointer;
00056 
00058   typedef TInputImage                              InputImageType;
00059   typedef TOutputImage                             OutputImageType;
00060   typedef typename InputImageType::Pointer         InputImagePointer;
00061   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00062   typedef typename InputImageType::RegionType      InputImageRegionType;
00063   typedef typename InputImageType::PixelType       InputImagePixelType;
00064   typedef typename InputImageType::LabelObjectType LabelObjectType;
00065   typedef typename LabelObjectType::LabelType      LabelType;
00066   typedef typename LabelObjectType::LengthType     LengthType;
00067 
00068   typedef typename OutputImageType::Pointer        OutputImagePointer;
00069   typedef typename OutputImageType::ConstPointer   OutputImageConstPointer;
00070   typedef typename OutputImageType::RegionType     OutputImageRegionType;
00071   typedef typename OutputImageType::PixelType      OutputImagePixelType;
00072   typedef typename OutputImageType::IndexType      IndexType;
00073   typedef typename OutputImageType::SizeType       SizeType;
00074   typedef typename OutputImageType::RegionType     RegionType;
00075 
00076 
00078   itkStaticConstMacro(InputImageDimension, unsigned int,
00079                       TInputImage::ImageDimension);
00080   itkStaticConstMacro(OutputImageDimension, unsigned int,
00081                       TOutputImage::ImageDimension);
00082   itkStaticConstMacro(ImageDimension, unsigned int,
00083                       TOutputImage::ImageDimension);
00085 
00087   itkNewMacro(Self);
00088 
00090   itkTypeMacro(LabelMapMaskImageFilter,
00091                ImageToImageFilter);
00092 
00094   void SetFeatureImage(const TOutputImage *input)
00095     {
00096     // Process object is not const-correct so the const casting is required.
00097     this->SetNthInput( 1, const_cast<TOutputImage *>(input) );
00098     }
00099 
00101   const OutputImageType * GetFeatureImage()
00102     {
00103     return static_cast<OutputImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
00104     }
00105 
00107   void SetInput1(const TInputImage *input)
00108     {
00109     this->SetInput( input );
00110     }
00111 
00113   void SetInput2(const TOutputImage *input)
00114     {
00115     this->SetFeatureImage( input );
00116     }
00117 
00122   itkSetMacro(BackgroundValue, OutputImagePixelType);
00123   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00125 
00129   itkSetMacro(Label, InputImagePixelType);
00130   itkGetConstMacro(Label, InputImagePixelType);
00132 
00136   itkSetMacro(Negated, bool);
00137   itkGetConstReferenceMacro(Negated, bool);
00138   itkBooleanMacro(Negated);
00140 
00144   itkSetMacro(Crop, bool);
00145   itkGetConstReferenceMacro(Crop, bool);
00146   itkBooleanMacro(Crop);
00148 
00153   itkSetMacro(CropBorder, SizeType);
00154   itkGetConstReferenceMacro(CropBorder, SizeType);
00156 
00157 protected:
00158   LabelMapMaskImageFilter();
00159   ~LabelMapMaskImageFilter() {};
00160 
00164   void GenerateInputRequestedRegion();
00165 
00167   void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00168 
00169   virtual void GenerateOutputInformation();
00170 
00171   virtual void BeforeThreadedGenerateData();
00172 
00173   virtual void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, ThreadIdType threadId );
00174 
00175   virtual void ThreadedProcessLabelObject( LabelObjectType * labelObject );
00176 
00177   void PrintSelf(std::ostream& os, Indent indent) const;
00178 
00179 private:
00180   LabelMapMaskImageFilter(const Self&); //purposely not implemented
00181   void operator=(const Self&); //purposely not implemented
00182 
00183   InputImagePixelType       m_Label;
00184   OutputImagePixelType      m_BackgroundValue;
00185   bool                      m_Negated;
00186   bool                      m_Crop;
00187   SizeType                  m_CropBorder;
00188 
00189   TimeStamp                 m_CropTimeStamp;
00190 
00191   typename Barrier::Pointer m_Barrier;
00192 
00193 }; // end of class
00194 
00195 } // end namespace itk
00196 
00197 #ifndef ITK_MANUAL_INSTANTIATION
00198 #include "itkLabelMapMaskImageFilter.hxx"
00199 #endif
00200 
00201 #endif
00202