1.导入相关的包
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt#画出效果图
2.读入图片
img = cv.imread(BASIC_PATH+"/test.jpg")
#imread(路径,读取类型)类型有IMREAD_GRAYSCALE(灰度),IMREAD_COLOR(彩色)
#默认是按原图像读入
<!--读入的图片是一个三维列表格式img[B[], G[], R[]]-->
3.显示图片窗口
def show_image(name, image):
cv.imshow(name, image)
<!--#cv.imshow(窗口名, 图片文件)-->
cv.waitKey(param)#param窗口显示的秒数(毫秒级1秒=1000毫秒),为0时任意按键可以终止
<!--# cv.destroyWindow(name)name表示需要销毁的窗口名-->
cv.destroyAllWindows()
4.一些基础操作
img[100, 100] = [255, 255, 255]
blue = img[100, 100, 0] #只显示该位置蓝色的像素值,通道按照BGR序
# print(blue)
print(img.shape) # 图像的shape元组返回(高h,宽w,通道数)
print(img.size) # 图像的size元组返回图像占有的像素点
print(img.dtype)