[vtkusers] KitWare | Read mhd/mha files

Matias Montroull matimontg at gmail.com
Fri Feb 20 16:04:37 EST 2015


Hi,

I need to read mhd or mha (derived from Dicom slices) and to do so I've
written this code:

However... I'm getting the following error message and nothing is displayed

*ERROR: In
..\..\..\..\vtksource-prefix\src\vtksource\Rendering\vtkImageActor.cxx,
line 266*
*vtkOpenGLImageActor (000000001F574230): This filter requires unsigned char
scalars as input*

The intention I have is to display the mhd or mha file as a set of images
where the user can scroll through slices.

Ultimately I will convert the mha file into a series of slices and read the
directory with vtkDICOMImageReader rather than the MetaImageReader...

Thank you,

Matias.

    vtkMetaImageReader readerdicom1 = new vtkMetaImageReader();
            readerdicom1.SetFileName(@"C:\test\CT3D.mha");
            readerdicom1.Update();
            vtkMetaImageReader readerdicom2 = new vtkMetaImageReader();
            readerdicom2.SetFileName(@"C:test\RM3D.mha");
            readerdicom2.Update();
            vtkImageActor actor1 = vtkImageActor.New();
            actor1.SetInput(readerdicom1.GetOutput());
            vtkRenderer render = vtkRenderer.New();
            render.AddActor(actor1);
            render.ResetCamera();
            vtkRenderWindow renwin = vtkRenderWindow.New();
            renwin.AddRenderer(render);
            vtkRenderWindowInteractor interactor =
vtkRenderWindowInteractor.New();
            vtkInteractorStyleImage estilo = vtkInteractorStyleImage.New();
            interactor.SetInteractorStyle(estilo);

            interactor.SetRenderWindow(renwin);
            interactor.Initialize();

            renwin.Render();

            interactor.Start();

            renwin.Render();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150220/27896018/attachment.html>


More information about the vtkusers mailing list