34 #ifndef AIMS_PRIMALSKETCH_PRIMALSKETCH2GRAPH_H 35 #define AIMS_PRIMALSKETCH_PRIMALSKETCH2GRAPH_H 58 bool operator()(
const std::pair<int,float> p1,
const std::pair<int,float> p2)
60 if (p1.second>p2.second)
62 else if (p1.second == p2.second)
64 if (p1.first < p2.first)
100 _graph =
new Graph(
"PrimalSketchArg");
110 _motion =
new Motion( m );
125 template<
typename Geom,
typename Text>
128 std::list<ScaleSpaceBlob<Site>*> blobList=_primalSketch->BlobSet();
129 std::set<std::pair<int, float>,
ltstr_blob > labelSet;
130 typename std::list<ScaleSpaceBlob<Site>*>
::iterator blobIt;
134 std::cout <<
"Creating blob labels by decreasing maximum intensity" << std::endl;
135 for (blobIt=blobList.begin(); blobIt!=blobList.end(); ++blobIt)
137 labelSet.insert(std::pair<int,float>((*blobIt)->Label(), (*blobIt)->GetMeasurements().t));
139 for (labelIt=labelSet.begin(); labelIt!=labelSet.end(); ++labelIt)
142 sortedLabels[(*labelIt).first]=label;
147 template<
typename Geom,
typename Text>
149 std::list<Bifurcation<Site>*> bifList = _primalSketch->BifurcationList();
150 std::list<ScaleSpaceBlob<Site>*> blobList = _primalSketch->BlobSet();
152 typename std::list<ScaleSpaceBlob<Site>*>
::iterator blobIt;
153 typename std::list<Bifurcation<Site> *>
::iterator bifIt;
155 std::map<int, Vertex *> vertMap;
157 std::list<ScaleSpaceBlob<Site>*> top, bottom;
158 typename std::list<ScaleSpaceBlob<Site>*>
::iterator topIt, bottomIt;
164 std::string nameBase =
"*";
167 _graph->setProperty(
"filename_base",
"*");
168 _graph->setProperty(
"subject", _primalSketch->Subject() );
171 std::string textType;
172 if (_primalSketch->Type()==
IMAGE)
174 else if (_primalSketch->Type()==
SURFACE)
175 textType =
"surface";
177 textType =
"unknown";
178 _graph->setProperty(
"type", textType );
181 blobIt = blobList.begin();
183 for ( ; blobIt != blobList.end() ; ++blobIt ) {
185 vert =_graph->addVertex(
"ssblob" );
186 rank = sortedLabels[(*blobIt)->Label()];
187 sprintf( conv,
"%4i", rank );
189 vert->setProperty(
"label", 0 );
190 vert->setProperty(
"name", rank+10000 );
191 vert->setProperty(
"rank", rank );
192 vert->setProperty(
"index",(*blobIt)->Label() );
193 vert->setProperty(
"tmin",(*blobIt)->ScaleMin() );
194 vert->setProperty(
"tmax",(*blobIt)->ScaleMax() );
195 vert->setProperty(
"trep", (*blobIt)->ScaleRep() );
196 vert->setProperty(
"lifeTime", (*blobIt)->LifeTime() );
197 vert->setProperty(
"maxIntensity",(*blobIt)->GetMeasurements().maxIntensity );
198 vert->setProperty(
"meanIntensity",(*blobIt)->GetMeasurements().meanIntensity );
199 vert->setProperty(
"maxContrast",(*blobIt)->GetMeasurements().maxContrast );
200 vert->setProperty(
"meanContrast",(*blobIt)->GetMeasurements().meanContrast );
201 vert->setProperty(
"area",(*blobIt)->GetMeasurements().area );
202 vert->setProperty(
"tValue",(*blobIt)->GetMeasurements().tValue );
203 vert->setProperty(
"t",(*blobIt)->GetMeasurements().t );
204 std::cout << (*blobIt)->GetMeasurements().tValue <<
";";
209 float x1, x2, y1, y2, z1, z2, gx, gy, gz;
210 std::vector<float> vectF;
211 std::vector<float> triplet(3),
ref( 3 );
213 vectF = blobTools.Boundingbox();
214 x1 = vectF[0]; y1 = vectF[1]; z1 = vectF[2];
215 x2 = vectF[3]; y2 = vectF[4]; z2 = vectF[5];
216 gx = ( x1 + x2 ) / 2.0;
217 gy = ( y1 + y2 ) / 2.0;
218 gz = ( z1 + z2 ) / 2.0;
223 vert->setProperty(
"gravity_center", triplet);
227 = _motion->transform(
Point3df( triplet[0], triplet[1], triplet[2] ) );
231 vert->setProperty(
"refgravity_center", ref );
237 vert->setProperty(
"boundingbox_min", triplet );
241 vert->setProperty(
"boundingbox_max", triplet );
243 vertMap[(*blobIt)->Label()] = vert;
248 bifIt = bifList.begin();
std::map< int, int > sortedLabels
std::list< Bifurcation< Site > * > BifurcationList()
void AddBlobsToPSGraph(PrimalSketch< Geom, Text > *sketch, Graph *graph)
PrimalSketch< Geom, Text > * _primalSketch
SiteType< Geom >::type Site
bool operator()(const std::pair< int, float > p1, const std::pair< int, float > p2)
TexType< Text >::type Val
Primalsketch2graph(PrimalSketch< Geom, Text > *primalSketch)
void setMotion(const Motion &m)
reference_wrapper< T > ref(T &ref)