/vol/vipdata/irtk/image++/include/irtkLargestConnectedComponentIterative.h

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkLargestConnectedComponentIterative.h 2 2008-12-23 12:40:14Z dr $
00005   Copyright : Imperial College, Department of Computing
00006               Visual Information Processing (VIP), 2008 onwards
00007   Date      : $Date: 2008-12-23 12:40:14 +0000 (Tue, 23 Dec 2008) $
00008   Version   : $Revision: 2 $
00009   Changes   : $Author: dr $
00010 
00011 =========================================================================*/
00012 
00013 #ifndef _IRTKLARGESTCONNECTEDCOMPONENTITERATIVE_H
00014 
00015 #define _IRTKLARGESTCONNECTEDCOMPONENTITERATIVE_H
00016 
00017 #include <irtkImageToImage.h>
00018 
00029 template <class VoxelType> class irtkLargestConnectedComponentIterative : public irtkImageToImage<VoxelType>
00030 {
00031 
00033   VoxelType _TargetLabel;
00034 
00036   int _largestClusterSize;
00037 
00038   // What label is used for the largest cluster during computation.
00039   VoxelType _largestClusterLabel;
00040 
00041   // Record of all cluster sizes.
00042   int *_ClusterSizes;
00043 
00044   // Number of clusters that match the target label.
00045   int _NumberOfClusters;
00046 
00048   Bool _Mode2D;
00049 
00050   Bool _AllClustersMode;
00051 
00052 protected:
00053 
00055   virtual void Run3D();
00056   virtual void Run2D();
00057 
00058   // Helper functions
00059   virtual void ResetMarks();
00060 
00061   virtual void SelectLargestCluster();
00062 
00063   int CheckAdjacency2D(VoxelType& markA, VoxelType& markB);
00064   int CheckAdjacency3D(VoxelType& markA, VoxelType& markB);
00065 
00067   virtual Bool RequiresBuffering();
00068 
00070   virtual const char *NameOfClass();
00071 
00072 public:
00073 
00075   irtkLargestConnectedComponentIterative(VoxelType = 0);
00076 
00078   ~irtkLargestConnectedComponentIterative();
00079 
00081   SetMacro(TargetLabel, VoxelType);
00082 
00084   GetMacro(TargetLabel, VoxelType);
00085 
00087   SetMacro(Mode2D, Bool);
00088 
00090   GetMacro(Mode2D, Bool);
00091 
00093   SetMacro(AllClustersMode, Bool);
00094 
00096   GetMacro(AllClustersMode, Bool);
00097 
00099   virtual void Run();
00100 };
00101 
00102 #endif