[Insight-users] viewing with VTK

Luis Ibanez luis.ibanez@kitware.com
Tue, 12 Nov 2002 09:16:02 -0500


Hi Zein,

The simplest way to view an ITK volume
with VTK is the following


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


#include "itkImageFileReader.h"
#include "itkImageToVTKImageFilter.h"
#include "itkImage.h"

#include "vtkImageViewer.h"
#include "vtkRenderWindowInteractor.h"


int main( int argc, char ** argv )
{

   if( argc < 3 )
     {
       std::cerr << "Usage: viewer1 imagefilename slicenumber";
       std::cerr << std::endl;
     }

   typedef unsigned char PixelType;

   typedef itk::Image< PixelType, 3 >         ImageType;
   typedef itk::ImageFileReader< ImageType >  ReaderType;

   typedef itk::ImageToVTKImageFilter< ImageType >  ConnectorFilterType;


   ReaderType::Pointer  reader =3D ReaderType::New();
   ConnectorFilterType::Pointer connector =3D ConnectorFilterType::New();=


   reader->SetFileName( argv[1] );

   connector->SetInput( reader->GetOutput() );

   vtkImageViewer * viewer =3D vtkImageViewer::New();

   vtkRenderWindowInteractor * renderWindowInteractor =3D
                                   vtkRenderWindowInteractor::New();

   viewer->SetupInteractor( renderWindowInteractor );
   viewer->SetInput( connector->GetOutput() );

   viewer->SetZSlice( atoi( argv[2] ) ); // <-- Slice selection

   renderWindowInteractor->Start();


   return 0;

}


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

The itkImageToVTKImageFilter  can be found in
the directory :

           Insight/Auxiliary/vtk

Note that the simplest way is not necessarily
the nicest     :-)


Please let us know if you encounter any problem,


Thanks


    Luis


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D



Zein Salah wrote:

> hello Friends,
>=20
> =20
>=20
> What is the simplest way to view a 3D volume (a meta file) using VTK?
>=20
> =20
>=20
> Many thanks,
>=20
> =20
>=20
> Zein
>=20
> =20
>=20
> =20
>=20
> ->8<------------->8<------------->8<------------->8<------------->8<---=
---------->8<-
> Zein I. Salah
> Universit=E4t T=FCbingen, WSI-GRIS
> Sand 14
> 72076 T=FCbingen
> Email: salah@gris.uni-tuebingen.de <mailto:salah@gris.uni-tuebingen.de>=
 =20
> / zeinsalah@hotmail.com <mailto:zeinsalah@hotmail.com>
> Tel.: (07071) 29 75465 (GRIS) , (07071) 96 44 39 (privat)
> Fax: (07071) 29 54 66
>=20