【发布时间】:2020-07-12 16:53:01
【问题描述】:
我正在尝试分析目录中的一组图像,但只有一个图像有效。所有图像的大小大致相同 (3MB),并且来自相同的原始图像。所有这些都可以在 GIMP 和照片中查看,但 cv2.imshow 仅适用于 slice_0_15.jpg
这里发生了什么?
使用 Python 3.8.3 版,OpenCV 4.2.0 版
for file in os.listdir("scanned_extrudate"): #go through all 18 slices in the directory
print("Analyzing file " + str(file))
image = cv2.imread(file)
if image is None:
print("Error: no image selected")
else:
rows,cols,_ = image.shape #dimensions of image (eg 200x300)
print("Image: " + str(rows) + " rows, " + str(cols) + " columns")
输出:
Analyzing file slice_0_0.jpg
Error: no image selected
Analyzing file slice_0_1.jpg
Error: no image selected
Analyzing file slice_0_10.jpg
Error: no image selected
Analyzing file slice_0_11.jpg
Error: no image selected
Analyzing file slice_0_12.jpg
Error: no image selected
Analyzing file slice_0_13.jpg
Error: no image selected
Analyzing file slice_0_14.jpg
Error: no image selected
Analyzing file slice_0_15.jpg
Image: 19935 rows, 928 columns
Analyzing file slice_0_16.jpg
Error: no image selected
Analyzing file slice_0_17.jpg
Error: no image selected
Analyzing file slice_0_2.jpg
Error: no image selected
Analyzing file slice_0_3.jpg
Error: no image selected
Analyzing file slice_0_4.jpg
Error: no image selected
Analyzing file slice_0_5.jpg
Error: no image selected
Analyzing file slice_0_6.jpg
Error: no image selected
Analyzing file slice_0_7.jpg
Error: no image selected
Analyzing file slice_0_8.jpg
Error: no image selected
Analyzing file slice_0_9.jpg
Error: no image selected
当我在终端中输入“文件 *”时,所有图像的结果都相同:(唯一的区别是尺寸)
slice_0_0.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 2400x2400, segment length 16, Exif Standard: [TIFF image data, little-endian, direntries=7, xresolution=98, yresolution=106, resolutionunit=2, software=GIMP 2.10.14, datetime=2020:07:10 13:34:33], progressive, precision 8, 1088x19935, frames 1
【问题讨论】:
-
图像是如何生成的?对
slice_0_15.jpg未完成的其余部分做了什么,反之亦然?你能重新生成图像吗?您的代码如何与随机 JPG 一起工作?