01.图像加载与保存
1.什么是图像
- 结构化存储的数据信息
- 一图胜十言,无图无真相
- 图像属性
- 通道数目
- 高与宽
- 像素数据
- 图像类型
import cv2 as cv
import numpy as np
def video_demo()://加载视频
capture = cv.VideoCapture(0)
while(True):
ret,frame = capture.read()
frame = cv.flip(frame,1)//镜像变换
cv.imshow("video",frame)
c = cv.waitKey(50)
if c == 27:
break
def get_image_info(image)://加载图片
print(type(image))
print(image.shape)
print(image.size)//等于shape三个数值相乘
print(image.dtype)//每个像素点有三个通道,每个通道所占的位数为uint8
pixel_data = np.array(image)
print(pixel_data)
print("--------------Hello Python----------------")
src = cv.imread("F:/tool/PyCharm/pic/test1.jpeg")
cv.namedWindow("input image",cv.WINDOW_AUOTOSIZE)
cv.imshow("input image",src)
get_image_info(src)
video_demo
gray = cv.cvtColor(src,cv.COLOR_BGR2GRAY)//灰度图
cv.imwrite("F:/tool/PyCharm/pic/test1.jpeg",gray)//保存图片
cv.waitKey(0)
cv.destoryAllWindows()