简体   繁体   English

TypeError: 图片数据不能转换为float // 导入.png图片时

[英]TypeError: Image data cannot be converted to float // When importing .png images

I saved inverted binarized images after extracting lines from tables as png (did it with opencv).从表格中提取线条为 png 后,我保存了倒置的二值化图像(使用 opencv 完成)。 Now when I try to load them with opencv or matplotlib it will show NoneType or the error in the headline.现在,当我尝试使用 opencv 或 matplotlib 加载它们时,它将显示 NoneType 或标题中的错误。 I have checked many different posts with the same error.我检查了许多具有相同错误的不同帖子。 I guess it has something to do with the image data.我想这与图像数据有关。

import cv2
import matplotlib.pyplot as plt


imgs = cv2.imread('Users/marius/Desktop/PDF/imgvh/1.png')
cv2.imshow('Users/marius/Desktop/PDF/imgvh/1.png', imgs)

在此处输入图像描述

The error which occurs when using cv2:使用cv2时出现的错误:

cv2.error: OpenCV(4.2.0) /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

Using matplotlib in this way:以这种方式使用 matplotlib:

imgs = plt.imshow('Users/marius/Desktop/PDF/imgvh/1.png')
plt.show()

leads to the following error:导致以下错误:

TypeError: Image data of dtype <U49 cannot be converted to float

The OpenCV part doesn't work because you omitted the slash at the start of the path ahead of Users/marius... . OpenCV部分不起作用,因为您在Users/marius...前面的路径开头省略了斜杠。 It should be:它应该是:

imgs = cv2.imread('/Users/marius/Desktop/PDF/imgvh/1.png')

The matplotlib part doesn't work because it should be: matplotlib部分不起作用,因为它应该是:

imgs = cv2.imread('/Users/marius...')

plt.imshow(imgs)
plt.show()  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:图像数据无法转换为少量图像浮动 - TypeError: Image data cannot be converted to float for few images 类型错误:图像数据无法转换为浮点数 - TypeError: Image data cannot be converted to float TypeError:使用tf.io.decode_jpeg导入后,无法使用plt.imshow将图像数据转换为float - TypeError: Image data cannot be converted to float with plt.imshow after importing with tf.io.decode_jpeg 类型错误:无法将图像数据转换为浮点数 无法将图像数据转换为浮点数 - TypeError: Image data cannot be converted to float Image data cannot be converted to float matplotlib.image.imsave TypeError:无法将图像数据转换为float - matplotlib.image.imsave TypeError: Image data cannot be converted to float TypeError:dtype对象的图像数据无法转换为float。 当显示来自神经网络的图像时 - TypeError: Image data of dtype object cannot be converted to float . When showing image from neural net Python OpenCV 错误:“类型错误:图像数据无法转换为浮点数” - Python OpenCV Error: “TypeError: Image data cannot be converted to float” plt.imshow()给出TypeError(“图像数据无法转换为浮点数”) - plt.imshow() giving TypeError(“Image data cannot be converted to float”) TypeError:加载.npy文件时,图像数据无法转换为float - TypeError: Image data cannot be converted to float while loading .npy file TypeError: dtype object 的图像数据无法转换为浮点数修复 - TypeError: Image data of dtype object cannot be converted to float Fix
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM