c++ - 使用极坐标创建图像(图像变换)

标签 c++ image-processing opencv distortion

我正在研究图像变形。变换后的图像实坐标为x和y,变换后图像的极坐标为r和theta。

(圆柱变形)。我有转换功能。但我对某些事情感到困惑。我从可以轻松转换为笛卡尔坐标的转换函数中获取极坐标。但是如何绘制这个变换后的图像呢?因为新尺寸将不同于旧图像尺寸。

编辑 :我有圆柱体中显示的图像。如图所示,我具有将其转换为幻觉图像的转换功能。由于此图像的大小与原始图像不同,我如何确保主图像中的所有点都被转换。此外,变换图像中那些点的坐标是极坐标的。我可以使用 openCV 使用转换后的极坐标形成新图像吗?

enter image description here

编号:http://www.physics.uoguelph.ca/phyjlh/morph/Anamorph.pdf

最佳答案

这里有两个问题。在我的理解中,更大的问题出现了,因为你正在将离散积分坐标转换为浮点坐标。另一个问题是生成的图像大小大于或小于原始图像的大小。此外,生成的图像不必是矩形的,因此必须对其进行裁剪或在角处填充黑色像素。

根据 http://opencv.willowgarage.com/documentation/geometric_image_transformations.html没有径向变换例程。

I'd suggest you do the following:
  1. Upscale the original image to have width*2, height*2. Set the new image to black. (cvResize, cvZero)
  2. Run over each pixel in the original image. Find the new coordinates of the pixel. Add 1/9 of its value to all 8 neighbors of the new coordinates, and to the new coordinates itself. (CV_IMAGE_ELEM(...) += 1.0/9 * ....)
  3. Downscale the new image back to the original width, height.
  4. Depending on the result, you may want to use a sharpening routine.

如果您想保留一些超出范围的像素,那是另一个问题。基本上你想找到你收到的坐标的最小值和最大值,所以例如你的原始图像有 Min,Max = [0,1024] 和你的新 MinNew,MaxNew = [-200,1200] 你做一个函数

normalize(int &convertedx,int &convertedy)
{
convertedx = MinNewX + (MaxNewX-MinNewX)/(MaxX-MinX) * convertedx;
convertedy = ...;
}

关于c++ - 使用极坐标创建图像(图像变换),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14404013/

相关文章:

c++ - 是否可以使用 operator new 和 initialiser 语法初始化非 POD 数组?

c++ - 如何在 C++ 中查找内存泄漏

c++ - 使用 -parallel 或(和)-vec 会使我们的程序运行得更快吗?

opencv - 非连接形态过滤器

c++ - boost::asio 接受器在 EOF 后重新打开和异步读取

c - 如何对四边形使用tensorflow.crop_and_resize()

c++ - OpenCv 2.3 C - 如何隔离图像中的对象

c++ - 尽管有新的视频数据,OpenCV 直方图不会更新

c++ - OpenCV:将图像包装到圆柱坐标

python - OpenCV 无法从视频捕获设备读取