【问题标题】:Error during reading an image using skimage使用 skimage 读取图像时出错
【发布时间】:2020-03-23 08:53:11
【问题描述】:

我一直在尝试从特定路径读取一堆图像,我使用的代码是~

images = [os.path.join(folder_path, f) for f in os.listdir(folder_path) if 
os.path.isfile(os.path.join(folder_path, f))]

num_generated_files = 0
while num_generated_files <= num_files_desired:
# random image from the folder
image_path = random.choice(images)
# read image as an two dimensional array of pixels
image_to_transform = sk.io.imread(image_path)

当我尝试使用单个图像时,它工作正常,但是当我使用图像路径获取随机图像时,它正在显示

 File "C:\Users\subhr\Anaconda3\lib\site-packages\imageio\core\functions.py", line 182, in get_reader
 "Could not find a format to read the specified file " "in mode %r" % mode
  ValueError: Could not find a format to read the specified file in mode 'i'

任何想法我做错了什么,任何帮助将不胜感激。

【问题讨论】:

  • 在您粘贴的代码中,缩进是错误的(循环不起作用)。尽管如此,尝试打印文件名 - 您可能遇到过不是图像的文件,而是文本或 docx 文件。
  • 嘿@VBB 非常感谢您指出,文件夹内有一些网页。另外你为什么说循环不起作用?你能解释一下吗?
  • 尝试使用imagelist = glob("*.png") 或者imagelist.extend(glob("*.jpg"))
  • python 循环需要缩进 - 您在此处粘贴的代码没有任何缩进。

标签: python anaconda scikit-image data-augmentation


【解决方案1】:

此文件夹中有多少张图片,它们的格式是什么(png、jpg 等)?看起来其中一张图片的类型未知(例如,非图片文件?)。

【讨论】:

  • 你好@gtancev,共有132张图片,它有混合格式(Png、JPEG和JPG),但正如VBB指出的那样,有一些非图片文件
猜你喜欢
  • 2020-07-14
  • 2017-03-20
  • 1970-01-01
  • 2014-07-28
  • 1970-01-01
  • 2021-01-01
  • 1970-01-01
  • 2011-10-21
  • 1970-01-01
相关资源
最近更新 更多