PIL:Image 和 cv2简单比较

简单比较PIL的Image 和CV2

 

from PIl impot Image  

import cv2

①打开:

img1 = Image.open("1.jpg")  注意:img= img.convert('RGB')

img2 =cv2.imread("1.jpg")

 

②长宽:

w, h = img1.size

w, h = img2.shape

 

③Resize:

ReSImg1 = img1.resize((224,224))

ReSImg2 =cv2.resize(img2,(h,w))

 

④保存:

img1.save(path)

cv2.imwrite(path,img)

注: cv2读取image的通道顺序是BGR

         PIL读取image的通道顺序是RGB

 

本文转自:

https://blog.csdn.net/summermaoz/article/details/56885981

 

你可能感兴趣的:(python,opencv,PIL)