FishEye图片效果(桶式失真)算法(使用Java)? [英] FishEye Picture Effect (Barrel Distortion) Algorithm (with Java)?

查看:232
本文介绍了FishEye图片效果(桶式失真)算法(使用Java)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找算法(位图像素操作)来模拟正常图片中的鱼眼镜头(Barrel Distortion)。到目前为止,我已经发现涉及OpenCV,OpenGL或jhlabs等外部库的实现。由于我正在参加数字图像处理课程并且正在进行课程评估项目,因此我不确定使用任何外部库是否会让我获得好成绩。那么有人会给我这样的算法参考吗?

I'm looking for the algorithm (bitmap pixel manipulation) to simulate the fisheye lens (Barrel Distortion) from normal pictures. So far I've found implementation involving external libraries like OpenCV, OpenGL or jhlabs. Since I'm taking a class in Digital Image Processing and I'm making a course assessment project, I'm not sure whether using any external lib will earn me a good grade. So would anyone give me the reference to such algorithm?

Ps。我被要求用Java实现它,但是任何语言的例子都可以。

Ps. I'm asked to implement it in Java, but example from any language would do.

推荐答案

你做的很好能够找到做你想做的事的例子。将它们包含在您的问题中会很有帮助 - 它确保阅读它的人与您在同一页面上。所以这是一个链接

It's good that you've been able to find examples that do what you want. It's helpful to include them in your question -- it makes sure that people that read it are on the same page as you are. So here's a link.

你想要自己做事,而不依靠某些图书馆来为你做艰苦的工作也很好。但这并不意味着你必须忽略这样的解决方案。这就是原因。

It's also good that you want to do things by yourself, without relying on some library to do the hard work for you. But that doesn't mean you have to ignore such solutions. Here's why.

该链接。这些函数以 cv 开头:

$ grep -o "cv\\w*" barrel.cpp | sort | uniq
cv
cvCreateImage
cvGet2D
cvGetSize
cvLoadImage
cvNamedWindow
cvSaveImage
cvSet2D
cvShowImage
cvWaitKey

如果你看一下 OpenCV API ,所有这些功能只处理普通的任务,如图像创建,删除,显示,像素设置等。这些任务都不是特别的桶形失真。对于桶形失真,该解决方案不是OpenCV特定的

If you look at the OpenCV API, all of these functions just handle mundane tasks like image creation, deletion, display, setting of pixels, etc. None of these tasks are particular to barrel distortion. As far as barrel distortion goes, that solution is not OpenCV specific.

确实,该计划的核心在于:

Indeed, the heart of the program is here:

float getRadialX(float x,float y,float cx,float cy,float k){
  x = (x*xscale+xshift);
  y = (y*yscale+yshift);
  float res = x+((x-cx)*k*((x-cx)*(x-cx)+(y-cy)*(y-cy)));
  return res;
}

float getRadialY(float x,float y,float cx,float cy,float k){
  x = (x*xscale+xshift);
  y = (y*yscale+yshift);
  float res = y+((y-cy)*k*((x-cx)*(x-cx)+(y-cy)*(y-cy)));
  return res;
}

这只是径向变换公式 - 这是你需要的位了解。如您所见,那里没有OpenCV调用。

Which is just the radial transform formula -- this is the bit that you need to understand. As you can see, there's no OpenCV calls in there.

这篇关于FishEye图片效果(桶式失真)算法(使用Java)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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