I am getting an Error: ValueError: Buffer not C contiguous error in a script that i am running on an AWS instance with skimage 0.11.3 and numpy 1.11.0rc1
I have read e.g. scikit-image transform ValueError: Buffer not C contiguous and other similar questions – and tried to take steps (overlapping ones) to make the array C contigious. When the script runs, the prints show that the arrays are C contigious. However, at random and unpredictable moments, the script will encounter appearantly a non-continous array and crash with the C contigious error. Is there anyhting i can do to avoid this?
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))
Full error:
/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 = []