ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkShapeRelabelImageFilter.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 __itkShapeRelabelImageFilter_h
00019 #define __itkShapeRelabelImageFilter_h
00020 
00021 #include "itkShapeLabelObject.h"
00022 #include "itkLabelImageToLabelMapFilter.h"
00023 #include "itkShapeLabelMapFilter.h"
00024 #include "itkShapeRelabelLabelMapFilter.h"
00025 #include "itkLabelMapToLabelImageFilter.h"
00026 
00027 namespace itk
00028 {
00045 template< class TInputImage >
00046 class ITK_EXPORT ShapeRelabelImageFilter:
00047   public ImageToImageFilter< TInputImage, TInputImage >
00048 {
00049 public:
00051   typedef ShapeRelabelImageFilter                        Self;
00052   typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
00053   typedef SmartPointer< Self >                           Pointer;
00054   typedef SmartPointer< const Self >                     ConstPointer;
00055 
00057   typedef TInputImage                            InputImageType;
00058   typedef TInputImage                            OutputImageType;
00059   typedef typename InputImageType::Pointer       InputImagePointer;
00060   typedef typename InputImageType::ConstPointer  InputImageConstPointer;
00061   typedef typename InputImageType::RegionType    InputImageRegionType;
00062   typedef typename InputImageType::PixelType     InputImagePixelType;
00063   typedef typename OutputImageType::Pointer      OutputImagePointer;
00064   typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
00065   typedef typename OutputImageType::RegionType   OutputImageRegionType;
00066   typedef typename OutputImageType::PixelType    OutputImagePixelType;
00067 
00069   itkStaticConstMacro(InputImageDimension, unsigned int,
00070                       TInputImage::ImageDimension);
00071   itkStaticConstMacro(OutputImageDimension, unsigned int,
00072                       TInputImage::ImageDimension);
00073   itkStaticConstMacro(ImageDimension, unsigned int,
00074                       TInputImage::ImageDimension);
00076 
00077   typedef ShapeLabelObject< InputImagePixelType, itkGetStaticConstMacro(ImageDimension) > LabelObjectType;
00078   typedef LabelMap< LabelObjectType >                                                     LabelMapType;
00079   typedef LabelImageToLabelMapFilter< InputImageType, LabelMapType >                      LabelizerType;
00080   typedef Image< typename OutputImageType::PixelType, itkGetStaticConstMacro(OutputImageDimension) >
00081   ShapeLabelFilterOutput;
00082   typedef ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput > LabelObjectValuatorType;
00083   typedef typename LabelObjectType::AttributeType                     AttributeType;
00084   typedef ShapeRelabelLabelMapFilter< LabelMapType >                  RelabelType;
00085   typedef LabelMapToLabelImageFilter< LabelMapType, OutputImageType > BinarizerType;
00086 
00088   itkNewMacro(Self);
00089 
00091   itkTypeMacro(ShapeRelabelImageFilter,
00092                ImageToImageFilter);
00093 
00094 #ifdef ITK_USE_CONCEPT_CHECKING
00095 
00096   itkConceptMacro( InputEqualityComparableCheck,
00097                    ( Concept::EqualityComparable< InputImagePixelType > ) );
00098   itkConceptMacro( IntConvertibleToInputCheck,
00099                    ( Concept::Convertible< int, InputImagePixelType > ) );
00100   itkConceptMacro( InputOStreamWritableCheck,
00101                    ( Concept::OStreamWritable< InputImagePixelType > ) );
00102 
00104 #endif
00105 
00110   itkSetMacro(BackgroundValue, OutputImagePixelType);
00111   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00113 
00119   itkGetConstMacro(ReverseOrdering, bool);
00120   itkSetMacro(ReverseOrdering, bool);
00121   itkBooleanMacro(ReverseOrdering);
00123 
00127   itkGetConstMacro(Attribute, AttributeType);
00128   itkSetMacro(Attribute, AttributeType);
00129   void SetAttribute(const std::string & s)
00130   {
00131     this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
00132   }
00134 
00135 protected:
00136   ShapeRelabelImageFilter();
00137   ~ShapeRelabelImageFilter() {}
00138   void PrintSelf(std::ostream & os, Indent indent) const;
00139 
00143   void GenerateInputRequestedRegion();
00144 
00146   void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
00147 
00150   void GenerateData();
00151 
00152 private:
00153   ShapeRelabelImageFilter(const Self &); //purposely not implemented
00154   void operator=(const Self &);          //purposely not implemented
00155 
00156   OutputImagePixelType m_BackgroundValue;
00157   bool                 m_ReverseOrdering;
00158   AttributeType        m_Attribute;
00159 }; // end of class
00160 } // end namespace itk
00161 
00162 #ifndef ITK_MANUAL_INSTANTIATION
00163 #include "itkShapeRelabelImageFilter.hxx"
00164 #endif
00165 
00166 #endif
00167