[vtkusers] Volume rendering with ray casting

paulus joo paulusjoo at hotmail.com
Wed Jun 30 13:19:49 EDT 2004


Hi Madhu


Sorry I am newbie also in VTK but I will share my experience to you.
I did the same thing with you. I will give you the code if you need it :-)

Volume rendering is different with surface rendering. In volume rendering the volume doesn't need to be segmented before rendered. In my code you will find 4 modes of volume rendering:MIP,Composite,Isosurface and X-Ray like projection. For surface rendering, you can derive from medical1.cxx, medical2.cxx or medical.cxx examples or I can give you also the code.

To use my code you must have the dataset where each voxel stored in unsigned char. If you have dicom data you can read by VolView and save as a series of PNG,BMP, or PNM (my code use PNG format). You can download VolView from internet. 

Cheers
 

----- Original Message ----- 
  From: Madhusudhanan Balasubramanian 
  To: vtkusers at vtk.org 
  Sent: Wednesday, June 30, 2004 5:58 PM
  Subject: [vtkusers] Volume rendering with ray casting


  Hi all,

  I've a volume data that I tried to volume render with ray casting(which I constructed from 5, 2D images).  I've a couple of questions at this time:

  1. When I rotate the volume around, assuming that image slice 1 is visible, I expect the see the structures in other slices; say if I rotate it 180 degrees around I'm expecting to see structures from image slice 5; but I still see only the structures from slice 1.  Am I missing something while rendering?  (I've verified the dimensions of the volume dataset and it is correct).

  2. Are there segmentation algorithms that are available with vtk that can used on 2D images before being volume rendered?

  3. With the volume built from 5 image slices, when I rotate the volume around, the thickness of the volume (along z-axis) appears to be got just from a single image.  May be I'm doing something wrong in rendering.

  Here are few fragments of my code that I used to volume render:

  CVolRendererView::CVolRendererView()
  {
   this->color = vtkPiecewiseFunction::New();
   this->color->AddPoint(0, 0.0);
   this->color->AddPoint(255, 1.0);

   this->opacity = vtkPiecewiseFunction::New();
   this->opacity->AddPoint(0, 0.0);
   this->opacity->AddPoint(130, 0.0);
   this->opacity->AddPoint(140, 1.0);
   this->opacity->AddPoint(255, 1.0);

   this->gradOpacity = vtkPiecewiseFunction::New();
   this->gradOpacity->AddPoint(0, 0.0);
   this->gradOpacity->AddPoint(3, 0.0);
   this->gradOpacity->AddPoint(6, 1.0);
   this->gradOpacity->AddPoint(255, 1.0);

   this->property = vtkVolumeProperty::New();
   this->property->SetColor(this->color);
   this->property->SetScalarOpacity(this->opacity);
   this->property->SetGradientOpacity(this->gradOpacity);
   this->property->ShadeOn();
   this->property->SetInterpolationTypeToLinear();

   this->composite = vtkVolumeRayCastCompositeFunction::New();
   this->composite->SetCompositeMethodToInterpolateFirst();

   this->mapper = vtkVolumeRayCastMapper::New();
   this->mapper->SetVolumeRayCastFunction(composite);

   this->volume = vtkVolume::New();
   this->volume->SetMapper(this->mapper);
   this->volume->SetProperty(this->property);

   this->ren = vtkRenderer::New();
   this->ren->AddVolume(volume);
   this->renWin = vtkWin32OpenGLRenderWindow::New();

   this->iren = vtkRenderWindowInteractor::New();

   this->imageAppend = vtkImageAppend::New();
   this->imageAppend->SetAppendAxis(2);

   this->renWin->AddRenderer(this->ren);
   this->iren->SetRenderWindow(this->renWin);
   this->iren->Start();
  }

  //Updating the volume with new image slices
  this->imageAppend->AddInput(this->GetDocument()->reader->GetOutput());
  this->imageAppend->UpdateWholeExtent();

  //Rendering
  this->mapper->SetInput((vtkImageData*)this->imageAppend->GetOutput());
  this->ren->ResetCamera();
  this->renWin->Render();

  I would appreciate your inputs on this.

  Thanks,
  Madhu.
  __________________________________________________
  Do You Yahoo!?
  Tired of spam? Yahoo! Mail has the best spam protection around 
  http://mail.yahoo.com 



------------------------------------------------------------------------------


  _______________________________________________
  This is the private VTK discussion list. 
  Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
  Follow this link to subscribe/unsubscribe:
  http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040630/b19add48/attachment.htm>


More information about the vtkusers mailing list