获取坐标边界框,忽略边缘位置

发布于 2024-10-15 11:52:52 字数 118 浏览 1 评论 0原文

我正在尝试围绕一组坐标创建一个边界框,但我想“关注”坐标组并忽略任何偏离并会弄乱地图的坐标。 (想象一张地图,其中一个城市有 10 个地点,另一个国家有 1 个地点)

构建左上角和右下角值的最佳方法是什么?

I'm trying to create a bounding box around a set of coordinates, but I want to 'focus' on groups of coordinates and ignore any that are way off and would mess up the map. (Imagine a map of 10 spots on a city and 1 somewhere in another country)

What would be the best way to build the top-left and bottom-right values?

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

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

发布评论

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

评论(3

在风中等你 2024-10-22 11:52:52

首先,我将确定“边缘位置”的标准,

例如“2 σ 之外”,然后您只需计算两个维度的平均值并在 2 σ 处绘制线条。如果您想要一些弯曲的边界,那么事情会变得更加复杂......从您的标准开始,然后从那里继续前进。

因此,假设您想从平均值中排除超过 2σ 的事物,

您需要计算:

σ(x)、σ(y)、mean(x)、mean(y)

那么您的左上界是 (mean(x)- 2σ(x) ,mean(y)+2σ(y) )

和你的右下界是 (mean(x)+2σ(x) ,mean(y)-2σ(y) )

这将产生一个 2σ 的矩形两个维度。对于一个圆,事情会变得有点复杂......从定义你的“可接受区域”开始

First I would determine your criteria for "fringe locations"

Something like "outside 2 σ" then you just need to calculate your mean in both dimensions and draw your lines at 2σ. If you want some curvy boundary then things get much more complicated... Start at your criteria and move forward from there.

So let's assume you wanted to exclude things more than 2σ from the mean

You need to calculate:

σ(x), σ(y), mean(x), mean(y)

Then your upper left bound is ( mean(x)-2σ(x) , mean(y)+2σ(y) )

and your lower right bound is ( mean(x)+2σ(x) , mean(y)-2σ(y) )

this will yield a rectangle for 2σ in both dimensions. For a circle things will get a bit more complicated... start with defining you "acceptable region"

琉璃繁缕 2024-10-22 11:52:52

计算质心,然后选择最接近该质心的点。然后,丢弃任何超过某个恒定距离(或者可能是某个阈值,例如距该点一两个标准差)的点。现在,使用修剪后的点集重新计算。这样做直到您对结果感到满意为止(即所有点都在您定义的边界内)。

正如 Matthew PK 所说,这适用于简单的半径,但如果您想要某种类型的弯曲边界,则需要做很多额外的工作。

Compute the centroid, and then pick the point that's nearest that centroid. Then, throw out any point that's more than some constant distance (or, perhaps, some threshold like one or two standard deviations away from that point). Now, re-compute using the trimmed set of points. Do that until you're happy with the result (i.e. all points are within the boundaries that you define).

As Matthew PK said, this will work will for a simple radius, but if you want some type of curved boundary, it's a lot of additional work.

余厌 2024-10-22 11:52:52

将您在统计课程中学到的知识运用到实践中;例如:

  1. 计算 X 和 Y 坐标的平均值
  2. 计算标准差(X 和 Y)
  3. 丢弃与平均值相差超过两个标准偏差的项目
  4. 根据结果坐标计算边界框

Put to work what you learned in your statistics courses; e.g.:

  1. Calculate the mean of your X and Y coordinates
  2. Calculate the standard deviation (X and Y)
  3. Discard items that are more than two stdevs from your mean
  4. Calculate your bounding box based on the resulting coordinates
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文