python opencv 處理文件、攝像頭、圖形化界面

轉換成RGBpython

import cv2
import numpy as ny
img = ny.zeros( ( 3 , 3 ),ny.float32)
img=cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
print(img)

 

將jpg裝成pngspa

import cv2
image=cv2.imread('C:/Users/Albert/PycharmProjects/CVTest/image/1.jpg')
cv2.imwrite('C:/Users/Albert/PycharmProjects/CVTest/image/1.png',image)

 

讀入灰度圖像code

import cv2
image=cv2.imread('C:/Users/Albert/PycharmProjects/CVTest/image/1.jpg',cv2.IMREAD_GRAYSCALE)
cv2.imwrite('C:/Users/Albert/PycharmProjects/CVTest/image/11.png',image)

 

圖像的相對路徑是指python腳本所在的文件夾blog

 

B、G、Rit

將圖像的綠色通道設置爲0class

import cv2 image=cv2.imread('C:/Users/Albert/PycharmProjects/CVTest/image/1.jpg') image[:,:,1]=0 cv2.imshow('a',image) cv2.waitKey(0)

 

 

圖像基本屬性import

import cv2 image=cv2.imread('C:/Users/Albert/PycharmProjects/CVTest/image/1.jpg') print(image.shape) print(image.size) print(image.dtype)
相關文章
相關標籤/搜索