保存的图像仅显示使用 cv2.rectangle 创建的矩形,而不显示创建矩形的整个图像

Saved image only shows rectangle created using cv2.rectangle and not the whole image on which rectangle was created

使用此代码时:

 start_point = (centerXList[i] +16,centerYList[i]-14)
 end_point = (centerXList[i]+50,centerYList[i]+24)
 color=(255,0,0)
 x1=cv2.rectangle(x1,start_point,end_point,color)
 imshow(x1)
 plt.show()

imshow 的结果是:

但是当保存图像时使用:

save_img("./Predicted Images/abc.jpeg", x1)

结果是:

https://drive.google.com/file/d/1A4q1buJJk9tBWfstQccgETHe8LDEOtxX/view?usp=sharing

我想保存和imshow显示的一样的图片。 怎么做?

提前致谢

你试过用这个保存照片吗:

cv2.imwrite('my_saved_image', img)

我的问题的解决方案是:

save_img("./Predicted Images/abc.jpeg", x1 * 255)