import cv2
import random
img_none=cv2.imread('none.jpg')# 大图
print(img_none.shape)
#(4244, 3228, 3) = (height,width,channel)
# 子区域 宽182,高428
a=3228-182
b=4244-428
for i in range(40): # 取40个子区域
x=random.randint(0, b)
y=random.randint(0, a)
print('({},{})'.format(x,y))
res=img_none[x:x+428,y:y+182] #子区域
cv2.imwrite('./img_save/none/mush_none_'+str(i)+'.jpg',res)
09-22
2405
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)