Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm trying to modify a function to create fisheye effect on image (i use a software that permit to modify every single pixel of an image).

At the moment i use this function:

float kk=width*0.5;
float ll=height*0.5;
float dx=(x-kk);
float dy=(y-ll);

float aa=atan2(dy,dx);
float rr=hypot(dy,dx);
float rs=rr*rr/hypot(kk,ll);
int px=kk+rs*cos(aa);
int py=ll+rs*sin(aa);

where:

  • width: image width;
  • height: image height;
  • x and y: original pixel position and px and py are pixel from where i take result.

Using this fonction i substitute pixel at {x,y} with pixel at {px,py}. This work,and create a fisheye effect correctly, but i need to add a variable/parameter to control final effect.

Someone could help me to find how to add this parameter on that function ?

share|improve this question

1 Answer 1

You could multiply rs by a parameter. This corresponds to changing the scale of how close to the center your original pixel is.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.