-//--------------------------------------------------------------------
-template <class ImageType, class MaskImageType>
-void
-clitk::ExtractLungFilter<ImageType, MaskImageType>::
-TrackFromThisIndex(std::vector<BifurcationType> & listOfBifurcations,
- MaskImagePointer skeleton,
- MaskImageIndexType index,
- MaskImagePixelType label,
- TreeIterator currentNode)
-{
- // Create NeighborhoodIterator
- typedef itk::NeighborhoodIterator<MaskImageType> NeighborhoodIteratorType;
- typename NeighborhoodIteratorType::SizeType radius;
- radius.Fill(1);
- NeighborhoodIteratorType nit(radius, skeleton, skeleton->GetLargestPossibleRegion());
-
- // Track
- std::vector<typename NeighborhoodIteratorType::IndexType> listOfTrackedPoint;
- bool stop = false;
- while (!stop) {
- nit.SetLocation(index);
- nit.SetCenterPixel(label);
- listOfTrackedPoint.clear();
- for(unsigned int i=0; i<nit.Size(); i++) {
- if (i != nit.GetCenterNeighborhoodIndex ()) { // Do not observe the current point
- if (nit.GetPixel(i) == GetForegroundValue()) { // if this is foreground, we continue the tracking
- listOfTrackedPoint.push_back(nit.GetIndex(i));
- }
- }
- }
- if (listOfTrackedPoint.size() == 1) {
- // Add this point to the current path
- currentNode = m_SkeletonTree.append_child(currentNode, listOfTrackedPoint[0]);
- index = listOfTrackedPoint[0];
- }
- else {
- if (listOfTrackedPoint.size() == 2) {
- // m_SkeletonTree->Add(listOfTrackedPoint[0], index); // the parent is 'index'
- // m_SkeletonTree->Add(listOfTrackedPoint[1], index); // the parent is 'index'
- BifurcationType bif(index, label, label+1, label+2);
- bif.treeIter = currentNode;
- listOfBifurcations.push_back(bif);
- TreeIterator firstNode = m_SkeletonTree.append_child(currentNode, listOfTrackedPoint[0]);
- TreeIterator secondNode = m_SkeletonTree.append_child(currentNode, listOfTrackedPoint[1]);
- TrackFromThisIndex(listOfBifurcations, skeleton, listOfTrackedPoint[0], label+1, firstNode);
- TrackFromThisIndex(listOfBifurcations, skeleton, listOfTrackedPoint[1], label+2, secondNode);
- }
- else {
- if (listOfTrackedPoint.size() > 2) {
- clitkExceptionMacro("error while tracking trachea bifurcation. Too much bifurcation points ... ?");
- }
- // Else this it the end of the tracking
- }
- stop = true;
- }
- }
-}
-//--------------------------------------------------------------------
-
-