<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=ËÎÌå size=2>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I want to convert a java 3D
array(threeDarray) to a vtkImageData object(image).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I do it use java as below:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> vtkImageData
image = new vtkImageData();<BR>
image.SetDimensions(iWidth, iHeight,
iNumImg);<BR> image.SetOrigin(0.0, 0.0,
0.0);<BR>
image.SetSpacing(spacing[0],spacing[1],spacing[2]);<BR>
image.SetScalarType(5);</FONT></DIV>
<DIV><FONT size=2><BR><FONT face=Arial>
vtkShortArray array = new
vtkShortArray();<BR>
array.SetNumberOfComponents(1);<BR>
array.SetNumberOfTuples(iWidth*iNumImg*iHeight);<BR>
</FONT></FONT></DIV><FONT size=2>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> int index =
0;<BR> for(int iZ = 0; iY <
iNumImg; iZ++){</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>
for(int iY= 0; iY < iHeight; iY++){</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT
face=Arial>
for(int iX = 0; iX < iWidth; iX++){</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT
face=Arial>
array.SetValue(index++,threeDarray[iZ][iY][iX]);<BR>
}</FONT></DIV>
<DIV><FONT face=Arial> }</FONT></DIV>
<DIV><FONT face=Arial>}</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>
image.GetPointData().SetScalars(array);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>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!</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Best regards,</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Yixun Liu</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV></FONT></FONT></DIV></BODY></HTML>