[vtkusers] Trying to read a set of jpg slices

Rodrigo Lovera lobo.theslayer at gmail.com
Tue Sep 25 00:37:07 EDT 2012


Hello everyone,

I've been reading and testing vtk examples in c++ in order to get into it,
but i'm getting stucked in some problem, how do correctly read a series of
jpg slices and use them for volume rendering. I've trying to read the
directory containing the data but it gives errors, it's like if it were
asking for a file like "something.1" instead of waiting for the jpg data
set. I've been reading some papers where they use the jpegreader for that
but can't get it to work. Any help or advice 'll ve much appreciate.

The errors i'm getting are the following

ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
5.10\VTK\IO\vtkJPEGReader.cxx, line 93
vtkJPEGReader (035651B0): Unable to open file
C://VTK5.10//DATA//MatlabTest//JPG//.1

ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
5.10\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326
vtkVolumeRayCastMapper (03574310): Cannot volume render data of type short,
only unsigned char or unsigned short.

ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
5.10\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326
vtkVolumeRayCastMapper (03574310): Cannot volume render data of type short,
only unsigned char or unsigned short.

ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
5.10\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326
vtkVolumeRayCastMapper (03574310): Cannot volume render data of type short,
only unsigned char or unsigned short.

and the code i'm trying to run is these:

int main()
{
vtkRenderer *aRender = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRender);
vtkRenderWindowInteractor *iRen = vtkRenderWindowInteractor::New();
iRen->SetRenderWindow(renWin);
 vtkJPEGReader *jpegReader = vtkJPEGReader::New();
jpegReader->SetDataByteOrderToLittleEndian();
// jpegReader->SetFilePattern("");
jpegReader->SetFilePrefix("C://VTK5.10//DATA//MatlabTest//JPG//");
jpegReader->SetDataExtent(0, 1280, 0, 1024, 1, 11);
jpegReader->SetDataSpacing(3.2, 3.2, 20);
jpegReader->SetDataOrigin(0, 0, 0);
 vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();
opacityTransferFunction->AddPoint(0, 0.0);
opacityTransferFunction->AddSegment(30, 0.0, 100, 0.9);
opacityTransferFunction->AddPoint(110, 2.0);
opacityTransferFunction->ClampingOn();
 vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetScalarOpacity(opacityTransferFunction);
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationTypeToLinear();
 vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
volumeMapper->SetVolumeRayCastFunction(compositeFunction);
volumeMapper->SetInput(jpegReader->GetOutput());

vtkVolume *volume = vtkVolume::New();
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);

vtkCamera *camera = vtkCamera::New();
camera->SetViewUp(0,0,1);
        camera->SetPosition(0,2,0);
camera->SetFocalPoint(0,0,0);
camera->Dolly(0.8);

  aRender->AddVolume(volume);
aRender->SetBackground(0.5, 0.5, 0.5);

renWin->SetSize(600, 600);
renWin->Render();

iRen->Initialize();
iRen->Start();


return 0;
}

Thx in advance.

-- 
*Rodrigo Lovera*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120924/a62b819f/attachment.htm>


More information about the vtkusers mailing list