1. Image read

作者: JaedenKil | 来源:发表于2020-01-13 17:39 被阅读0次
import cv2 as cv2


img = cv2.imread('C:\\Users\\zzheng\\Pictures\\tiger.png')
cv2.imshow('sample image', img)
cv2.waitKey(0)  # waits until a key is pressed
cv2.destroyAllWindows()  # destroys the window showing image

cv2.imread(/complete/path/to/image,flag):

cv2.IMREAD_COLOR : Loads a color image. Any transparency of image will be neglected. It is the default flag.
cv2.IMREAD_GRAYSCALE : Loads image in grayscale mode
cv2.IMREAD_UNCHANGED : Loads image as such including alpha channel

Returns numpy array, containing the pixel values. For colored images, each pixel is represented as an array containing Red, Green and Blue channels.

Note that the default flag is cv2.IMREAD_COLOR. Hence even if read a png image with transparency, the transparency channel is neglected.

相关文章

网友评论

    本文标题:1. Image read

    本文链接:https://www.haomeiwen.com/subject/cqdnactx.html