Python 裁剪图像中的区域

Python 裁剪图像中的区域,python,opencv,Python,Opencv,如何获得下图中两位数字之间的区域。我正在使用opencv和python 输入图像 输出图像/区域 区域1 区域2 区域3 如果您已经知道裁剪框的确切尺寸,那么这很容易 box_count = 3 box_w = 50 box_h = 50 regions = [] for r in range(1,box_count+1): regions.append(img[(r-1)*box_h:r*box_h, 0:box_w]) #img is the image for regi

如何获得下图中两位数字之间的区域。我正在使用
opencv
python

输入图像

输出图像/区域

区域1

区域2

区域3

如果您已经知道裁剪框的确切尺寸,那么这很容易

box_count = 3
box_w = 50
box_h = 50
regions = []

for r in range(1,box_count+1):
    regions.append(img[(r-1)*box_h:r*box_h, 0:box_w]) #img is the image

for region in regions:
    cv2.imshow("r", region)
    cv2.waitKey(1000)

箱子的高度可能会有所不同。