将极坐标图像转换为笛卡尔图像

发布于 2024-10-31 23:57:15 字数 304 浏览 5 评论 0原文

我正在尝试将极坐标(轴是角度 x 半径)中的图像转换为笛卡尔坐标(轴是 x 和 y)中的图像。

在 matlab 中使用 pcolor() 这很简单,但问题是我必须在 mex 文件(Matlab 的 C++ 接口)中执行此操作。这看起来很简单,只是 Matlab 仅使用数组容器,所以我想不出一种聪明或雄辩的方法来做到这一点。

我确实可以访问图像尺寸,并且我可以想象一种非常混乱的方式,将输入图像数组重新打包为 C++ 中的矩阵并进行转换,但这会很混乱且有问题。

另外,我需要能够在 xy 平面中的点之间插入间隙。

有什么想法吗?

I am attempting to convert an image in polar coordinates (axes are angle x radius) to an image in cartesian coordinates (axes are x and y).

This is simple enough in matlab using pcolor() but the issue is that I must do this in a mex file (c++ interface to Matlab). This seem's easy enough except that Matlab ONLY uses array containers so I can't think of a clever or eloquent way of doing this.

I do have access to the image dimensions and I can imagine a very messy way of repackaging the input image array as a matrix in C++ and carying out the conversion but this would be messy and problematic.

Also, I need to be able to interpolate gaps between points in the xy plain.

Any ideas?

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

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

发布评论

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

评论(1

梦里的微风 2024-11-07 23:57:15

这在图像处理中是相当标准的,特别是在配准中。然而,这需要一些思考并且不是“显而易见的”。第一次对我来说也不明显。

我假设您有两个图像,位于不同的“域”中,在您的情况下,极坐标中的源图像和笛卡尔坐标中的目标图像。我假设您知道要填充的目标图像中的区域。

在图像处理中众所周知的最佳做法是循环遍历要填充的目标图像的已知区域中的坐标。对于每个位置 (x,y),您都将进行一些极坐标转换。它可能是 r = sqrt(x*x+y*y) 和 theta = atan2(y,x) 或类似的东西。然后,您可以通过插值从极坐标位置的该位置进行采样。

插值的选择包括:

  1. 最近邻 - 您只需舍入到最近的 rtheta 并选择其值。
  2. 双线性 -
  3. 双三次
  4. ...

当然,您应该注意边界条件以及如果您的 rtheta 超出图像会发生什么。

对于各种坐标变换,此过程也类似(循环目标图像并从源图像采样,并基于反向变换进行查找)。好处是你不会在与源想象相关的地方留下漏洞。

希望这对图像部分有所帮助。

至于墨西哥部分,这里有一些链接:
墨西哥教程
Mex 教程

你能更具体地说明一下什么吗你需要墨西哥部分吗?

This is reasonably standard in image processing, particularly in registration. However, it takes some thought and isn't "obvious". It wasn't obvious to me the first time either.

I'm assuming you have two images, in different "domains", in your case a source image in polar coordinates and a target image in Cartesian coordinates. I'm assuming you know the region in the target image you want to populate.

The commonly known best thing to do in image processing is to loop over coordinates in the known area of the target image that you want to populate. For each of these positions (x,y), you'll have some conversion to polar. It's probably r = sqrt(x*x+y*y) and theta = atan2(y,x) or something like that. Then you sample from that position in the polar coordinate position with interpolation.

Among choices of interpolation are:

  1. Nearest neighbor - you just round to the nearest r and theta and choose the value of that.
  2. Bilinear -
  3. Bi-cubic
  4. ...

Of course you should take care of boundary conditions and what happens if your r and theta go out of your image.

This procedure also is similar (looping over the target image and sampling from the source image, and doing lookups based on the reverse transform) for all kinds of coordinates transformations. The nice thing is that you don't leave holes where your source imagine is relevant.

Hope this helps with the image part.

As for the mex part, here's some links:
Mex tutorial
Mex tutorial

Can you be more specific about what you need about the mex part?

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