TLIB documentation
 

tlBlobs.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  This file is part of the TLIB computer vision library.
00004 //  Copyright (C) 2003-2008 Sebastien Grange
00005 //  Copyright (C) 2003-2007 VRAI Group, EPFL
00006 //  All rights reserved.
00007 // 
00008 //  This library is free software; you can redistribute it and/or modify
00009 //  it under the terms of the GNU General Public License("GPL") version 2
00010 //  as published by the Free Software Foundation.
00011 // 
00012 //  <http://www.tuyphon.com/tlib>
00013 //
00014 /////////////////////////////////////////////////////////////////////////////////
00015 
00016 
00017 #ifndef __TLBLOBS_H__
00018 #define __TLBLOBS_H__
00019 
00020 
00021 #include "tlVision.h"
00022 
00023 
00024 
00025 #ifndef NO_DOC
00026 // blob list elements
00027 typedef struct lblob{
00028   int    index;
00029   tlMask *mask;
00030   lblob  *next;
00031   lblob  *prev;
00032 } lblob;
00033 #endif
00034 
00035 #define TL_MAX_LABELS  255
00036 
00037 
00038 
00039 // class declaration
00040 class tlBlobs
00041 {
00042 private:
00043   int    count;
00044         int    tcount;
00045         lblob  *current;
00046   lblob  *start;
00047   lblob  *end;
00048   int    connex;
00049   int    *labels;
00050 
00051   // internal chained list element creation
00052   struct lblob *newBlob (tlMask *mask);
00053 
00054   // internal management
00055   int remove  (lblob *blob);
00056   int swap    (lblob *lblob1, lblob* lblob2);
00057 
00058   // internal processing methods
00059   int processImage (tlImage *image, tlRect *rect, int minArea);
00060   int findBlobs    (tlImage *image, tlRect *rect);
00061   int extractBlobs (tlImage *image, tlRect *rect);
00062 
00063 public:
00064 
00065   // constructors
00066   tlBlobs  ();
00067   tlBlobs  (tlImage *image, int minArea = 0);
00068   tlBlobs  (tlImage *image, tlRect *rect, int minArea = 0);
00069   virtual ~tlBlobs ();
00070 
00071   // data management
00072   int    getCount     () { return count;  }
00073   tlMask *getBlob     (int index);
00074   int    getBlob      (int index, tlMask *mask);
00075   tlMask *getBlobCopy (int index);
00076 
00077   // list management
00078   void setConnex (int connex) { this->connex = connex; };
00079   int  reset ();
00080   int  clear ();
00081 
00082   // blobs construction
00083   int extract (tlImage *image, int minArea = 0);
00084   int extract (tlImage *image, tlRect *rect, int minArea = 0);
00085 
00086   // blob area filters
00087   int filterArea    (int minArea, int maxArea);
00088   int filterMinArea (int minArea);
00089   int filterMaxArea (int maxArea);
00090   
00091   // aspect ratio filter
00092   int filterAspect    (float minRatio, float maxRatio);
00093   int filterMinAspect (float minRatio);
00094   int filterMaxAspect (float maxRatio);
00095   
00096   // surface area filter
00097   int filterSurface    (float minRatio, float maxRatio);
00098   int filterMinSurface (float minRatio);
00099   int filterMaxSurface (float maxRatio);
00100   
00101   // distance between blobs filter
00102   int filterDistance   (float minDist, float maxDist);
00103   int filterMinDist    (float minDist);
00104   int filterMaxDist    (float maxDist);
00105   
00106   // sort blobs by area
00107   int sortByArea ();
00108 
00109   // blob management
00110   int add     (tlMask *mask);
00111   int insert  (int index, tlMask *mask);
00112   int remove  (int index);
00113   int swap    (int index1, int index2);
00114 };
00115 
00116 
00117 #endif


TLIB documentation - generated on 7 May 2008
Please address any questions to seb@tuyphon.com
(C) 2001-2008 - S. Grange
(C) 2001-2007 - VRAI Group, EPFL
All Rights Reserved.