11 KiB
11 KiB
In [3]:
import numpy as np
import matplotlib.pylab as plt
import pandas as pd
Nx=3
Ny=128
Nz=128
dx = 1.0/(Nz-1)
ID = np.ones(Nx*Ny*Nz,dtype='uint8')
ID.shape = (Nz,Ny,Nx)In [6]:
for idx in range(len(D)):
#print(idx)
cx=D['cx'][idx] / dx
cy=D['cy'][idx] /dx
r=D['r'][idx] /dx
for i in range(0,Nz):
for j in range(0,Ny):
if ( (cx-i)*(cx-i) + (cy-j)*(cy-j) < r*r ):
ID[i,j,0] = 0
ID[i,j,1] = 0
ID[i,j,2] = 0
ID.tofile("discs_3x128x128.raw")In [7]:
plt.figure(1)
plt.title('segmented image')
plt.pcolormesh(ID[:,:,1],cmap='hot')
plt.grid(True)
plt.axis('equal')
plt.show()In [ ]: