[vtkusers] ITK beginer

Massi Massinissa.Bandou at USherbrooke.ca
Thu Mar 1 11:57:34 EST 2012


Hi 

I started learning ITK-VTK according this web site: (really good for a
beginner) 
http://www.vtk.org/Wiki/VTK/Examples/Cxx

There is an example of reading an JPEG image (your image should be in the
same directory as you executable)

#include "itkImageFileReader.h"
#include "itkImage.h"
#include "vtkJPEGReader.h"
#include "vtkImageViewer2.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
#include "vtkRenderWindowInteractor.h"

int main(int arg, char ** argv)
 {
         vtkSmartPointer<vtkJPEGReader> jpegReader =
vtkSmartPointer<vtkJPEGReader>::New();
	 jpegReader->SetFileName("your image.jpg");

 //Vizualisation
	 vtkSmartPointer<vtkImageViewer2> imageViewer =
vtkSmartPointer<vtkImageViewer2>::New();
	 imageViewer->SetInputConnection(jpegReader->GetOutputPort());

	 vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =    
         vtkSmartPointer<vtkRenderWindowInteractor>::New();
	 imageViewer->SetupInteractor(renderWindowInteractor);

	 imageViewer->Render();
	 imageViewer->GetRenderer()->ResetCamera();
	 imageViewer->Render();

	 renderWindowInteractor->Start();

 return 0;
 }

make sure you have all the headers!!

Massi



--
View this message in context: http://vtk.1045678.n5.nabble.com/ITK-beginer-tp5528382p5528483.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list