[vtkusers] Transform resulting ICP to data!!

Siti Khatijah khaty111 at hotmail.com
Sat Jan 15 23:51:22 EST 2005


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/




More information about the vtkusers mailing list