如何将45°-135°坐标系的坐标值转换到地球坐标系?

发布于 2024-12-27 09:02:56 字数 421 浏览 1 评论 0原文

我得到一系列方形二值图像,如下图所示, 在此处输入图像描述

我想找到红色点,它是四个块(2 个黑色和 2 个块)的交点白色的)。为此,我用来获取沿方形图像对角线方向的所有像素值的总和,分别为 45 度和 135 度。最大像素和 45 度线与最小像素和 135 度线的交点就是我的红点所在的位置。

现在我得到了45°-135°坐标系中红点的坐标,如何将它们转换为地球坐标?

换句话说,假设我在 45deg-135deg 坐标系中有一个点;如何找到xy坐标系中对应的坐标值?什么是变换矩阵?

更多可能有帮助的信息:

1)如果图像是 60x60 图像,我会在 45deg-135deg 系统中得到 120 个值,因为我扫描每一行,然后扫描列以添加像素。

I get a series of square binary images as in the picture below,
enter image description here

I want to find the red point, which is the point of intersection of four blocks (2 black and 2 white). For doing so, I use to get the sum of all pixel values along the diagonal directions of the square image, which is 45 deg and 135 deg respectively. The intersection of maximum pixel sum 45 deg line and minimum pixel sum 135 deg line is where my red point is.

Now that I get the co-ordinate of the red point in 45 deg-135 deg co-ordinate system, how to I transform them to earth co-ordinates?

In other words, say I have a point in 45deg-135deg co-ordinate system; How do I find the corresponding co-ordinate values in x-y co-ordinate system? What is the transformation matrix?

some more information that might help:

1) if the image is a 60x60 image, I get 120 values in 45deg-135deg system, since i scan each row followed by column to add the pixels.

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

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

发布评论

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

评论(2

白日梦 2025-01-03 09:02:56

我对 matlab 不太了解,但一般来说你需要做的就是将网格旋转 45 度。
这是一个有用的链接;显示您需要的旋转矩阵

维基百科旋转矩阵文章

2D后点的新坐标旋转看起来像这样:
x' = x \cos \theta - y \sin \theta。
y' = x \sin \theta + y \cos \theta。

将 theta 替换为 45(或者可能是 -45),您应该已准备就绪。

如果红点从 (x,y) 开始,那么在 -45 度旋转后,它将具有新坐标 (x',y'),其定义如下:

x' = x cos(-45) - y 罪 (-45)
y' = x sin (-45) + y cos (-45)

I don't know much about matlab, but in general all you need to do is rotate your grid by 45 degrees.
Here's a helpful link; shows you the rotation matrix you need

wikipedia rotation matrix article

The new coordinates for a point after 2D rotation look like this:
x' = x \cos \theta - y \sin \theta.
y' = x \sin \theta + y \cos \theta.

replace theta with 45 (or maybe -45) and you should be all set.

If your red dot starts out at (x,y), then after the -45 degree rotation it will have the new coordinates (x',y'), which are defined as follows:

x' = x cos(-45) - y sin (-45)
y' = x sin (-45) + y cos (-45)

小梨窩很甜 2025-01-03 09:02:56

抱歉,我误解了你的问题,但你为什么要旋转图像?红点的x值就是x方向导数具有最大绝对值的点。对于y方向,与y方向的导数相同。

假设您有以下图像

在此处输入图像描述

如果您采用图像的第一行,则它的开头全部为 1大部分宽度为零。第一列的图如下所示。

在此处输入图像描述

现在,您将这一行与内核 {-1,1} 进行卷积,这只是您的内核上的一个嵌套循环行,您会得到

在此处输入图像描述

现在查看此结果并提取具有最高值的点的位置即可获得72.因此,红点的 x 位置是 73(因为卷积核过早找到导数一个点)。

因此,如果data是上述二值图像的图像矩阵,那么提取你的红点位置接近Mathematica中的一行,

Last[Transpose[Position[ListConvolve[{-1, 1}, #] & /@ 
{data[[1]],Transpose[data][[1]]}, 1 | -1]]] + 1

这里你得到{73, 86},即如果 y=0 则正确位置是顶行。此方法应该可以在任何语言中在几分钟内实现。

备注:

  1. 卷积结果的近似导数可以为负值,也可以为正值。这取决于是从 0 到 1 的变化,还是从 0 到 1 的变化。如果要寻找最大值,就必须取卷积结果的绝对值。

  2. 请记住,图像矩阵中的第一行并不总是位于显示图像的顶部位置。这取决于您使用的软件。如果您得到错误的 y 值,请注意这一点。

Sorry when I misunderstood your question but why do you rotate the image? The x-value of your red point is just the point where the derivative in x-direction has the maximum absolute value. And for the y-direction it is the same with the derivative in y-direction.

Assume you have the following image

enter image description here

If you take the first row of the image it has at the beginning all 1 and the for most of the width zeroes. The plot of the first column looks like this.

enter image description here

Now you convolve this line with the kernel {-1,1} which is only one nested loop over your line and you get

enter image description here

Going now through this result and extracting the position of the point with the highest value gets you 72. Therefore the x-position of the red point is 73 (since the kernel of the convolution finds the derivative one point too soon).

Therefore, if data is the image matrix of the above binary image then extracting your red point position is near to one line in Mathematica

Last[Transpose[Position[ListConvolve[{-1, 1}, #] & /@ 
{data[[1]],Transpose[data][[1]]}, 1 | -1]]] + 1

Here you get {73, 86} which is the correct position if y=0 is the top row. This method should be implemented in a few minutes in any language.

Remarks:

  1. The approximated derivative which is the result of the convolution can either be negative or positive. This depends whether it is a change from 0 to 1 or vice versa. If you want to search for the highest value, you have to take the absolute value of the convolution result.

  2. Remember that the first row in the image matrix is not always in top position of the displayed image. This depends on the software you are using. If you get wrong y values be aware of that.

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