2维数组,计算最大值

发布于 2024-09-18 13:05:06 字数 181 浏览 2 评论 0原文

我正在尝试获取二维数组中一行的最大值。例如这张灰度图像。对我来说计算水平和垂直最大灰度值没有问题。

但是,我不知道如何从这个二维数组计算有角度的线(绿线)。

任何人都可以帮我解决这个问题。

替代文本

I'm trying to get the maximum value in a line in an 2d array. For example is this greyscale image. For me it's no problem to calculate the horizontal and vertical maximum grey value.

However, I don't have a clue how to calculate an angled line (green line) from this 2d array.

Anyone can help me out with this.

alt text

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

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

发布评论

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

评论(1

如果没结果 2024-09-25 13:05:06

你知道线的角度吗?

您可以使用正弦和余弦函数来计算每个点的 x 和 y 值。

var x = Math.Cos(angle) * length
var y = Math.Sin(angle) * length

每次增加长度的地方。您必须对 x 和 y 值进行舍入,因为它们不是整数。

然后使用 x 和 y 值作为二维数组的索引

Do you know the angle of the line?

You can use the sinus and cosinus functions to calculate the x and y values of each point.

var x = Math.Cos(angle) * length
var y = Math.Sin(angle) * length

Where you increase the length each time. You will have to round the x and y values because they won't be integers.

You then use the x and y values as indices for the 2 dimensional arrays

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