我最開始使用以下代碼:
for iraw, ipro in zip(np.nditer(raw_image), np.nditer(pro_image)):
ipro= formatfloat(iraw)/65536.0
但行不通,數據根本沒有修改,後改用
for iraw, ipro in zip(np.nditer(raw_image), np.nditer(pro_image, op_flags=['writeonly'])):
ipro[...] = formatfloat(iraw)/65536.0
提取迭代器index可用以下代碼
it = np.nditer(a, flags=[’multi_index’])
while not it.finished:
... print "%d <%s>" % (it[0], it.multi_index),
... it.iternext()