裁剪图像中的区域

时间:2018-05-28 20:08:49

标签: python opencv

如何获取下图中2位数之间的区域。我正在使用opencvpython

输入图像

enter image description here

输出图像/区域

enter image description here

区域1

Region 1

区域2

Region 2

区域3

Region 3

1 个答案:

答案 0 :(得分:0)

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

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)