opencv读取图片的默认像素排列是BGR,和很多其他软件不一致,需要转换。
opencv rgb转bgr 或 bgr转rgb
rgb = (cv_img * 255).astype(np.uint8)
bgr = cv2.cvtColor(rgb, cv2.COLOR_RGB2BGR)
#cv2.COLOR_RGB2BGR rgb转bgr
#cv2.COLOR_BGR2RGB bgr转rgb
cv2.imwrite(sub_path + '/' + str(step) + '.jpg', bgr)
OpenCV image to Matplotlib
rgb = bgr[...,::-1]
Matplotlib image to OpenCV
bgr = rgb[...,::-1]
gbr = rgb[...,[2,0,1]]