我想知道如何将顶部图片转换为底部图片。这些图片可以在以下链接中找到。顶部图片是笛卡尔坐标系下的,底部图片是极坐标系下的转换后的图片。
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++;
}
}
float
这个词,剩下的基本上就是你需要的公式了。 - user1693593getInputPixel()
。谢谢你发现了这个问题!我已经更新了代码。 - user1118321