How would you make a bubble lens effect, like looking through a fish-eye lens.
I wanted to know the equations behind the pixel color translations. Anyone know where I can find this? Or have any examples?
Printable View
How would you make a bubble lens effect, like looking through a fish-eye lens.
I wanted to know the equations behind the pixel color translations. Anyone know where I can find this? Or have any examples?
My internet died as I was posting a reply to this message last night.
First, you need to know the equation of a parabola. Using this, you can define your "lens" as a parabola. Then, for each x coordinate, find the y value that is on the parabola for that coordinate. Then, at that point, find the slope of the parabola (probably calculus here), and find a line that goes perpendicular the the slope. Using that, extend that line until it hits the source image. The pixel you intersect is the pixel to plot. Here is an Image:
http://www.vbforums.com/attachment.php?s=&postid=759123
Z.
ahh, so simple. Very Nice Z! Thanks.
So I'm guessing that this would also work with other equations suck as low amplitude sine/cosine curves. Hmm, that would be an interesting project. Well if I ever finish the project I'll be sure to post it here!
Thanks again!
NOMAD
I forgot to mention =). All of that was out of my own head, so you may want to do a bit more research, but it seems pretty sound to me. Points nearest the center of the image will come out close to the original, while ones nearest the edge will be distorted.
Z.
Damn you and your college-level education, zaei!
Btw, there's a very very fast way to apply effects like that... but if I tell you how, my friend who invented the trick will kill me :)
You need to add 128 to j in the call to GetPixel(). Also, since squaring any value will give you a positive value, you need to determine if the pixel you should be getting is negative or positive.
Z.