ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkWatershedRelabeler.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 __itkWatershedRelabeler_h
00019 #define __itkWatershedRelabeler_h
00020 
00021 #include "itkWatershedSegmentTree.h"
00022 #include "itkWatershedSegmenter.h"
00023 
00024 namespace itk
00025 {
00026 namespace watershed
00027 {
00063 template< class TScalarType, unsigned int TImageDimension >
00064 class ITK_EXPORT Relabeler:
00065   public ProcessObject
00066 {
00067 public:
00069   typedef Relabeler                  Self;
00070   typedef ProcessObject              Superclass;
00071   typedef SmartPointer< Self >       Pointer;
00072   typedef SmartPointer< const Self > ConstPointer;
00073   itkNewMacro(Self);
00074   itkTypeMacro(WatershedRelabeler, ProcessObject);
00076 
00078   itkStaticConstMacro(ImageDimension, unsigned int, TImageDimension);
00079 
00081   typedef TScalarType                                       ScalarType;
00082   typedef Image< IdentifierType, TImageDimension >          ImageType;
00083   typedef SegmentTree< ScalarType >                         SegmentTreeType;
00084   typedef Segmenter< Image< ScalarType, TImageDimension > > SegmenterType;
00085   typedef DataObject::Pointer                               DataObjectPointer;
00086 
00088   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00089   using Superclass::MakeOutput;
00090   virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx);
00091 
00093   void SetInputImage(ImageType *img)
00094   {
00095     this->ProcessObject::SetNthInput(0, img);
00096   }
00097 
00098   ImageType * GetInputImage(void)
00099   {
00100     return static_cast< ImageType * >
00101            ( this->ProcessObject::GetInput(0) );
00102   }
00103 
00105   void SetOutputImage(ImageType *img)
00106   {
00107     this->ProcessObject::SetNthOutput(0, img);
00108   }
00109 
00110   ImageType * GetOutputImage(void)
00111   {
00112     return static_cast< ImageType * >
00113            ( this->ProcessObject::GetOutput(0) );
00114   }
00115 
00117   void SetInputSegmentTree(SegmentTreeType *et)
00118   {
00119     this->ProcessObject::SetNthInput(1, et);
00120   }
00121 
00122   SegmentTreeType * GetInputSegmentTree(void)
00123   {
00124     return static_cast< SegmentTreeType * >
00125            ( this->ProcessObject::GetInput(1) );
00126   }
00127 
00129   void GenerateData();
00130 
00133   itkSetClampMacro(FloodLevel, double, 0.0, 1.0);
00134   itkGetConstMacro(FloodLevel, double);
00136 
00138   void GraftOutput(ImageType *graft);
00139 
00140   void GraftNthOutput(unsigned int idx, ImageType *graft);
00141 
00142 protected:
00143   Relabeler();
00144   virtual ~Relabeler() {}
00145   Relabeler(const Self &) {}
00146   void operator=(const Self &) {}
00147   void PrintSelf(std::ostream & os, Indent indent) const;
00148 
00149   double m_FloodLevel;
00150   void GenerateOutputRequestedRegion(DataObject *output);
00151 
00152   void GenerateInputRequestedRegion();
00153 };
00154 } // end namespace watershed
00155 } // end namespace itk
00156 
00157 #ifndef ITK_MANUAL_INSTANTIATION
00158 #include "itkWatershedRelabeler.hxx"
00159 #endif
00160 
00161 #endif
00162