So I have a 3D-array:
>>> img_data.shape
(182, 218, 182)
My idea is to replace every value equals to 0 with 255. I tried:
new_img = np.zeros(img_range)
print(new_img.shape)
for i in range(img_range[0]):
for j in range(img_range[1]):
for k in range(img_range[2]):
print "%s %s %s" % (i, j, k )
if img_data[i][j][k] == 0:
new_img[i][j][k] = 2
else:
new_img[i][j][k] = img_data[i][j][k]
But this take forever, most likely because Python is dynamic and may be doing something in the backgrouns.
Any ideas on how to improve this? Thanks, Rodrigo