imread/imwrite
img_path = f"all_img/{img_name}.png"
img = cv2.imdecode(np.fromfile(img_path, dtype=np.uint8), 1)
name = f"data_ver2/{img_name}.png"
cv2.imencode('.png', img)[1].tofile(name)
这篇博客详细介绍了如何利用OpenCV库在Python中进行图片的读取和保存。通过`cv2.imdecode`函数从文件中读取图像数据,并使用`cv2.imencode`编码后写入新的文件,实现了图片的高效处理。
imread/imwrite
img_path = f"all_img/{img_name}.png"
img = cv2.imdecode(np.fromfile(img_path, dtype=np.uint8), 1)
name = f"data_ver2/{img_name}.png"
cv2.imencode('.png', img)[1].tofile(name)

被折叠的 条评论
为什么被折叠?