Hi,
i tried to make a sketch which projects an image like a fisheye camera lens.
I searched a while how to do it and found this formula for MathMap:
filter fisheye (image in)
in(ra:[r*r/R,a])
end
(
http://www.complang.tuwien.ac.at/schani/mathmap/stills.html)
Example picture:
http://www.gdargaud.net/Photo/Fisheye/20050606_FisheyeChristophe2.jpgI don't know how to adopt it to the cartesian coodinatesystem.
Here's my basic sketch:
PImage img1;
float r; // Radius from specific point to the middle (width/2, height/2)
float rMax; //Max Radius = Distance from the middle to a corner
void setup()
{
size(640, 480, P2D);
img1 = loadImage("img.jpg");
img1.resize(640, 480);
rMax = dist(0, 0, width/2, height/2);
}
void draw()
{
loadPixels();
img1.loadPixels();
for(int x=0 ; x<width; x++)
{
for(int y=0; y<height; y++)
{
r = dist(width/2, height/2, x, y);
//pixels[y*width+x] = img1.pixels[ ... ];
}
}
updatePixels();
}
Would be really nice if someone can help me!
Greetings Tim