常用代码段

jupyter

import numpy as np
import cv2
import matplotlib.pyplot as plt
%matplotlib inline

def imshow(img):
    if len(img.shape) == 3:
        b,g,r = cv2.split(img)
        plt.subplot(111);
        plt.imshow(cv2.merge([r, g, b]))
    elif len(img.shape) == 2:
        plt.subplot(111);
        plt.imshow(img, cmap='gray')
    else:
        print("Unknown input shape")

你可能感兴趣的:(python)