网络编程
位置:首页>> 网络编程>> Python编程>> python+opencv 读取文件夹下的所有图像并批量保存ROI的方法

python+opencv 读取文件夹下的所有图像并批量保存ROI的方法

作者:zhangxu_bme  发布时间:2021-02-23 13:07:23 

标签:python,opencv,图像,ROI

如下所示:


import cv2
import os

import numpy as np

root_path = "I:/Images/2017_08_03/"
dir = root_path+"images"+"/"
count = 0
for root,dir,files in os.walk(dir):
for file in files:
 srcImg = cv2.imread(root_path+"images"+"/"+str(file))
 roiImg = srcImg[36:521, 180:745]
 cv2.imwrite(root_path+"Image"+"/"+str(file),roiImg)
 count +=1
 if count%400==0:
  print count

来源:https://blog.csdn.net/chengzhongxuyou/article/details/76823964

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com