当前位置:网站首页>Opencv display image

Opencv display image

2022-06-23 05:41:00 andrew P

One . use opencv Read the picture , use matplotlib.pyplot Show

1.opencv The read image channel is ,BGR, If you use matplotlib Show , It's about to turn into RGB

import matplotlib.pyplot as plt
import cv2


def CVshow_RGB(path):
    img = cv2.imread(path)
    img = img[:, :, [2, 1, 0]]#BGR to RGB
    plt.title("RGB")
    plt.imshow(img)
    plt.show()

2. If there is batch , You need to compress the batch dimension

def CVshow_pixes(title,img_pixes):
    if len(img_pixes.shape)!=3 :
        img_pixes=np.squeeze(img_pixes,axis=0)
    cv2.imshow(title,img_pixes)
    cv2.waitKey()
    cv2.destroyAllWindows()

Two . use opencv Read the picture , use opencv Show

原网站

版权声明
本文为[andrew P]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230351349958.html