[vtkusers] need your help imperatively!
Yixun Liu
yxliu at fudan.edu.cn
Mon Apr 4 00:00:19 EDT 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);
vtkShortArray array = new vtkShortArray();
array.SetNumberOfComponents(1);
array.SetNumberOfTuples(iWidth*iNumImg*iHeight);
int index = 0;
for(int iZ = 0; iY < iNumImg; iZ++){
for(int iY= 0; iY < iHeight; iY++){
for(int iX = 0; iX < iWidth; iX++){
array.SetValue(index++,threeDarray[iZ][iY][iX]);
}
}
}
image.GetPointData().SetScalars(array);
However, it is very slow. To 256*256*256 slices it needs about 2 minutes to finish the loop.My computer has a high speed CPU and 1.2G memory. I need your help and any suggestion will be appreciated!
Best regards,
Yixun Liu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050404/5374d0b1/attachment.htm>
More information about the vtkusers
mailing list