The example show how to store a 3D Image to a comma separated format.
def SavePointCloud(ImageName, Filename):
img=GetImageMatr(ImageName)
f=open(Filename,'w')
if img<>None:
if img.elemtype()=='XYZf' : fmt='%f,%f,%f\n' #3 element pr. point
elif img.elemtype()=='XYZWVf': fmt='%f,%f,%f,%f,%f\n' #5 element pr. point
if img.isvec() and img.elemtype()=='XYZWVf':
cnt=img.dim()[0]
for i in range(cnt):
f.write(fmt % img[i])
elif img.ismat() and img.elemtype()=='XYZWVf':
rows,cols = img.dim()
for r in range(rows):
offs=r*cols
for c in range(cols):
f.write(fmt % (img[offs+c]))
f.close()
f.close()
Example 1: Save 3D Point Cloud with 5 elements
SavePointCloud('3D','image.csv')
|