Question about rasterio, imageio and opencv python


I have a question about using rasterio.plot.reshape_as_image() and rasterio.plot.reshape_as_raster() in python.

I noticed that reshape_as_image seems to put the shape in the correct order if I print with numpy.shape, however opencv throws an exception when trying to resize() as if the size is empty (which usually happens if the shape is out of order). (-215:Assertion failed) !dsize.empty() in function 'resize'

If instead I use rasterio.plot.reshape_as_raster(my_image).transpose() then opencv works normally and resizes properly without exception.

The shape seems to be correct with both if I print the shape, so not sure why opencv is complaining about it.

So far I've only tested this with code that is reading from float32 RGB TIFF files with imageio, which uses tifffile for the tiff handling, so it should be a normal numpy array. Was curious if anyone noticed this behavior and what might be causing the exception.

Basic Example:
img = imageio.imread(path)
img2 = rasterio.plot.reshape_as_image(img)
resized = cv2.resize(img2, (300,300), interpolation=cv2.INTER_LANCZOS4)

Join to automatically receive all group messages.