# -*- coding: utf-8 -*-
"""
Created on Wed Sep 1 14:53:32 2021
@author: Administrator
"""
from glob import glob
import cv2
import os
file = glob(r'C:/Users/Administrator/Desktop/datasets/imgs/*.tif')
label_path = 'C:/Users/Administrator/Desktop/datasets/labels/'
i = 0
for name_path in file:
img_name = str(name_path).split('\\')[-1]
#print(img_name)
img = cv2.imread(name_path)
binaryImg = cv2.Canny(img,50,200)
contours, hierarchy = cv2.findContours(binaryImg,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
#print(len(contours))
if len(contours)==0:
print(img_name)
os.remove(name_path)
os.remove(label_path + img_name)
i = i + 1
print(i)
#cv2.imshow("img", binaryImg)
cv2.waitKey(1)
遥感领域划窗裁剪数据空白数据剔除,语义分割
最新推荐文章于 2024-11-14 17:10:58 发布