python - 从所有轮廓中删除选定的轮廓?
问题描述
我有一个轮廓列表(contours_list),它是 np.shape(contours_list)= (5,519) 并且轮廓的大小(在轮廓列表中)是不同的,例如:索引 0 1 2 3 4 大小(8,1,2)( 16,1,2) (3,1,2) (199,1,2) (9,1,2)。
我图像中的物体是不同长度的细丝。例如,我想删除带有 :len(contours)>12 的轮廓(这是细丝中选定边界点的数量)这是我的代码:
df=pd.DataFrame(contours_list)
extract=np.array(())
selected_contours_list=[]
for i in range(5):
for j in range(519):
if len(df.loc[i][j])>=12:
extract=np.array(df.loc[i][j])
selected_contours_list.append(extract)
out_put: np.shape(selected_contours_list) : (1345,) 满足条件!但我认为有错!我不明白会发生什么?我的 5 个清单在哪里?我想要 np.shape(selected_contours_list)(5, output)
index: 0 1 2 和 size: (27, 1, 2) (28, 1, 2) (15, 1, 2) 分别。
解决方案
推荐阅读
- macos - 在 macOS 上使用 Conda 安装 TensorFlow 2.2
- json - 如何将内容丰富的富文本格式化为 RSS 提要的可读 html?
- java - 如何检查矩形是否适合另一个矩形?
- typescript - Jest 存根不会更改假存储库的状态
- javascript - Heroku Node.js 错误代码 H10“应用程序崩溃”
- typescript - 如何为整个目录中的打字稿模块文件创建接口?
- angular - Angular - 地理编码异步传递变量
- wordpress - Wordpress Sendgrid 电子邮件未发送
- excel - HANA SQL:将格式为日期的 Excel 字段导入数据集或将 Excel 日期值(例如 31.12.2019 的 43830)转换为日期
- swiftui - SwiftUI 如何在 VStack 中垂直居中视图