[vtkusers] vtkImageReader problem

Kévin REDON kevredon at gmail.com
Thu Apr 20 11:10:42 EDT 2006


I try to construct a 3D Volume with slices, with Java.

First I copied the Medical1 Example (VTK example), which uses
vtkVolume16Reader, but I use 1bit bmp image, and it doesn't read them (only
16bit pnm raw).

Then I tried vtkVolumeReader, but I can't specify that it's a littleEndian
(the MaskData doesn't exists)

So I used vtkImageReader, but it always crashes java and it neverd ends
readind HDD, also for just 1 picture.

Finally I use vtkImageReader2, but he says :

Warning: In /home/kevredon/stage/vtk/VTK/IO/vtkImageReader2.cxx, line 605
vtkImageReader2 (0x808f1a8): File operation failed.

Generic Warning: In /home/kevredon/stage/vtk/VTK/IO/vtkImageReader2.cxx,
line 675
File operation failed. row = 16, Read = 512, FilePos = -1

and construct the 3D volume juste partially.

What can I do now (or how specify that it's 1bit bmp) :
kevredon at gmail.com

source :

//Create the buttons.
            vtkPanel renWin = new vtkPanel();

            //image reader
            vtkImageReader2 reader = new vtkImageReader2();
            reader.SetNumberOfScalarComponents(1);
            reader.SetDataByteOrderToLittleEndian();
            reader.SetDataOrigin(0, 0, 0);
            reader.SetDataExtent(0,size[0]-1,0,size[1]-1,0,slices.length-1);
            reader.SetFilePrefix(FOLDER_NAME+File.separator+PREFIX);
            reader.SetDataSpacing(spacing);

            // An isosurface
            vtkContourFilter skinExtractor = new vtkContourFilter();
            skinExtractor.SetInput(reader.GetOutput());
            skinExtractor.SetValue(0,5);
            vtkPolyDataNormals skinNormals = new vtkPolyDataNormals();
            skinNormals.SetInput(skinExtractor.GetOutput());
            skinNormals.SetFeatureAngle(60.0);
            vtkPolyDataMapper skinMapper = new vtkPolyDataMapper();
            skinMapper.SetInput(skinNormals.GetOutput());
            skinMapper.ScalarVisibilityOff();
            vtkActor skin = new vtkActor();
            skin.SetMapper(skinMapper);

            // An outline provides context around the data.
            vtkOutlineFilter outlineData = new vtkOutlineFilter();
            outlineData.SetInput(reader.GetOutput());
            vtkPolyDataMapper mapOutline = new vtkPolyDataMapper();
            mapOutline.SetInput(outlineData.GetOutput());
            vtkActor outline = new vtkActor();
            outline.SetMapper(mapOutline);
            outline.GetProperty().SetColor(0, 0, 0);

            // It is convenient to create an initial view of the data.
            vtkCamera aCamera = new vtkCamera();
            aCamera.SetViewUp(0, 0, -1);
            aCamera.SetPosition(0, 1, 0);
            aCamera.SetFocalPoint(0, 0, 0);
            aCamera.ComputeViewPlaneNormal();

            // Actors are added to the renderer. An initial camera view is
created.
            // The Dolly() method moves the camera towards the FocalPoint,
            // thereby enlarging the image.
            renWin.GetRenderer().AddActor(outline);
            renWin.GetRenderer().AddActor(skin);
            renWin.GetRenderer().SetActiveCamera(aCamera);
            renWin.GetRenderer().ResetCamera();
            aCamera.Dolly(1.5);

            // Set a background color for the renderer and set the size of
the
            // render window (expressed in pixels).
            renWin.GetRenderer().SetBackground(1, 1, 1);
            VtkPanelUtil.setSize(renWin, 320, 240);

            // Note that when camera movement occurs (as it does in the
Dolly()
            // method), the clipping planes often need adjusting. Clipping
planes
            // consist of two planes: near and far along the view direction.
The
            // near plane clips out objects in front of the plane the far
plane
            // clips out objects behind the plane. This way only what is
drawn
            // between the planes is actually rendered.
            renWin.GetRenderer().ResetCameraClippingRange();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060420/aaae2dd5/attachment.htm>


More information about the vtkusers mailing list