Matlab - 跟踪两个不同点之间的轮廓线
我有一组表示为 2 行 n 列矩阵的点。 这些点构成了连接的边界或边缘。我需要一个从起点 P1 追踪该轮廓并在终点 P2 停止的函数。它还需要能够沿顺时针或逆时针方向追踪轮廓。我想知道是否可以通过使用Matlab的一些函数来实现这一点。
我尝试编写自己的函数,但这充满了错误,我也尝试使用 bwtraceboundary 和索引,但这会产生有问题的结果,因为矩阵内的点不按创建轮廓的顺序。
预先感谢您的帮助。
顺便说一句,我已经添加了指向该组点图的链接。它是手的一半轮廓。
理想情况下,该函数将追踪从红色星星到绿色三角形的轮廓。按遍历顺序返回点。
编辑:这可能是解决我试图解决的一个更大问题的方法,但是否可以测试蓝色边界边缘上的点是否连接到红色星星或绿色三角形点之间的轮廓。
即,对于蓝色边界上的点,如果您要手动从左侧红色星号到绿色三角形追踪轮廓,如果该点位于两点之间的连接边界上,则函数将返回 true,否则返回 false。
I have a set of points represented as a 2 row by n column matrix.
These points make up a connected boundary or edge. I require a function that traces this contour from a start point P1 and stop at an end point P2. It also needs to be able trace the contour in a clockwise or anti-clockwise direction. I was wondering if this can be achieved by using some of Matlab's functions.
I have tried to write my own function but this was riddled with bugs and I have also tried using bwtraceboundary
and indexing however this has problematic results as the points within the matrix are not in the order that create the contour.
Thank you in advance for any help.
Btw, I have included a link to a plot of the set of points. It is half the outline of a hand.
The function would ideally trace the contour from ether the red star to the green triangle. Returning the points in order of traversal.
EDIT: This is perhaps a work around to a larger problem I am trying to solve but would it be possible to test if a point on the blue boundary edge is connected to the contour that is between either the red stars or green triangular points.
i.e. for a point on the blue boundary, if you were to trace the contour by hand from the left red asterixs to the green triangle the function would return true if the point is on the connected boundary between the two points and false otherwise.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这些点非常接近,您应该能够通过始终在列表中查找下一个最近的点来进行跟踪。
如果点相距较远,问题将无法解决 - 想象一下五个点,其中四个是角,一个在中心:追踪线的“正确”方法是什么?
If the points are so close together, you should be able to do the trace by always looking for the next closest point in the list.
If the point were farther apart, the problem would not be solvable - imagine the five points where four are corners and one is in the center: what is the 'correct' way of tracing the line?