图上画矩形框并切割相应区域-python
import cv2
name = 'C:/Users/Desktop/data/drive/2_M3_x4.bmp'
img = cv2.imread(name)
img1 = img[100:201, 300:401]
cv2.rectangle(img, (300,100), (400,200), (0,255,0), 1)
cv2.imwrite('C:/Users/Desktop/data/drive/2draw_M3_x4.bmp', img)
cv2.imwrite('C:/Users/Desktop/data/drive/2cut_M3_x4.bmp', img1)