[vtkusers] about converting java array to vtkImageData

David Cole david.cole at kitware.com
Thu Mar 31 09:37:22 EST 2005


InsertNextTuple1 adds another new tuple, but you don't need that. You've
already pre-allocated all the tuples you'll need by calling
AllocateScalars. Call SetTuple1 instead of InsertNextTuple1 and you
should see a dramatic speed up...

HTH,
David


Yixun Liu wrote:

> Hi,
> I want toconverta java 3D array(threeDarray) toa vtkImageData
> object(image).
> I do it use java as below:
> vtkImageData image = new vtkImageData();
> image.SetDimensions(iWidth, iHeight, iNumImg);
> image.SetOrigin(0.0, 0.0, 0.0);
> image.SetSpacing(spacing[0],spacing[1],spacing[2]);
> image.SetScalarType(5);
> image.AllocateScalars();
> vtkDataArray array = image.GetPointData().GetScalars();
>
> for(int iZ = 0; iY < iNumImg; iZ++){
> for(int iY= 0; iY < iHeight; iY++){
> for(int iX = 0; iX < iWidth; iX++){
> array.InsertNextTuple1(threeDarray[iZ][iY][iX]);
> }
> }
> }
> However, it is very slow due to the insertNextTuple(). Anybody tell me
> a queikly method?
> Best regards,
> Yixun Liu
>
>------------------------------------------------------------------------
>
>_______________________________________________
>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
>  
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050331/0d301142/attachment.htm>


More information about the vtkusers mailing list