[vtkusers] Re: problems with craeting a volume from png files

Goodwin Lawlor goodwin.lawlor at ucd.ie
Mon Jul 4 11:10:50 EDT 2005


Hi Norman,

Try:

pngreader.SetFilePattern("%s%d.png");
pngreader.SetDataExtent(0,255,0,255,1,57);
pngreader.SetFileNameSliceOffset(200);

instead of what you have now...

You could try to add a vtkImageViewer with pngreader as the input just to 
make sure your data is being read in correctly. If you do, remember to:

viewer.SetColorLevel 127.5
viewer.SetColorWindow 255

if your images are 8bit grayscale.

hth


Goodwin




"Norman Rzezovski" <norrze at web.de> wrote in message 
news:002201c580a4$2bc7e680$0101a8c0 at rechi...
Hi everyone

I have a couple of png files (test201.png - test257.png) that are slices
from a vein system, the veins being white, the surroundings black. I want to
build a volume from these slices, using the following code (put together
from various examples):

vtkRenderer ren1 = new vtkRenderer();
vtkRenderWindow renWin = new vtkRenderWindow();
renWin.AddRenderer(ren1);
vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
iren.SetRenderWindow(renWin);

vtkPNGReader pngreader = new vtkPNGReader();
pngreader.SetFilePrefix("data/png/test2");
pngreader.SetFilePattern("%s%.2d.png");
pngreader.SetDataExtent(1,256,1,256,0,57);
pngreader.SetFileNameSliceOffset(1);
pngreader.SetDataSpacing(1,1,1);
pngreader.SetDataByteOrderToLittleEndian();
pngreader.UpdateWholeExtent();

vtkPiecewiseFunction opacityTransferFunction = new vtkPiecewiseFunction();
opacityTransferFunction.AddPoint(0, 0.0);
opacityTransferFunction.AddPoint(10, 0.259);
opacityTransferFunction.AddPoint(50, 1.0);

vtkColorTransferFunction colorTransferFunction = new
vtkColorTransferFunction();
colorTransferFunction.AddRGBPoint(0.0, 0.0, 0.0, 0.0);
colorTransferFunction.AddRGBPoint(10.0, 0.259, 0.259, 0.3);
colorTransferFunction.AddRGBPoint(255.0, 1.0, 1.0, 0.3);

vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
volumeProperty.SetColor(colorTransferFunction);
volumeProperty.SetScalarOpacity(opacityTransferFunction);
volumeProperty.SetInterpolationTypeToLinear();
volumeProperty.ShadeOff();

vtkVolumeRayCastCompositeFunction compositeFunction = new
vtkVolumeRayCastCompositeFunction();
vtkVolumeRayCastMapper volumeMapper = new vtkVolumeRayCastMapper();
volumeMapper.SetVolumeRayCastFunction(compositeFunction);
volumeMapper.SetInput(pngreader.GetOutput());

vtkVolume volume = new vtkVolume();
volume.SetMapper(volumeMapper);
volume.SetProperty(volumeProperty);
ren1.AddVolume(volume);
ren1.SetBackground(0.1, 0.2, 0.4);
renWin.Render();
iren.Initialize();

All I get from this is a blue window with a few yellow dots. The window
immediately vanishes after half a second.
What am I doing wrong?

Thanks in advance




_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: 
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers 






More information about the vtkusers mailing list