【问题标题】:Image conversion from Cartesian coordinate to polar coordinate笛卡尔坐标到极坐标的图像转换
【发布时间】:2013-08-05 00:36:21
【问题描述】:

我想知道是否有人帮助我了解如何将顶部图像转换为底部图像。 图像可在以下链接中找到。顶部图像是笛卡尔坐标。下图是转换后的极坐标图

【问题讨论】:

    标签: image-processing polar-coordinates cartesian-coordinates


    【解决方案1】:

    这是一个基本的rectangular to polar coordinate transform。要进行转换,请扫描输出图像并将 x 和 y 视为 r 和 theta。然后将它们用作 r 和 theta 来查找输入图像中的相应像素。所以是这样的:

    int x, y;
    for (y = 0; y < outputHeight; y++)
    {
        Pixel* outputPixel = outputRowStart (y); // <- get a pointer to the start of the output row
        for (x = 0; x < outputWidth; x++)
        {
            float r = y;
            float theta = 2.0 * M_PI * x / outputWidth;
            float newX = r * cos (theta);
            float newY = r * sin (theta);
            *outputPixel = getInputPixel ( newX, newY ); // <- Should probably do at least bilinear resampling in this function
            outputPixel++;
        }
    }
    

    请注意,您可能需要根据您要实现的目标来处理包装。 theta 值在 2pi 处换行。

    【讨论】:

    • 你能帮我一个大忙,用 MATLAB 编写代码吗?我不熟悉 C++?
    • +1 @John 您可能应该在提问时指定语言。无论如何,如果您删除单词float,剩下的几乎就是您需要的公式。
    • @rep_movsd 我搞砸了。这些应该传递给getInputPixel()。谢谢你抓住它!我已经更新了代码。
    猜你喜欢
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-10
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    相关资源
    最近更新 更多