从二维坐标到圆柱坐标的图像转换

发布于 2024-12-22 00:17:10 字数 314 浏览 1 评论 0原文

我想将 Jpeg 图像(其坐标(x,y))转换为圆柱坐标。opencv

中有没有可以直接执行此操作的函数?或者我可以使用 opencv 中的哪些函数来创建自己的函数?

我对 2d 坐标、3d 坐标和柱坐标感到困惑。有人可以简单讨论一下吗?

是否有可用于将 2d 转换为 3d 的数学算法?二维到圆柱坐标? 3d 到圆柱坐标?

我读过关于这个主题的上一篇文章,但不明白。

我没有上过图像处理课程,但我急于读书。 我通过经验和研究其他程序员的代码来学习..所以源代码将非常感激..

感谢大家,并对我的基本帖子感到抱歉,,

I would like to convert a Jpeg image (its coordinates (x,y)) into a Cylindrical coordinates..

Is there a function in opencv that can do this directly? or what functions in opencv can I use to create my own??

I am having confusion between 2d coordinates, 3d coordinates and cylindrical coordinates.. can someone briefly discuss this?

Is there a mathematical algorithms available to convert 2d to 3d? 2d to cylindrical coordinates? 3d to cylindrical coordinates?

I read the previous post regarding this topic but does not understand it..

I have not take a course on image processing but I'm in a rush to read books..
I learn by experience and by studying other programmers code.. so source code will be much appreciated..

thanks to everyone and sorry for my elementary post,,

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

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

发布评论

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

评论(1

一身仙ぐ女味 2024-12-29 00:17:10

在 2D 领域,有极坐标。 OpenCV 有两个很好的函数用于在笛卡尔坐标和极坐标之间进行转换cartToPolarpolarToCart。似乎没有使用这些函数的好示例,因此我使用 cartToPolar 函数为您制作了一个:

#include <opencv2/core/core.hpp>
#include <iostream>

#include <vector>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    vector<double> vX;
    vector<double> vY;

    for(int y = 0; y < 3; y++)
    {
        for(int x = 0; x < 3; x++)
        {
            vY.push_back(y);
            vX.push_back(x);
        }
    }

    vector<double> mag;
    vector<double> angle;

    cartToPolar(vX, vY, mag, angle, true);

    for(size_t i = 0; i < mag.size(); i++)
    {
        cout << "Cartesian (" << vX[i] << ", " << vY[i] << ") " << "<-> Polar (" << mag[i] << ", " << angle[i] << ")" << endl;
    }

    return 0;
}

柱坐标是极坐标的 3D 版本。下面是一个小示例,展示了如何实现柱坐标。我不确定您将在哪里获得 3D z 坐标,因此我只是将其设为任意(例如,x + y):

Mat_<Vec3f> magAngleZ;

for(int y = 0; y < 3; y++)
{
    for(int x = 0; x < 3; x++)
    {
        Vec3f pixel;
        pixel[0] = cv::sqrt((double)x*x + (double)y*y); // magnitude
        pixel[1] = cv::fastAtan2(y, x);                 // angle
        pixel[2] = x + y;                               // z
        magAngleZ.push_back(pixel);
    }
}

for(int i = 0; i < magAngleZ.rows; i++)
{
    Vec3f pixel = magAngleZ.at<Vec3f>(i, 0);
    cout << "Cylindrical (" << pixel[0] << ", " << pixel[1] << ", " << pixel[2] << ")" << endl;
}

如果您对图像拼接感兴趣,请看一下在 stitching.cppstitching_detailed.cpp OpenCV 提供的示例。

编辑:
您可以在 圆柱形投影 有帮助:

计算机愿景:马赛克
<一href="http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&sqi=2&ved=0CEwQFjAE&url=http ://groups.csail.mit.edu/graphics /classes/CompPhoto06/html/lecturenotes/15_pano_6.pdf&ei=mtPsTovuCMKatwfjsZTyCQ&usg=AFQjCNE7dwPjPoGVfpEsn65iHfowL-pziA&sig2=LCo7riAg5ybnLwvK59oqYg">为什么马赛克?
使用不变特征的自动全景图像拼接
创建全视图全景图像马赛克和环境地图

In the 2D realm, you have Polar coordinates. OpenCV has two nice functions for converting between Cartesian and Polar coordinates cartToPolar and polarToCart. There doesn't seem to be a good example of using these functions, so I made one for you using the cartToPolar function:

#include <opencv2/core/core.hpp>
#include <iostream>

#include <vector>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    vector<double> vX;
    vector<double> vY;

    for(int y = 0; y < 3; y++)
    {
        for(int x = 0; x < 3; x++)
        {
            vY.push_back(y);
            vX.push_back(x);
        }
    }

    vector<double> mag;
    vector<double> angle;

    cartToPolar(vX, vY, mag, angle, true);

    for(size_t i = 0; i < mag.size(); i++)
    {
        cout << "Cartesian (" << vX[i] << ", " << vY[i] << ") " << "<-> Polar (" << mag[i] << ", " << angle[i] << ")" << endl;
    }

    return 0;
}

Cylindrical coordinates are the 3D version of Polar coordinates. Below is a small sample to show how you could implement cylindrical coordinates. I'm not sure where you'll be getting your 3D z-coordinate, so I just made it arbitrary (e.g., x + y):

Mat_<Vec3f> magAngleZ;

for(int y = 0; y < 3; y++)
{
    for(int x = 0; x < 3; x++)
    {
        Vec3f pixel;
        pixel[0] = cv::sqrt((double)x*x + (double)y*y); // magnitude
        pixel[1] = cv::fastAtan2(y, x);                 // angle
        pixel[2] = x + y;                               // z
        magAngleZ.push_back(pixel);
    }
}

for(int i = 0; i < magAngleZ.rows; i++)
{
    Vec3f pixel = magAngleZ.at<Vec3f>(i, 0);
    cout << "Cylindrical (" << pixel[0] << ", " << pixel[1] << ", " << pixel[2] << ")" << endl;
}

If you're interested in image stitching, have a look at the stitching.cpp and stitching_detailed.cpp samples provided by OpenCV.

EDIT :
You may find these resources on cylindrical projection helpful:

Computer Vision: Mosaics
Why Mosaic?
Automatic Panoramic Image Stitching using Invariant Features
Creating full view panoramic image mosaics and environment maps

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