代码如下:
python
import cv2
import numpy as np
img = np.zeros((256, 256), np.uint8)
for i in range(0,16):
for j in range(0,16):
img[i*16:(i+1)*16][j*16:(j+1)*16]=i*16+j
cv2.imwrite('result.jpg', img)
效果如下: