void BifurcationsInSkeletonization::Process()
{
printf("EED BifurcationsInSkeletonization::Process start \n");
-
- // ---- Step 1.1 Find start point of the segments ----
- // ---- step 1.2 Cleaning repeated start points ----
- // ---- Step 2.1 Find leaves ----
- // ---- Step 2.2 Cleaning repeated leaves ----
- // ---- Step 3.0 Find all bifurcations ----
+ // ---- Step 1.1 Find start point of the segments ----
+ // ---- step 1.2 Cleaning repeated start points ----
+ // ---- Step 2.1 Find leaves ----
+ // ---- Step 2.2 Cleaning repeated leaves ----
+ // ---- Step 3.0 Find all bifurcations ----
+ // ---- Step 3.1 Clean possible repeated bifurcations ----
-
std::vector<int> tmpLstX = bbGetInputLstX();
std::vector<int> tmpLstY = bbGetInputLstY();
std::vector<int> tmpLstZ = bbGetInputLstZ();
long int ww;
bool ok;
-
// ---- Step 1.1 Find start point of the segments-----------
-
w=2;
while (tmpLstX.size()!=0)
{
} // for i
-
// ---- Step 2.1 Find leaves -----------
tmpLstX = leavesLstX;
tmpLstY = leavesLstY;
} // while leavesLstX.size()!=0
-
-
- /*
- // --- Step 3.0 Find all bifurcations ---
- ww=-1;
- double gl=-1;
- while (leavesLstX.size()!=0)
- {
- px = leavesLstX[0];
- py = leavesLstY[0];
- pz = leavesLstZ[0];
- leavesLstX.erase( leavesLstX.begin() );
- leavesLstY.erase( leavesLstY.begin() );
- leavesLstZ.erase( leavesLstZ.begin() );
-// w = tmpImage->GetScalarComponentAsDouble(px,py,pz,0);
-// printf("EED BifurcationsInSkeletonization::Process px,py,pz %d %d %d w=%ld ww=%d \n", px,py,pz, w,ww);
- ok = true;
- while ( (tmpImage->GetScalarComponentAsDouble(px,py,pz,0)!=1) && (ok==true) )
- {
- // w = w - 1;
- w = tmpImage->GetScalarComponentAsDouble(px,py,pz,0);
- ok = false;
- tmpImage->SetScalarComponentFromDouble( px,py,pz,0,ww);
- for ( i=px-1 ; i<=px+1 ; i++ )
- {
- for ( j=py-1 ; j<=py+1 ; j++ )
- {
- for ( k=pz-1 ; k<=pz+1 ; k++ )
- {
- if (!((px==i) && (py==j) && (pz==k)))
- {
- gl = tmpImage->GetScalarComponentAsDouble(i,j,k,0);
- if ((gl<w) && (gl>0) )
- {
- tx = i;
- ty = j;
- tz = k;
- ok = true;
-// printf("EED BifurcationsInSkeletonization::Process tx,ty,tz %d %d %d \n", tx,ty,tz);
- } // if graylevel == w
- } // if px,py,pz != i,j,k
- } // for k
- } // for j
- } // for i
- px = tx;
- py = ty;
- pz = tz;
- } // while graylevel!=1 && ok==true
-
- ww = ww -1;
- ok = false;
- w = tmpImage->GetScalarComponentAsDouble(px,py,pz,0);
- for ( i=px-2 ; i<=px+2 ; i++ )
+ // ---- Step 3.1 Clean possible repeated bifurcations ----
+ size = outLstX.size();
+ for (i=size-1; i>=0; i--)
+ {
+ for (ii=size-1; ii>i; ii--)
{
- for ( j=py-2 ; j<=py+2 ; j++ )
+ if ( (outLstX[i]==outLstX[ii]) && (outLstY[i]==outLstY[ii]) && (outLstZ[i]==outLstZ[ii]) )
{
- for ( k=pz-2 ; k<=pz+2 ; k++ )
- {
- if (!((px==i) && (py==j) && (pz==k)))
- {
- gl = tmpImage->GetScalarComponentAsDouble(i,j,k,0);
- if (gl<0)
- {
- if ( abs( abs(gl)-abs(w) ) >= 2 )
- {
- ok=true;
- } // if abs (diff w)
- } // if graylevel == w
- } // if px,py,pz != i,j,k
- } // for k
- } // for j
- } // for i
-
- if (ok==true)
- {
- outLstX.push_back( px );
- outLstY.push_back( py );
- outLstZ.push_back( pz );
- }
-
- } // while leavesLstX.size()!=0
-
- */
- bbSetOutputOutLstX(outLstX);
- bbSetOutputOutLstY(outLstY);
- bbSetOutputOutLstZ(outLstZ);
+ outLstX.erase( outLstX.begin()+ii );
+ outLstY.erase( outLstY.begin()+ii );
+ outLstZ.erase( outLstZ.begin()+ii );
+ size--;
+ } // if iPoint == iiPoint
+ }// for ii
+ } // for i
+
+ bbSetOutputOutLstX(outLstX);
+ bbSetOutputOutLstY(outLstY);
+ bbSetOutputOutLstZ(outLstZ);
//bbSetOutputOutLstX(leavesLstX);
//bbSetOutputOutLstY(leavesLstY);
if (bbGetInputScalarRange().size()==2)
{
imgConnfilter->SetScalarRange( bbGetInputScalarRange()[0], bbGetInputScalarRange()[1] );
- printf("EED ImageConnectivityFilter Scalar Range %f %f \n", bbGetInputScalarRange()[0], bbGetInputScalarRange()[1]);
} // Range
if (bbGetInputExtractionMode()==0) // LargestRegion
} // ExtractionMode 1
if (bbGetInputExtractionMode()==2) // SeedRegions
{
- printf("EED ImageConnectivityFilter 1\n");
imgConnfilter->SetExtractionModeToSeededRegions();
std::vector<double> lstX = bbGetInputLstX();
std::vector<double> lstY = bbGetInputLstY();
std::vector<double> lstZ = bbGetInputLstZ();
if ( (lstX.size()>0) && (lstX.size()==lstY.size()) && (lstX.size()==lstZ.size()) )
{
- printf("EED ImageConnectivityFilter 2\n");
int i,size = lstX.size();
double p[3];
vtkPoints *points = vtkPoints::New();
p[0] = lstX[i];
p[1] = lstY[i];
p[2] = lstZ[i];
- printf("EED ImageConnectivityFilter 3 %f %f %f\n", p[0], p[1], p[2] );
points->InsertNextPoint(p);
} // for i
vtkPolyData *seedData = vtkPolyData::New();