[vtkusers] Help!! Whole 3D Image Slices display

Arsene ELLA ella at pet.mpin-koeln.mpg.de
Tue Mar 19 05:26:14 EST 2002


Hi,

Having a 3D image, how can I do to display all slices in the Z direction
in the same window?

For instance, to display the first Four slices in the Z direction of the 3D
vtk image " quarter ", I used the code below. But, I thing that it is really
exhausting to display all the 93 slices in this way.

--------------------------------------------------------------------------------------------
// 3D Image reader
  vtkImageReader *reader;
  reader = vtkImageReader::New();
  reader->ReleaseDataFlagOff();
  reader->SetDataByteOrderToLittleEndian();
  reader->SetDataExtent(0, 63, 0, 63, 1, 93);
  reader->SetDataSpacing(3.2, 3.2, 1.5);
  reader->SetFilePrefix("C:\\Program 
Files\\VTK40\\VTKData\\Data\\headsq\\quarter");
  //reader->SetDataMask(0x7fff);

  // Mapper1
  vtkImageMapper *mapper1;
  mapper1 = vtkImageMapper::New();
  mapper1->SetInput(reader->GetOutput());
  mapper1->SetColorWindow(2000);
  mapper1->SetColorLevel(1000);
  mapper1->SetZSlice(0);

  // Mapper2
  vtkImageMapper *mapper2;
  mapper2 = vtkImageMapper::New();
  mapper2->SetInput(reader->GetOutput());
  mapper2->SetColorWindow(2000);
  mapper2->SetColorLevel(1000);
  mapper2->SetZSlice(1);

  // Mapper3
  vtkImageMapper *mapper3;
  mapper3 = vtkImageMapper::New();
  mapper3->SetInput(reader->GetOutput());
  mapper3->SetColorWindow(2000);
  mapper3->SetColorLevel(1000);
  mapper3->SetZSlice(2);

  // Mapper4
  vtkImageMapper *mapper4;
  mapper4 = vtkImageMapper::New();
  mapper4->SetInput(reader->GetOutput());
  mapper4->SetColorWindow(2000);
  mapper4->SetColorLevel(1000);
  mapper4->SetZSlice(3);

  // actor1
  vtkActor2D *actor1;
  actor1 = vtkActor2D::New();
  actor1->SetMapper(mapper1);

  // actor2
  vtkActor2D *actor2;
  actor2 = vtkActor2D::New();
  actor2->SetMapper(mapper2);

  // actor3
  vtkActor2D *actor3;
  actor3 = vtkActor2D::New();
  actor3->SetMapper(mapper3);

  // actor4
  vtkActor2D *actor4;
  actor4 = vtkActor2D::New();
  actor4->SetMapper(mapper4);

  // Imager1
  vtkImager *imager1;
  imager1 = vtkImager::New();
  imager1->AddActor2D(actor1);
  imager1->SetViewport(0.5, 0.0, 1.0, 0.5);

  // Imager2
  vtkImager *imager2;
  imager2 = vtkImager::New();
  imager2->AddActor2D(actor2);
  imager2->SetViewport(0.0, 0.0, 0.5, 0.5);

  // Imager3
  vtkImager *imager3;
  imager3 = vtkImager::New();
  imager3->AddActor2D(actor3);
  imager3->SetViewport(0.5, 0.5, 1.0, 1.0);

  // Imager4
  vtkImager *imager4;
  imager4 = vtkImager::New();
  imager4->AddActor2D(actor4);
  imager4->SetViewport(0.0, 0.5, 0.5, 1.0);

  // Windows
  vtkImageWindow *imgWin;
  imgWin = vtkImageWindow::New();
  imgWin->AddImager(imager1);
  imgWin->AddImager(imager2);
  imgWin->AddImager(imager3);
  imgWin->AddImager(imager4);
  imgWin->SetSize(800, 800)

  // Render Setup
  imgWin->Render();
--------------------------------------------------------------------------------------------


thanks in advance for any help,

Arsene






Arsene ELLA, PhD
Max-Planck Institut Für Neurogische Forschung
Gleueler str, 50
D-50931 Cologne
GERMANY
Tel:   (+49) 221 478 5713
Mob: (+49) 174 320 7881
Fax:  (+49) 221 478 7256




More information about the vtkusers mailing list