[vtkusers] vtkImageViewer Help

Abhi Rampal a_rampal at hotmail.com
Thu Jun 2 14:28:08 EDT 2005


Good Day,

I wrote a program in C++ to view DICOM images using vtKImageViewer. When I 
run the program the window into which the image is loaded closes 
automatically. With Polydata I woudl use vtkRenderWindowInteractor to keep 
the window open but this solution does not work with vtkImageViewer. Does 
anyone have a solution?

the code being used is:

  vtkImageReader *reader = vtkImageReader::New();
  reader->SetDataByteOrderToLittleEndian();
  reader->SetDataExtent(0,63,0,63,40,40);
  reader->SetFilePrefix("C:\\vtk\\VTKData\\Data\\headsq\\quarter");
  reader->SetDataMask(0x7fff);

  vtkImageGradient *gradient = vtkImageGradient::New();
  gradient->SetInput(reader->GetOutput());
  gradient->SetDimensionality(3);

  vtkImageViewer *viewer = vtkImageViewer::New();
  viewer->SetInput(gradient->GetOutput());
  viewer->SetZSlice(22);
  viewer->SetColorWindow(2000);
  viewer->SetColorLevel(0);
  viewer->Render();

  reader->Delete();
  gradient->Delete();
  viewer->Delete();

Thank you and with kind regards,

Abhi





More information about the vtkusers mailing list