[vtkusers] Viewing 3d RGBA or 3d RGB itk image in vtk

Arunachalam Kana Kana.Arunachalam at fh-wels.at
Tue Sep 21 10:59:49 EDT 2010


Hi VTK Users,

I am trying to view a 3d itk RGBA image or RGB image. Below is the pipeline followed by problem.

itkImageFileReader ==> itkVTKImageExport ==>  vtkImageImport ==> vtkImageActor

    typedef itk::RGBAPixel< unsigned char > PixelType;
    typedef itk::Image< PixelType, 3 > ImageType;

    typedef itk::ImageFileReader< ImageType > ReaderType;

    ReaderType::Pointer reader  = ReaderType::New();
    reader->SetFileName( argv[1] );
    reader->Update();

      // Obtain center index of the image
    //
    ImageType::Pointer inputImage = reader->GetOutput();
    ImageType::SizeType  size  = inputImage->GetBufferedRegion().GetSize();
    ImageType::IndexType start = inputImage->GetBufferedRegion().GetIndex();

    typedef itk::VTKImageExport< ImageType > ExportFilterType;
    ExportFilterType::Pointer itkExporter = ExportFilterType::New();

    itkExporter->SetInput( reader->GetOutput() );

    // Create the vtkImageImport and connect it to the
    // itk::VTKImageExport instance.
    vtkImageImport* vtkImporter = vtkImageImport::New();
    ConnectPipelines(itkExporter, vtkImporter);

    //------------------------------------------------------------------------
    // VTK pipeline.
    //------------------------------------------------------------------------

    // Create a renderer, render window, and render window interactor to
    // display the results.
    vtkRenderer* renderer = vtkRenderer::New();
    vtkRenderWindow* renWin = vtkRenderWindow::New();
    vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();

      vtkLookupTable *lut = vtkLookupTable::New();
      lut->SetHueRange(0.66667,0.0);
      lut->SetSaturationRange(1, 1);
      lut->SetValueRange(1, 1);
      lut->SetAlphaRange(1, 1);
      lut->SetNumberOfColors(128);
      lut->Build();

      //set vtkimageviewer
      vtkImageViewer2* ImageViewer = vtkImageViewer2::New();
      ImageViewer->SetInput(vtkImporter->GetOutput() );
      ImageViewer->SetSize(500,500);
      ImageViewer->SetupInteractor(iren);
      ImageViewer->GetRenderer()->SetBackground(0.4392, 0.5020, 0.5647);
      ImageViewer->GetWindowLevel()->SetOutputFormatToRGBA();
      ImageViewer->GetWindowLevel()->SetLookupTable(lut);
      ImageViewer->SetSlice(slicenumber);
      ImageViewer->SetSliceOrientationToXY();

      ImageViewer->GetRenderer()->ResetCamera();
    ImageViewer->GetRenderWindow()->Render();
    ImageViewer->GetRenderWindow()->GetInteractor()->Start();

The result only red and blue colour which is not true. There should be green and other colour. What am i doing wrong ?

Any quick help is highly appreciated.

Thank you,
Regards,
Kana Arunachalam Kannappan
Research Associate
FH OÖ Forschungs & Entwicklungs GmbH
Stelzhamer Strasse 23,
4600 Wels,
Austria.
Phone: +43 (0)7242 72811 -4420
kana.arunachalam at fh-wels.at
www.fh-ooe.at; www.3dct.at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100921/6667bf58/attachment.htm>


More information about the vtkusers mailing list