【发布时间】:2016-06-07 05:05:59
【问题描述】:
我收到一个错误:ValueError: Buffer not C contiguous error in a script 我在 skimage 0.11.3 和 numpy 1.11.0rc1 的 AWS 实例上运行
我读过例如scikit-image transform ValueError: Buffer not C contiguous 和其他类似问题 - 并尝试采取步骤(重叠的步骤)使数组 C 连续。当脚本运行时,打印显示数组是 C 连续的。但是,在随机且不可预知的时刻,脚本会遇到明显的非连续数组并因 C 连续错误而崩溃。我能做些什么来避免这种情况吗?
f = dicom.read_file(path)
img = f.pixel_array.astype(float) / np.max(f.pixel_array) #######
img = np.ascontiguousarray(img)
img = img.copy(order='C')
print(img.flags)
img = resize(np.ascontiguousarray(img[c_x-dx:c_x+dx, c_y-dy:c_y+dy]),(OUTPUT_IMG_SIZE, OUTPUT_IMG_SIZE))
完全错误:
/home/ubuntu/pp_mm2.py in write_data_csv(fname, frames)
166 img = img.copy(order='C')
167 print(img.flags)
--> 168 img = resize(np.ascontiguousarray(img[c_x-dx:c_x+dx, c_y-dy:c_y+dy]),np.ascontiguousarray((OUTPUT_IMG_SIZE, OUTPUT_IMG_SIZE)))
169 img /= np.max(img)
170 img *= 255
/usr/local/lib/python2.7/dist-packages/skimage/transform/_warps.pyc in resize(image, output_shape, order, mode, cval, clip, preserve_range)
105 out = warp(image, tform, output_shape=output_shape, order=order,
106 mode=mode, cval=cval, clip=clip,
--> 107 preserve_range=preserve_range)
108
109 return out
/usr/local/lib/python2.7/dist-packages/skimage/transform/_geometric.pyc in warp(image, inverse_map, map_args, output_shape, order, mode, cval, clip, preserve_range)
1343 warped = _warp_fast(image, matrix,
1344 output_shape=output_shape,
-> 1345 order=order, mode=mode, cval=cval)
1346 elif image.ndim == 3:
1347 dims = []
【问题讨论】:
标签: python arrays numpy scikit-image