当前位置:主页 > 软件编程 > Python代码 >

python用opencv批量截取图像指定区域的方法

时间:2021-03-24 10:28:56 | 栏目:Python代码 | 点击:

代码如下

import os
import cv2
for i in range(1,201):
  if i==169 or i==189:
    i = i+1
  pth = "C:\\Users\\Desktop\\asd\\"+str(i)+".bmp"
  image = cv2.imread(pth)      //从指定路径读取图像
  cropImg = image[600:1200,750:1500] //获取感兴趣区域
  cv2.imwrite("C:\\Users\\Desktop\\qwe\\"+str(i)+".bmp",cropImg) //保存到指定目录
  # print pth
#cropImg = image[100:200, 100:200]
#cv2.imwrite("a.bmp",cropImg)

您可能感兴趣的文章:

相关文章