[vtkusers] Volume rendering with *.mhd

Urvoas, Paul paul.urvoas at philips.com
Tue Jul 13 05:59:26 EDT 2010


Hi,
I would like to visualize volume with a vtk volume rendering. With that code, there is no error but we don't see a volume in the window, only a black slice... Maybe I have to change the rendering mode to visualize in 3d instead of in 2d? Then, how can I choose the range of the color (intensity) I want to visualize in the window ?

Kind regards,
Paul


int main() {

   typedef itk::Image<unsigned char, 3> ImageType;
   // Declare a reader
   typedef itk::ImageFileReader< ImageType > VolumeReaderType;
   VolumeReaderType::Pointer reader = VolumeReaderType::New();

   // Set the name of the file to read
   reader->SetFileName( "FILTER.mhd" );

   // See if the file can be read - "try" otherwise program will
   //   mysteriously exit on failure in the Object factory
   try{reader->Update();}
   catch( ... ){
     std::cout << "Problems reading file format" << std::endl;
     return  EXIT_FAILURE;
   }

   typedef itk::ImageToVTKImageFilter< ImageType>  ConnectorType;
   ConnectorType::Pointer connector = ConnectorType::New();
   connector->SetInput( reader->GetOutput() );

   // Add image to an vtk actor
    vtkImageActor * imageActor = vtkImageActor::New();
    imageActor->SetInput(connector->GetOutput());

    //Add that actor to the renderer
    vtkRenderer *ren1 = vtkRenderer::New();
    ren1->AddActor(imageActor);
    ren1->SetBackground(0.1, 0.2, 0.4);

    //Create a render window
    vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(ren1);
    renWin->SetSize(600, 600);

    ren1->ResetCamera();
    ren1->GetActiveCamera()->Zoom(1.5);
    renWin->Render();

     //Create an interactor and associate it to the render window
    vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

    //Define the interacting style
    vtkInteractorStyleTrackballCamera *style =  vtkInteractorStyleTrackballCamera::New();
    iren->SetInteractorStyle(style);

    //Start to interact
    iren->Initialize();
    iren->Start();

 }

________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100713/912092ab/attachment.htm>


More information about the vtkusers mailing list