img_为读入路径文件下的图片,之前有读入过

然后后处理: img_2 = img_
结果就报错 'arr' does not have a suitable array shape for any mode.

最后解决是通过把四通道变为三通道img_2 = img_[0]

 

 

以下部分来自 https://www.jianshu.com/p/bbf051149d74

'arr' does not have a suitable array shape for any mode.

 

以下部分来自博客 https://blog.csdn.net/yyhhlancelot/article/details/81477830 

首先默认import scipy as sp。

一般来说,是遇到了sp.misc出现了该类问题。

根据scipy官方文档,我们可以知道,参数中的arr

arr : ndarray, MxN or MxNx3 or MxNx4

Array containing image values. If the shape is MxN, the array represents a grey-level image. Shape MxNx3 stores the red, green and blue bands along the last dimension. An alpha layer may be included, specified as the last colour band of an MxNx4 array.

分别对应单一灰度通道,RGB三通道,RGB+alpha四通道。不过大部分人应该只会用到前两个(其实是因为博主尝试了sp.misc.imsave去保存四通道的图像失败了哈哈,不管这么多了)

所以说,如果你想保存的图像维度不符合以上三种(一般是前两种)默认方式的话,就会报这样的错!

 

 

相关文章:

  • 2022-12-23
  • 2021-12-24
  • 2021-04-13
  • 2021-10-07
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-29
  • 2021-10-15
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2022-01-27
相关资源
相似解决方案