[vtkusers] Trouble modifying vtkIterativeClosestPointTransform

David Doria daviddoria at gmail.com
Thu May 14 20:49:03 EDT 2009


I am trying to implement the ICP improvement that only uses points which
have a closest point closer than some threshold in the landmark transform.
It looked like it would be easy to do - here's what I came up with. (The
commented lines are what I changed.)

The old version found the closest point to every point in 'a' and stored
them in 'closestp'. Then it used 'a' and 'closestp' to create the landmark
transform.
The new version finds the closest point to every point in 'a'. If the
distance is less than the threshold, it adds a[i] to 'UsedPoints' and adds
the closest point to 'closestp'. It then uses 'UsedPoints' and 'closestp' to
create the lankmark transform. Nothing else is changed - with the idea being
that 'a' will still be what is actually getting transformed.

---------------------------
vtkPoints *closestp = vtkPoints::New();
vtkPoints *UsedPoints = vtkPoints::New();

//clear the array used to create the landmark transform
  closestp->SetNumberOfPoints(0);
  UsedPoints->SetNumberOfPoints(0);

  // Fill closestp and UsedPoints with the closest points to each vertex in
input if they are sufficiently close
  for(i = 0; i < nb_points; i++)
  {
    this->Locator->FindClosestPoint(a->GetPoint(i),
                                      outPoint,
                                      cell_id,
                                      sub_id,
                                      dist2);
  //closestp->SetPoint(i, outPoint);
  if(dist2 < Thresh_)
  {
    closestp->InsertNextPoint(outPoint);
    UsedPoints->InsertNextPoint(a->GetPoint(i));
  }
}

// Build the landmark transform

//    this->LandmarkTransform->SetSourceLandmarks(a);
//    this->LandmarkTransform->SetTargetLandmarks(closestp);
    this->LandmarkTransform->SetSourceLandmarks(UsedPoints);
    this->LandmarkTransform->SetTargetLandmarks(closestp);
    this->LandmarkTransform->Update();

---------------------------
What happens is that in each iteration, the number of points used decreases
until it eventually gets to zero. I am using two polydata's which are very
close to each other and identical as the test source and target, so the
number of points used should certainly not decrease. I have a feeling it is
something to do with how the LandmarkTransform stores the vtkPoints data?
Does anyone see the problem with this?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090514/547d4137/attachment.htm>


More information about the vtkusers mailing list