[vtkusers] about converting java array to vtkImageData
Yixun Liu
yxliu at fudan.edu.cn
Thu Mar 31 03:47:49 EST 2005
Hi,
I want to convert a java 3D array(threeDarray) to a 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050331/d328c608/attachment.htm>
More information about the vtkusers
mailing list