[vtkusers] re: vtkIterativeClosestPoint

Moti Freiman freiman at cs.huji.ac.il
Sun Jan 16 13:00:13 EST 2005


Hi!
you should add after your ICPTransform code section this lines:
ICPTransform->Update();
vtkMatrix4x4 * mat = vtkMatrix4x4::New();
mat->DeepCopy (ICPTransform->GetMatrix());

on this stage you got the transfrom matrix, then you should apply it to your data using vtkTransfrom, and vtkTransformPolyDataFilter.

hope it helps
-- 
Moti Freiman, Graduate Student.
Medical Image Processing and Computer-Assisted Surgery Laboratory.
School of Computer Science and Engineering.
The Hebrew University of Jerusalem Givat Ram, Jerusalem 91904, Israel 
Phone: +(972)-2-658-5371 (laboratory) 
E-mail: freiman at cs.huji.ac.il
WWW site: http://www.cs.huji.ac.il/~freiman  




Hi,
I'm new to this vtk and i need your help...I want to register two images 
together using Iterative Closest Point Transform...How do i transform the 
resulting ICP to my data or setting it to user's transform...I think i am 
missing something out..Any help is appreaciated..Thx..Below is my source 
code..

//Declaring all the variables needed
#include "vtkPolyDataMapper.h"  //maps polygonal data  to graphics
#include "vtkActor.h"	       //represents an object (geometry & properties) 
in a rendered scene
#include "vtkProperty.h"      //represent surface properties of a geometric 
object
#include "vtkRenderWindow.h"  //create a window for renderers to draw into
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCamera.h"
#include "vtkIterativeClosestPointTransform.h"
#include "vtkSTLReader.h"
#include "vtkPolyDataNormals.h"
#include "vtkLODActor.h"
#include "vtkOBJReader.h"
#include "vtkPolyData.h"


main()
{

//Create a rendering window and the renderer
vtkRenderWindow * renWin = vtkRenderWindow::New();
vtkRenderer * ren1 = vtkRenderer::New();

//Adding the renderers inside the rendering window
renWin->AddRenderer(ren1);

//Input the ctForehead image(.stl)
vtkSTLReader * ctForehead = vtkSTLReader::New();
ctForehead->SetFileName("C:/Documents and 
Settings/Khatijah/Desktop/examples/ctForehead.stl");

vtkPolyDataNormals * foreheadnormals = vtkPolyDataNormals::New();
foreheadnormals->SetInput(ctForehead->GetOutput());

vtkPolyDataMapper * foreheadMapper = vtkPolyDataMapper::New();
foreheadMapper->SetInput(foreheadnormals->GetOutput());

vtkLODActor  * foreheadActor = vtkLODActor::New();
foreheadActor->SetMapper(foreheadMapper);

//Reading .obj image
vtkOBJReader  * inspeckForehead = vtkOBJReader::New();
inspeckForehead->SetFileName("C:/Documents and 
Settings/Khatijah/Desktop/examples/initinspeckForehead.obj");

vtkPolyDataNormals * forehead2normals = vtkPolyDataNormals::New();
forehead2normals->SetInput(inspeckForehead->GetOutput());

vtkPolyDataMapper * forehead2Mapper = vtkPolyDataMapper::New();
forehead2Mapper->SetInput(forehead2normals->GetOutput());

vtkLODActor * forehead2Actor = vtkLODActor::New();
forehead2Actor->SetMapper(forehead2Mapper);


//vtkIterativeClosestPoint function
vtkIterativeClosestPointTransform *ICPTransform = 
vtkIterativeClosestPointTransform::New();
ICPTransform->SetSource(inspeckForehead->GetOutput());
ICPTransform->SetTarget(ctForehead->GetOutput());
ICPTransform->SetCheckMeanDistance(1);
ICPTransform->SetMaximumMeanDistance(0.001);
ICPTransform->SetMaximumNumberOfIterations(30);
ICPTransform->SetMaximumNumberOfLandmarks(500);

//assign actor to the renderer
ren1->AddActor(foreheadActor);
ren1->AddActor(forehead2Actor);
renWin->SetSize(800,400);

// Now we loop over 360 degreeees and render the cone each time.

  int i;
  for (i = 0; i < 360; ++i)
    {
    // render the image
    renWin->Render();
    // rotate the active camera by one degree
    ren1->GetActiveCamera()->Azimuth(0.1);
  }

//Begin mouse interaction
vtkRenderWindowInteractor * iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);


  iren->Initialize();
  iren->Start();

  return 0;
}

_________________________________________________________________
Keep track of Singapore & Malaysia stock prices. 
http://www.msn.com.sg/money/





-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.12 - Release Date: 14/01/2005



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.12 - Release Date: 14/01/2005




More information about the vtkusers mailing list