简体   繁体   English

从整体图像中获取轮廓的像素坐标

[英]Getting Pixel coordinates of a contour from the overall image

So I would like to get the XY coordinates of the center of a contour on an image.所以我想获得图像上轮廓中心的 XY 坐标。 How would I go about this?我该怎么办?

I have the contours defined and the objects detected now how do I get the pixel XY of the center.我已经定义了轮廓并检测到了现在如何获得中心的像素 XY。

Get the normal vectors at the start and end of the contour and calculate their intersection.获取轮廓起点和终点的法向量并计算它们的交点。

^ is for a simple 3 point contour ie a circular arc. ^ 用于简单的 3 点轮廓,即圆弧。 If you have more points, "center" is a kinda ambiguous term, but if you averaged all points contributing to the contour it could give you a center of mass which may be what you are after.如果你有更多的点,“中心”是一个有点模棱两可的术语,但如果你平均所有对轮廓有贡献的点,它可以给你一个质心,这可能就是你所追求的。

You could also get bounding boxes or circle etc as described here您还可以获得边界框或圆圈等,如此处所述

You could also use the moments to get center of mass if you prefer as seen on the documentation :如果您喜欢文档中所见,您也可以使用矩来获得质心:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM