- std::vector<BifurcationType> listOfBifurcations;
- m_SkeletonTree.set_head(index);
- TrackFromThisIndex(listOfBifurcations, skeleton, index, label, m_SkeletonTree.begin());
- DD("end track");
-
- // Convert index into physical point coordinates
- for(unsigned int i=0; i<listOfBifurcations.size(); i++) {
- skeleton->TransformIndexToPhysicalPoint(listOfBifurcations[i].index,
- listOfBifurcations[i].point);
+ FullTreeNodeType n;
+ n.index = index;
+ skeleton->TransformIndexToPhysicalPoint(n.index, n.point); // à mettre dans TrackFromThisIndex2
+ mFullSkeletonTree.set_head(n);
+ StructuralTreeNodeType sn;
+ sn.index = index;
+ skeleton->TransformIndexToPhysicalPoint(sn.index, sn.point);
+ mStructuralSkeletonTree.set_head(sn);
+ TrackFromThisIndex2(index, skeleton, label, mFullSkeletonTree.begin(), mStructuralSkeletonTree.begin());
+ StopCurrentStep();
+
+ // Reput FG instead of label in the skeleton image
+ skeleton = clitk::SetBackground<ImageType, ImageType>(skeleton, skeleton, label, GetForegroundValue(), true);
+
+ // Debug
+ typename StructuralTreeType::iterator sit = mStructuralSkeletonTree.begin();
+ while (sit != mStructuralSkeletonTree.end()) {
+ DD(sit->point);
+ ++sit;
+ }
+
+ // compute weight : n longueurs à chaque bifurfaction.
+ // parcours de FullTreeNodeType, à partir de leaf, remonter de proche en proche la distance eucl.
+ // par post order
+
+ // Init
+ typename FullTreeType::iterator fit = mFullSkeletonTree.begin();
+ while (fit != mFullSkeletonTree.end()) {
+ fit->weight = 0.0;
+ ++fit;
+ }
+
+ DD("compute weight");
+ typename FullTreeType::post_order_iterator pit = mFullSkeletonTree.begin_post();
+ while (pit != mFullSkeletonTree.end_post()) {
+ //DD(pit->point);
+ /*
+ if (pit != mFullSkeletonTree.begin()) {
+ typename FullTreeType::iterator parent = mFullSkeletonTree.parent(pit);
+ double d = pit->point.EuclideanDistanceTo(parent->point);
+ // DD(parent->weight);
+ //DD(d);
+ parent->weight += d;
+ if (pit.number_of_children() > 1) {
+ DD(pit.number_of_children());
+ DD(pit->point);
+ DD(pit->weight);
+ DD(parent->weight);
+ DD(mFullSkeletonTree.child(pit, 0)->weight);
+ DD(mFullSkeletonTree.child(pit, 1)->weight);
+ }
+ }
+ */
+ double previous = pit->weight;
+ for(uint i=0; i<pit.number_of_children(); i++) {
+ double d = pit->point.EuclideanDistanceTo(mFullSkeletonTree.child(pit, i)->point);
+ // pit->weight = pit->weight + mFullSkeletonTree.child(pit, i)->weight + d;
+ if (i==0)
+ pit->weight = pit->weight + mFullSkeletonTree.child(pit, i)->weight + d;
+ if (i>0) {
+ DD(pit.number_of_children());
+ DD(pit->point);
+ DD(pit->weight);
+ DD(mFullSkeletonTree.child(pit, 0)->weight);
+ DD(mFullSkeletonTree.child(pit, 1)->weight);
+ pit->weight = std::max(pit->weight, previous+mFullSkeletonTree.child(pit, i)->weight + d);
+ }
+ }
+ ++pit;
+ }
+
+ DD("end");
+ fit = mFullSkeletonTree.begin();
+ while (fit != mFullSkeletonTree.end()) {
+ std::cout << "p = " << fit->point
+ << " " << fit->weight
+ << " child= " << fit.number_of_children()
+ << " -> ";
+ for(uint i=0; i<fit.number_of_children(); i++) {
+ std::cout << " " << mFullSkeletonTree.child(fit, i)->weight;
+ }
+ std::cout << std::endl;
+ ++fit;