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. 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.
Look at what OpenCV is actually being used for in that link. These are functions that start with
cv
: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:
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.