ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkObjectByObjectLabelMapFilter.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 __itkObjectByObjectLabelMapFilter_h
00019 #define __itkObjectByObjectLabelMapFilter_h
00020 
00021 #include "itkLabelMapFilter.h"
00022 #include "itkLabelImageToLabelMapFilter.h"
00023 #include "itkBinaryImageToLabelMapFilter.h"
00024 #include "itkLabelMapToBinaryImageFilter.h"
00025 #include "itkLabelSelectionLabelMapFilter.h"
00026 #include "itkAutoCropLabelMapFilter.h"
00027 #include "itkPadLabelMapFilter.h"
00028 
00029 
00030 namespace itk {
00031 
00072 template<class TInputImage, class TOutputImage=TInputImage,
00073   class TInputFilter=ImageToImageFilter<
00074     Image< unsigned char, ::itk::GetImageDimension<TInputImage >::ImageDimension >,
00075     Image< unsigned char, ::itk::GetImageDimension<TOutputImage>::ImageDimension > >,
00076   class TOutputFilter=typename TInputFilter::Superclass,
00077   class TInternalInputImage=typename TInputFilter::InputImageType,
00078   class TInternalOutputImage=typename TOutputFilter::OutputImageType >
00079 class ITK_EXPORT ObjectByObjectLabelMapFilter :
00080     public LabelMapFilter<TInputImage, TOutputImage>
00081 {
00082 public:
00084   typedef ObjectByObjectLabelMapFilter              Self;
00085   typedef LabelMapFilter<TInputImage, TOutputImage> Superclass;
00086   typedef SmartPointer<Self>                        Pointer;
00087   typedef SmartPointer<const Self>                  ConstPointer;
00088 
00090   typedef TInputImage                              InputImageType;
00091   typedef TOutputImage                             OutputImageType;
00092   typedef typename InputImageType::Pointer         InputImagePointer;
00093   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00094   typedef typename InputImageType::RegionType      InputImageRegionType;
00095   typedef typename InputImageType::PixelType       InputImagePixelType;
00096   typedef typename OutputImageType::Pointer        OutputImagePointer;
00097   typedef typename OutputImageType::ConstPointer   OutputImageConstPointer;
00098   typedef typename OutputImageType::RegionType     OutputImageRegionType;
00099   typedef typename OutputImageType::PixelType      OutputImagePixelType;
00100   typedef typename OutputImageType::SizeType       SizeType;
00101   typedef OutputImageType                          LabelMapType;
00102   typedef typename LabelMapType::LabelObjectType   LabelObjectType;
00103 
00104   typedef TInputFilter                          InputFilterType;
00105   typedef TOutputFilter                         OutputFilterType;
00106 
00107   typedef TInternalInputImage                         InternalInputImageType;
00108   typedef typename InternalInputImageType::RegionType InternalRegionType;
00109   typedef typename InternalInputImageType::SizeType   InternalSizeType;
00110   typedef typename InternalInputImageType::IndexType  InternalIndexType;
00111   typedef typename InternalInputImageType::OffsetType InternalOffsetType;
00112   typedef typename InternalInputImageType::PixelType  InternalInputPixelType;
00113 
00114   typedef TInternalOutputImage                        InternalOutputImageType;
00115   typedef typename InternalOutputImageType::PixelType InternalOutputPixelType;
00116 
00118   itkStaticConstMacro(InputImageDimension, unsigned int,
00119                       TInputImage::ImageDimension);
00120   itkStaticConstMacro(OutputImageDimension, unsigned int,
00121                       TOutputImage::ImageDimension);
00122   itkStaticConstMacro(ImageDimension, unsigned int,
00123                       TOutputImage::ImageDimension);
00125 
00126   // filter types used internally
00127   typedef itk::LabelSelectionLabelMapFilter< LabelMapType >                        SelectType;
00128   typedef itk::AutoCropLabelMapFilter< LabelMapType >                              CropType;
00129   typedef itk::PadLabelMapFilter< LabelMapType >                                   PadType;
00130   typedef itk::LabelMapToBinaryImageFilter< LabelMapType, InternalInputImageType>  LM2BIType;
00131   typedef itk::LabelImageToLabelMapFilter< InternalOutputImageType, LabelMapType>  LI2LMType;
00132   typedef itk::BinaryImageToLabelMapFilter< InternalOutputImageType, LabelMapType> BI2LMType;
00133 
00135   itkNewMacro(Self);
00136 
00138   itkTypeMacro(ObjectByObjectLabelMapFilter,
00139                LabelMapFilter);
00140 
00141   void SetFilter(InputFilterType * filter);
00142   InputFilterType * GetFilter()
00143     {
00144     return this->m_InputFilter;
00145     }
00146 
00147   const InputFilterType * GetFilter() const
00148     {
00149     return this->m_InputFilter;
00150     }
00151 
00152   void SetInputFilter( InputFilterType * filter );
00153   itkGetObjectMacro( InputFilter, InputFilterType );
00154 
00155   void SetOutputFilter( OutputFilterType * filter );
00156   itkGetObjectMacro( OutputFilter, OutputFilterType );
00157 
00158 
00166   itkSetMacro(KeepLabels, bool);
00167   itkGetMacro(KeepLabels, bool);
00168   itkBooleanMacro(KeepLabels);
00170 
00174   itkSetMacro(PadSize, SizeType);
00175   itkGetMacro(PadSize, SizeType);
00177 
00182   itkSetMacro(ConstrainPaddingToImage, bool);
00183   itkGetMacro(ConstrainPaddingToImage, bool);
00184   itkBooleanMacro(ConstrainPaddingToImage);
00186 
00192   itkSetMacro(BinaryInternalOutput, bool);
00193   itkGetMacro(BinaryInternalOutput, bool);
00194   itkBooleanMacro(BinaryInternalOutput);
00196 
00201   itkSetMacro(InternalForegroundValue, InternalOutputPixelType);
00202   itkGetMacro(InternalForegroundValue, InternalOutputPixelType);
00204 
00209   itkGetMacro(Label, InputImagePixelType);
00210 
00211 protected:
00212   ObjectByObjectLabelMapFilter();
00213   ~ObjectByObjectLabelMapFilter() {};
00214   void PrintSelf(std::ostream& os, Indent indent) const;
00215 
00216   virtual void GenerateData();
00217 
00218 
00219 private:
00220   ObjectByObjectLabelMapFilter(const Self&); //purposely not implemented
00221   void operator=(const Self&); //purposely not implemented
00222 
00223   bool     m_ConstrainPaddingToImage;
00224   SizeType m_PadSize;
00225   bool     m_BinaryInternalOutput;
00226 
00227   bool     m_KeepLabels;
00228 
00229   InternalOutputPixelType m_InternalForegroundValue;
00230 
00231 
00232   typename InputFilterType::Pointer       m_InputFilter;
00233   typename OutputFilterType::Pointer      m_OutputFilter;
00234 
00235   typename SelectType::Pointer m_Select;
00236   typename CropType::Pointer   m_Crop;
00237   typename PadType::Pointer    m_Pad;
00238   typename LM2BIType::Pointer  m_LM2BI;
00239   typename LI2LMType::Pointer  m_LI2LM;
00240   typename BI2LMType::Pointer  m_BI2LM;
00241 
00242   InputImagePixelType          m_Label;
00243 
00244 }; // end of class
00245 
00246 } // end namespace itk
00247 
00248 #ifndef ITK_MANUAL_INSTANTIATION
00249 #include "itkObjectByObjectLabelMapFilter.hxx"
00250 #endif
00251 
00252 #endif
00253