aimsalgo  5.1.2
Neuroimaging image processing
bucketblob.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef AIMS_SCALESPACE_BUCKETBLOB_H
36 #define AIMS_SCALESPACE_BUCKETBLOB_H
37 
38 #include <aims/bucket/bucket.h>
40 
41 
42 namespace aims
43 {
44 
47  template <typename T>
49  {
50  public:
51  struct BlobStruct
52  {
53  BlobStruct() : newblobnum( 0 ), keepallblobs( false ), background( -10 )
54  {}
57  std::map<int, int> mergemap;
58  // value in this map is the merge position
59  std::map<int, Point3d> deadblobs;
62  };
63 
65  {
66  public:
67  virtual ~StopCriterion() {}
68 #if __GNUC__ == 3 && __GNUC_MINOR__ == 2 // bug in gcc 3.2 (mingw)
69  virtual bool stops( const Point3d &, const BlobStruct & bs ) {}
70 #else
71  virtual bool stops( const Point3d &, const BlobStruct & bs ) = 0;
72 #endif
73  virtual bool doesKeepBlob( int, const BlobStruct & ) { return true; }
74  };
75 
77  {
78  public:
79  virtual ~NoStopCriterion() {}
80  virtual bool stops( const Point3d &, const BlobStruct & )
81  { return false; }
82  };
83 
85  {
86  public:
88  ( const std::set<Point3d, BucketMapLess> & toJoin );
90  virtual bool stops( const Point3d &, const BlobStruct & bs );
91  virtual bool doesKeepBlob( int blob, const BlobStruct & );
92 
93  std::set<Point3d, BucketMapLess> pointsToJoin;
94  int mainblob;
95  };
96 
97 
99  {
100  public:
101  virtual ~BlobsMerger();
102  virtual void merge( const std::set<int> & tomerge, BlobStruct & bs,
103  const Point3d & p );
104  };
105 
106 
107  class GLBlobsMerger : public BlobsMerger
108  {
109  public:
110  GLBlobsMerger();
111  virtual ~GLBlobsMerger();
112  virtual void merge( const std::set<int> & tomerge, BlobStruct & bs,
113  const Point3d & p );
114  };
115 
116 
117  BucketBlobExtractor( StopCriterion* sc, bool minima,
118  bool keepallblobs = false, BlobsMerger* m = 0 );
120 
126  BucketMap<Void> *extractBlobs( const BucketMap<T> & valuemap );
127 
128  protected:
129  void neighborBlobs( std::set<int> &, const Point3d &, const BlobStruct & );
130 
133  bool _minima;
136  };
137 
138 
139  extern template class BucketBlobExtractor<float>;
140 
141 }
142 
143 #endif
144 
145 
146 
virtual void merge(const std::set< int > &tomerge, BlobStruct &bs, const Point3d &p)
Definition: bucketblob_d.h:240
virtual void merge(const std::set< int > &tomerge, BlobStruct &bs, const Point3d &p)
Definition: bucketblob_d.h:274
virtual bool stops(const Point3d &, const BlobStruct &)
Definition: bucketblob.h:80
virtual bool stops(const Point3d &, const BlobStruct &bs)
Definition: bucketblob_d.h:186
std::set< Point3d, BucketMapLess > pointsToJoin
Definition: bucketblob.h:93
virtual bool doesKeepBlob(int blob, const BlobStruct &)
Definition: bucketblob_d.h:225
OneComponentStopCriterion(const std::set< Point3d, BucketMapLess > &toJoin)
Definition: bucketblob_d.h:171
virtual bool stops(const Point3d &, const BlobStruct &bs)=0
virtual bool doesKeepBlob(int, const BlobStruct &)
Definition: bucketblob.h:73
Blobs and watershed.
Definition: bucketblob.h:49
BucketMap< Void > * extractBlobs(const BucketMap< T > &valuemap)
Extracts blobs or watershed.
Definition: bucketblob_d.h:94
void neighborBlobs(std::set< int > &, const Point3d &, const BlobStruct &)
Definition: bucketblob_d.h:65
BucketBlobExtractor(StopCriterion *sc, bool minima, bool keepallblobs=false, BlobsMerger *m=0)
Definition: bucketblob_d.h:44
Connectivity::Type _connectivity
Definition: bucketblob.h:135
StopCriterion * _stop
Definition: bucketblob.h:131
Connectivity::Type connectivity() const
Definition: bucketblob.h:122
void setConnectivity(Connectivity::Type t)
Definition: bucketblob.h:121
std::map< int, Point3d > deadblobs
Definition: bucketblob.h:59