使用 matlab 计算定义为点列表的多边形的属性

发布于 2024-09-07 20:01:43 字数 243 浏览 1 评论 0原文

MATLAB 是否有内置函数来查找一般属性,例如质心和中心点?定义为(非整数值)点列表的多边形的惯性矩?

Regionprops 对整数值点执行此任务,假设这些点代表图像中的像素索引。但我能找到的唯一处理非整数点列表的函数是polyarea和inpolygon。

我现在的拼凑是创建一个 bwconncomp 结构,其中所有点乘以某个大值(例如 10,000),然后将其输入到 Regionprops 中,但想知道是否有更优雅的解决方案。

Does MATLAB have a built-in function to find general properties like center of mass & moments of inertia for a polygon defined as a list of (non-integer valued) points?

regionprops performs this task for integer valued points, on the assumption that these represent indices of pixels in an image. But the only functions I can find that treat non integral point lists are polyarea and inpolygon.

My kludge for now is to create a bwconncomp structure with all the points multiplied by some large value (like 10,000), then feeding it in to regionprops, but wondered if there is a more elegant solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江心雾 2024-09-14 20:01:43

您应该查看 POLYGEOM 提交的内容://www.mathworks.com/matlabcentral/fileexchange/authors/2538" rel="nofollow noreferrer">HJ Sommer 在MathWorks 文件交换。看起来它具有您想要的所有属性测量值,以及描述代码中使用的公式的精美文档。

You should check out the submission POLYGEOM by H.J. Sommer on the MathWorks File Exchange. It looks like it has all the property measurements you want, and nice documentation describing the formulae used in the code.

晒暮凉 2024-09-14 20:01:43

我不知道 MATLAB 中是否有函数可以为您执行此操作。

但是, poly2mask 可能对您有用创建像素掩码以输入到regionprops中。我还建议,如果您决定走这条路,请仔细测试离散化对结果的影响程度,这样您就不会创建疯狂的大型数组(并浪费时间)而不会真正提高准确性。

I don't know of a function in MATLAB that would do this for you.

However, poly2mask might be of use for you to create the pixel masks to feed into regionprops. I also suggest that, should you decide to go this route, you carefully test how much the discretization affects the results, so that you don't create crazy large arrays (and waste time) for no real gain in accuracy.

巴黎盛开的樱花 2024-09-14 20:01:43

一种可能性是将计算外包给 Java 拓扑套件。我不知道“惯性矩”,但它至少有一个质心方法。

One possibility is to farm out the calculations to the Java Topology Suite. I don't know about "moments of inertia", but it does at least have a centroid method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文