在最初的代碼中,
#read an image img = cv2.imread('image.jpg') #print the dimension of the image print img.shape
可能是因為沒有設置路徑,所以返回的類型是None。
改正的方法是,讀取圖片時把路徑也寫上
#Try changing the direction of the slashes im = cv2.imread("D:/testdata/some.tif",CV_LOAD_IMAGE_COLOR) #or add r to the begining of the string im = cv2.imread(r"D:\testdata\some.tif",CV_LOAD_IMAGE_COLOR)
