[vtkusers] Trying to read a set of jpg slices

Rodrigo Lovera lobo.theslayer at gmail.com
Tue Sep 25 09:16:53 EDT 2012


Each slice is a single file, all of 'em in a sequence but got them like
image1, image2.... image79... so u mean I need to save 'm like image.1
image.2... and so??


2012/9/25 Bill Lorensen <bill.lorensen at gmail.com>

> 1) Are all slices in one file?
>     If so, SetFileDimensionality=3
>     SetFileName to the name of the single file. DO NOT use //, instead use
> /
> 2) Is each slice in it's own file? c:/A/B/foo.1 c:/A/B/foo.2 ...
>    SetFilePrefix to c:/A/B/foo.
>
>
> On Tue, Sep 25, 2012 at 12:37 AM, Rodrigo Lovera <lobo.theslayer at gmail.com
> > wrote:
>
>> 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*
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
>


-- 
*Rodrigo aka WarHearT*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120925/3de1e2d0/attachment.htm>


More information about the vtkusers mailing list