嗨!是否可以在Python中将图像的(宽度,高度,通道)尺寸更改为(通道,高度,宽度)?
例如:224 x 224 x 3 -> 3 x 224 x 224
嗨!是否有解决方案,可以在Python中将图像的(宽度,高度,通道)尺寸更改为(通道,高度,宽度)?例如:224 x 224 x 3-> 3 x 224 x 224
您可以使用np.transpose
https://numpy.org/doc/1.18/reference/generated/numpy.transpose.html:
假设图像表示为nd.array
,则可以使用如下所示的moveaxis
方法: