1. 程式人生 > >macOS python3 opencv 讀取和寫入影象

macOS python3 opencv 讀取和寫入影象

python opencv 影象 讀取 寫入

1,讀取和寫入影象

#! /usr/local/bin/python3
# coding:utf-8
import cv2 
#讀取影象
img = cv2.imread("/Users/y50/captcha_png.png")
print (img.shape)
print (img.shape[0:2])
print (type(img.shape))
h,w = img.shape[0:2]
print ( "高,寬:", h , w)
#儲存影象
cv2.imwrite("/Users/y50/captcha_png.jpg"
, img)
(50, 192, 3)
(50, 192)
<class 'tuple'>
高,寬: 50 192

參考:

  1. Basic Operations on Images