我收到一个错误:ValueError:我正在使用skimage 0.11.3和numpy 1.11.0rc1
的AWS实例上运行的脚本中的缓冲区不是C连续错误我已阅读过例如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 = []
答案 0 :(得分:0)
我遇到了同样的问题。结果问题是剪辑范围部分位于图像之外。您可以检查是否正确剪裁图像。