基本用法

# load a color image
img = cv2.imread('messi5.jpg')

# access a pixel value by its row and column coordinate
px = img[100,100]

# modify the pixel values the same way
img[100,100] = [255,255,255]

# Shape of image is accessed by img.shape
img.shape

# Total number of pixels is accessed by img.size
img.size

# Image datatype is obtained by img.dtype
img.dtype

# show the img
img.show()

# 复制原有的图片
emptyImage2 = img.copy()

图像处理

# 转换成灰度图
im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)

# 固定阈值二值化
ret, dst = cv2.threshold(src, thresh, maxval, type)

# 轮廓检测
cv2.findContours()

# 直方图对比度增强算法
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))