aimsalgo 6.0.0
Neuroimaging image processing
scaleSpaceBlob.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#ifndef AIMS_PRIMALSKETCH_SCALESPACEBLOB_H
35#define AIMS_PRIMALSKETCH_SCALESPACEBLOB_H
36
37#include <cstdlib>
40#include <set>
41#include <map>
42#include <list>
43#include <utility>
44
45namespace aims
46{
55
56 template<class T> class ScaleSpaceBlob;
57 template<class T> class Bifurcation {
58
59 protected:
60 char _type;
61 std::list<ScaleSpaceBlob<T>*> topBlobs; // scale(bottomBlobs) < scale(topBlobs)
62 std::list<ScaleSpaceBlob<T>*> bottomBlobs; // by convention
63 float _tUp;
64 float _tDown;
65 float _tMid;
66
67 public:
68
69 Bifurcation(char type, float tUp, float tDown) : _type(type), _tUp(tUp), _tDown (tDown){
70
71 _tMid=exp((log(_tUp)+log(_tDown))/2.0);
72
73 }
74 char Type() {return _type;}
75 float tUp() {return _tUp;}
76 float tDown() {return _tDown;}
77 float tMid() {return _tMid;}
78 void setType(char type){ _type = type; }
79 void settUp(float tUp){ _tUp = tUp; }
80 void settDown(float tDown){ _tDown = tDown; }
81 void settMid(float tMid){ _tMid = tMid; }
82
83 void AddTopBlob(ScaleSpaceBlob<T> *blob) {topBlobs.push_back(blob);}
84 void AddBottomBlob(ScaleSpaceBlob<T> *blob) {bottomBlobs.push_back(blob);}
85 std::list<ScaleSpaceBlob<T>*> TopBlobs() {return topBlobs;}
86 std::list<ScaleSpaceBlob<T>*> BottomBlobs() {return bottomBlobs;}
87 };
88
89 // Scale space blobs
90 // Characterised by an image/subject name (default="subject")
91 // and a label. This is for future graph handling and multi-subject
92 // matching
93
94 template<class T> class ScaleSpaceBlob {
95
96 protected:
97
98 std::string _subject;
99 int _label;
100 //std::list<GreyLevelBlob<T>*> glBlobs;
101 float scaleMin;
102 float scaleMax;
103
104 float scaleRep; // scale at which the blob will be represented
106
107 float lifeTime;
109
110 Bifurcation<T> *topBifurcation; // scale(topBif)>scale(bottomBif)
112
113 // Rajouter les mesures, localisation, glBlob representatif, etc...
114
115 public:
116
117 ScaleSpaceBlob() { glBlobs = std::list<GreyLevelBlob<T>*>(); }
118 ScaleSpaceBlob( const std::string & subject )
119 {
120 _subject = subject;
121 glBlobs = std::list<GreyLevelBlob<T>*>();
122 }
123 ScaleSpaceBlob( const std::string & subject, int label )
124 {
125 _subject = subject;
126 _label = label;
127 glBlobs = std::list<GreyLevelBlob<T>*>();
128 }
129 void SetLabel( int label ) { label = _label; }
130 int Label() { return _label; }
131
132 // test
133 std::list<GreyLevelBlob<T>*> glBlobs;
134
135 void SetScaleMin(float t) {scaleMin=t;}
136 void SetScaleMax(float t) {scaleMax=t;}
137 float ScaleMin() {return scaleMin;}
138 float ScaleMax() {return scaleMax;}
139 float ScaleRep() {return scaleRep;}
140 float LifeTime() {return lifeTime;}
142
147 //std::list<GreyLevelBlob<T>*> GlBlobs() {return glBlobs;}
148 void AddGreyLevelBlob(GreyLevelBlob<T> *blob) { glBlobs.push_back(blob); }
153 };
154
155 // --------------Definitions-------------------------------------------------------
156
157 template<class T> void ScaleSpaceBlob<T>::ComputeLifeTime()
158 {
159 lifeTime=log(topBifurcation->tMid()) - log(bottomBifurcation->tMid());
160 }
161
162 //---------------------------------------
163
164 template<class T> void ScaleSpaceBlob<T>::ComputeScaleRep()
165 {
166 // Cette definition peut changer, il peut même y en avoir plusieurs
167 // temporaire, donc.
168 float t, delta=1000.0;
169 typename std::list<GreyLevelBlob<T>*>::iterator
170 itBlob=glBlobs.begin();
171
172 scaleRep=exp((log(scaleMin) + log(scaleMax))/2.0); // the ususal logarithmic scale
173// cout << "sR : " << scaleMin << ";" << scaleMax << ";" << scaleRep ;
174 for (; itBlob!=glBlobs.end(); ++itBlob) // now finding the glBlob that has a scale the closest
175 {
176 t=(*itBlob)->GetScale(); // to scaleRep
177// cout << t << endl;
178 if (fabs(t-scaleRep) < delta)
179 {
180 delta=fabs(t-scaleRep);
181 glBlobRep=(*itBlob);
182 }
183 }
184// if (glBlobRep->GetListePoints().size() == 1) cout << "->" << glBlobRep->GetScale() << "test" << endl; else cout << endl;
185
186 }
187
188}
189
190#endif
Bifurcation(char type, float tUp, float tDown)
std::list< ScaleSpaceBlob< T > * > TopBlobs()
void settUp(float tUp)
std::list< ScaleSpaceBlob< T > * > bottomBlobs
void AddTopBlob(ScaleSpaceBlob< T > *blob)
void setType(char type)
std::list< ScaleSpaceBlob< T > * > BottomBlobs()
void AddBottomBlob(ScaleSpaceBlob< T > *blob)
void settMid(float tMid)
std::list< ScaleSpaceBlob< T > * > topBlobs
void settDown(float tDown)
Class for grey-level blobs Templated with respect to the type of points: TypeSite<carto::VolumeRef<T>...
void SetLabel(int label)
Bifurcation< T > * bottomBifurcation
Bifurcation< T > * TopBifurcation()
void AddGreyLevelBlob(GreyLevelBlob< T > *blob)
GreyLevelBlob< T > * GlBlobRep()
BlobMeasurements measurements
void SetScaleMin(float t)
void SetBottomBifurcation(Bifurcation< T > *bif)
Bifurcation< T > * BottomBifurcation()
GreyLevelBlob< T > * glBlobRep
BlobMeasurements GetMeasurements()
void SetMeasurements(BlobMeasurements meas)
ScaleSpaceBlob(const std::string &subject, int label)
std::list< GreyLevelBlob< T > * > glBlobs
void SetTopBifurcation(Bifurcation< T > *bif)
ScaleSpaceBlob(const std::string &subject)
Bifurcation< T > * topBifurcation
void SetScaleMax(float t)
PrimalSketchEvents