[vtkusers] Problem opening raw images with vtkImageReader2

Rafael S. Medeiros devilmaycrytherockbaby at gmail.com
Wed Apr 29 07:58:34 EDT 2009


Hello,
I'm making a simple program which opens a raw image that has 10x10 pixels. I
want to scale it to 400x400.
I'm using vtkImageReader2 to read the image and vtkImageViewer2 to view, but
the only thing I get is a black screen. I've tested the viewer and it's
highely unlikely that the error is there.

Here's the source code:

     vtkImageReader2 *reader = vtkImageReader2::New();
     reader->SetFileName( argv[1] );
     reader->SetFileDimensionality(2);
     reader->SetDataExtent( 0, 9, 0, 9, 0, 0 );
     reader->SetDataScalarTypeToUnsignedShort( );
     reader->SetDataByteOrderToLittleEndian();
     reader->Update();

     vtkImageMagnify *mag = vtkImageMagnify::New();
    mag->SetInput(reader->GetOutput());
    mag->SetMagnificationFactors(40, 40, 1);
    mag->InterpolateOn();
    vtkRenderWindowInteractor *renderWindowInteractor =
vtkRenderWindowInteractor::New();

    vtkImageViewer2 *viewer = vtkImageViewer2::New();
    viewer->SetupInteractor( renderWindowInteractor );
    viewer->SetInput( mag->GetOutput() );
    viewer->SetColorWindow( 255 );
    viewer->SetColorLevel( 127 );
    viewer->SetSize(40,40);
    viewer->SetSlice(0);
    viewer->Render();
    renderWindowInteractor->Start();
    return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090429/a23f6e28/attachment.htm>


More information about the vtkusers mailing list