[vtkusers] vtkImagePlaneWidget problem, (data thickness)

khinwee khinwee at yahoo.com
Fri Jan 21 09:20:56 EST 2011


Dear ALL,

I have two questions about the 3D rendering from multiple slices of MRI
images. For this task, I am using vtkImagePlaneWidget, to show the sagittal,
coronal and axial plane from the constructed 3d rendering.
First question: MRI images have thickness, for my case, it is 5mm, how can I
set this thickness in the program? The SetDataSpacing is the only way to set
the spacing between the slices, but not the thickness. Anyone having ideas?
 Second question: The resultant images after 3D rendering seems like have
been stretch, as shown in figure below: 

   http://vtk.1045678.n5.nabble.com/file/n3351486/Original.bmp 
(a) Original					


http://vtk.1045678.n5.nabble.com/file/n3351486/results_been_stretch.bmp 
(b) the result been stretch, why?

What is the problem? Is that because of the camera setting? I showed my
codes below:

int main()
{
vtkVolume16Reader *reader = vtkVolume16Reader::New();
 reader->SetDataOrigin(0,0,0);
reader->SetFilePrefix("C:\\Users\\Khin
Wee\\Desktop\\P2_MRI\\data\\004\\MR.978");
reader->SetDataSpacing(0.78125,0.78125,5);
reader->SetDataDimensions(511,447);
reader->SetImageRange(88, 136);
reader->SetDataByteOrderToLittleEndian();
reader->Update();

vtkImageCast *readerImageCast = vtkImageCast::New();
	readerImageCast->SetInput((vtkDataObject *)reader->GetOutput());
	readerImageCast->SetOutputScalarTypeToUnsignedChar();
	readerImageCast->ClampOverflowOn();
	readerImageCast->Update();

  vtkRenderer* ren1 = vtkRenderer::New();
  vtkRenderWindow* renWin = vtkRenderWindow::New();
  renWin->AddRenderer(ren1);

  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

  vtkCellPicker* picker = vtkCellPicker::New();
    picker->SetTolerance(0.005);

  vtkProperty* ipwProp = vtkProperty::New();
   
  vtkImagePlaneWidget* planeWidgetX = vtkImagePlaneWidget::New();
    planeWidgetX->SetInteractor( iren);
    planeWidgetX->SetKeyPressActivationValue('x');
    planeWidgetX->SetPicker(picker);
    planeWidgetX->RestrictPlaneToVolumeOn();
    planeWidgetX->GetPlaneProperty()->SetColor(1,0,0);
    planeWidgetX->SetTexturePlaneProperty(ipwProp);
    planeWidgetX->TextureInterpolateOff();
    planeWidgetX->SetResliceInterpolateToNearestNeighbour();
    planeWidgetX->SetInput(readerImageCast->GetOutput());
    planeWidgetX->SetPlaneOrientationToXAxes();
	planeWidgetX->SetSlicePosition(150);
    planeWidgetX->DisplayTextOn();
    planeWidgetX->On();
    planeWidgetX->InteractionOn();

  vtkImagePlaneWidget* planeWidgetY = vtkImagePlaneWidget::New();
    planeWidgetY->SetInteractor( iren);
    planeWidgetY->SetKeyPressActivationValue('y');
    planeWidgetY->SetPicker(picker);
    planeWidgetY->GetPlaneProperty()->SetColor(1,1,0);
    planeWidgetY->SetTexturePlaneProperty(ipwProp);
    planeWidgetY->TextureInterpolateOn();
    planeWidgetY->SetResliceInterpolateToLinear();
    planeWidgetY->SetInput(readerImageCast->GetOutput());
    planeWidgetY->SetPlaneOrientationToYAxes();
    planeWidgetY->SetSlicePosition(140);
    planeWidgetY->DisplayTextOn();
    planeWidgetY->UpdatePlacement();
    planeWidgetY->On();

  vtkImagePlaneWidget* planeWidgetZ = vtkImagePlaneWidget::New();
    planeWidgetZ->SetInteractor( iren);
    planeWidgetZ->SetKeyPressActivationValue('z');
    planeWidgetZ->SetPicker(picker);
    planeWidgetZ->GetPlaneProperty()->SetColor(0,0,1);
    planeWidgetZ->SetTexturePlaneProperty(ipwProp);
    planeWidgetZ->TextureInterpolateOn();
    planeWidgetZ->SetResliceInterpolateToCubic();
    planeWidgetZ->SetInput(readerImageCast->GetOutput());
    planeWidgetZ->SetPlaneOrientationToZAxes();
    planeWidgetZ->SetSliceIndex(80);
    planeWidgetZ->DisplayTextOn();
    planeWidgetZ->On();

  ren1->SetBackground( 0.1, 0.1, 0.2);
  renWin->SetSize( 600, 600);
  renWin->Render();
  iren->Initialize();
  iren->Start();
  renWin->Render();
  ipwProp->Delete();
  planeWidgetX->Delete();
  planeWidgetY->Delete();
  planeWidgetZ->Delete();
  picker->Delete();
  outlineActor->Delete();
  outlineMapper->Delete();
  outline->Delete();
  iren->Delete();
  renWin->Delete();
  ren1->Delete();
  reader->Delete();
  return 0;
}



-- 
View this message in context: http://vtk.1045678.n5.nabble.com/vtkImagePlaneWidget-problem-data-thickness-tp3351486p3351486.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list