pytorch 预处理图片--Resize
pytorch 预处理图片–Resize文章目录pytorch 预处理图片--Resizedef resizeImg():for x in range(1 ,100):# 读取图片img = cv2.imread("E:\\{}.png".format(str(x)))img = Image.fromarray(img)img = F.resize(img, (512,512))img=np.ar
·
pytorch 预处理图片–Resize
def resizeImg():
for x in range(1 ,100):
# 读取图片
img = cv2.imread("E:\\{}.png".format(str(x)))
img = Image.fromarray(img)
img = F.resize(img, (512,512))
img=np.array(img)
#img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imwrite("E:\\{}.png".format(str(x)), img)
plt.imshow(img ,cmap='gray')
plt.show()
resizeImg()
注意open-cv的读取图像格式为numpy,而pytorch中的resize方法需要Image格式,因此需要转换
更多推荐

所有评论(0)