[vtkusers] Copy from vtkImageData to array

Francois Bertel francois.bertel at kitware.com
Thu Nov 19 10:34:31 EST 2009


Hello,

On Thu, Nov 19, 2009 at 10:21 AM, Michael Xanadu
<xanadu.michael at googlemail.com> wrote:
> Hi,
>
> I have got a vtkImageData filled with 3-dimensional CT data. Now I'm doing
> this:
>
> vtkUnsignedCharArray *arr =
> vtkUnsignedCharArray::SafeDownCast(image->GetPointData()->GetScalars());
>
> This copies the 3-dimensional image data into a 1-dimensional array.

No there is no copy involved here. You just downcasted a vtkDataArray
pointer to a vtkUnsignedCharArray pointer.
vtkDataArrays are one-dimensional arrays.

> But of
> course, now I don't know which index of the array I should address if I want
> to get an element with former coordinates (x,y,z). In other words, what
> principle was used to copy the data from the vtkImageData to the array?

Look at static vtkIdType vtkStructuredData::ComputePointId (int
dim[3], int ijk[3])

http://www.vtk.org/doc/nightly/html/classvtkStructuredData.html

>
>
> Regards, Michael
>
> _______________________________________________
> 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
>
>



-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA



More information about the vtkusers mailing list