使用极坐标创建图像(图像变换) [英] creating image using polar coordinates (image transformations)

查看:269
本文介绍了使用极坐标创建图像(图像变换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理图像变形。图像的真实坐标的变换版本是x和y,并且变换的图像的极坐标是r和theta。

I'm working on image warping. The transformed version of the real coordinates of an image are x and y, and, the polar coordinates of the transformed image are r and theta.

(圆柱形变形)。我有转换功能。但我不知道某些事情。我从变换函数得到极坐标,可以很容易地转换为笛卡尔。但如何绘制这个变换的图像?因为新尺寸将不同于旧图片尺寸。

(cylindrical anamorphosis). I have the transformation functions. But Im confused about a certain things. I'm getting the polar coordinates from transformation functions which can easily be converted to cartesian. But how to draw this transformed image? as the new size will be different than the old image size.

EDIT :我有如图所示的圆柱体。我有转换函数将其转换为幻影图像如图所示。由于此图片的大小与原始图片不同,如何确保主图片中的所有点都在转换。此外,变换图像中的那些点的坐标是极坐标。我可以使用openCV使用转换的极坐标形成新图像吗?

EDIT : I have the image as shown in the cylinder. I have the transformation function to convert it into the illusion image as shown. As this image's size is different from the original image, how do I ensure that all my points in the main image are being transformed. Moreover the coordinates of those points in transformed image are polar. Can I use openCV to form the new image using the transformed polar coordinates?

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

推荐答案

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

You have two problems here. In my understanding, the bigger problem arises because you are converting discrete integral coordinates into floating point coordinates. The other problem is that the resulting image's size is larger or smaller than the original image's size. Additionally, the resulting image does not have to be rectangular, so it will have to be either cropped, or filled with black pixels along the corners.

根据 http://opencv.willowgarage.com/documentation/geometric_image_transformations.html 没有径向

I'd suggest you do the following:





  1. 将原始图片缩放为宽度* 2,高度* 2。将新图像设置为黑色。 (cvResize,cvZero)

  2. 运行原始图片中的每个像素。找到像素的新坐标。将其值的1/9添加到新的
    坐标的所有8个邻居中,以及新坐标本身。 (CV_IMAGE_ELEM(...)+ =
    1.0 / 9 * ....)

  3. 将新图片缩小为原始宽度,高度。

  4. 根据结果,您可能需要使用锐化程序。

  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]你创建一个函数

If you want to KEEP some pixels that go out of bounds, that's a different question. Basically you want to find Min and Max of the coordinates you receive, so for example your original image has Min,Max = [0,1024] and your new MinNew,MaxNew = [-200,1200] you make a function

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

这篇关于使用极坐标创建图像(图像变换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆