[vtkusers] Access imagedata

cc cc cctsinghua at gmail.com
Fri Feb 10 14:41:06 EST 2012


Hello David,

Thanks for your help!
I've found the problem.
vtkVolume16Reader reads in 16 bit unsignedshort int. It can't be convert
into double!
When I tried imageData->SetScalarTypeToDouble(); Things went wrong.
But imageData->SetScalarTypeToUnsignedShort(); works fine.
Thanks.

Cheng

2012/2/11 David Doria <daviddoria at gmail.com>

> On Fri, Feb 10, 2012 at 1:03 PM, cc cc <cctsinghua at gmail.com> wrote:
>
>> Hello,
>>
>> I want to get value of each point. The data is from vtkVolume16Reader,
>> the typical header frequently seen in vtk, used in vtkMarchingCubes. Below
>> is vtkVolume16Reader from sample code.
>>     vtkVolume16Reader *v16 = vtkVolume16Reader::New();
>>     v16->SetDataDimensions(64,64);
>>     v16->GetOutput()->SetOrigin(0.0,0.0,0.0);
>>     v16->SetDataByteOrderToLittleEndian();
>>     v16->SetFilePrefix("/.../VTK/VTKData/Data/headsq/quarter");
>>     v16->SetImageRange(1,93);
>>     v16->SetDataSpacing(3.2,3.2,1.5);
>>     v16->Update();
>> But how can I get value on each vertex? Please help. Best wishes.
>>
>> Cheng
>>
>
> You should get the output of the filter as a vtkImageData:
>
> vtkImageData* image = v16->GetOutput();
>
> Then you can access the data like this:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/IterateImageData
>
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120211/0c17674d/attachment.htm>


More information about the vtkusers mailing list