python - Identify groups of numbers in an array (group pixels of an image)
问题描述
this question is related to another question i asked before here. now i have an array of contains 0s,1s,-1s. consider it as an image where background is 0s. i has groups of 1s and -1s. This it that array opened in excel. those highlighted groups are 1s( in some cases can be -1s). there can be 4 groups in one array maximum. i want to separate those groups in to left, right, top, bottom with its value and the original index. referring to the previous question, i am trying to find the points on the humps and hollows in the puzzle pieces. if i can group them separately then i know how to find the index of the point i want. i tried to separate like this. but this doesn't apply for all the pieces. some times it can cut through hollows. thanks in advance for any help!!!
解决方案
Since your data is 2d array. Have you tried using an approach like region growing to segment the data?
https://en.wikipedia.org/wiki/Region_growing
Basically, you need to start with a seed point and grow the region by considering neighbouring points and whether or not they fit the criteria for your region.
推荐阅读
- python - “清洁代码”的函数参数编号指南是否适用于 API 设计?
- python - 列表之间的关系(Python)
- swift - 如何在 BodyEntity 中以编程方式访问剔除模式和双面?
- javascript - 如何生成这个 JSON 对象?
- discord - 检查具有特定角色的用户是否对最新的机器人消息作出反应 | 不和谐.js
- gstreamer - Gstreamer 在编码 ts 段时保留时间戳
- php - 下载计数仅更新并显示第一行
- maven - 安装 maven 依赖项解析为 pom 到自己的存储库
- unit-testing - 如何在 python3 中模拟自定义异常?
- python - 逐个元素地迭代查询字符串上的列表