What algorithm can I use to apply fisheye distortion in an image?

Can someone help me best develop a filtering algorithm for video processing?

Say, for example, I wanted to apply a fisheye lens filter to an image, how would I process the pixels so that it mimics this effect?

If I wanted to make the picture more red, I would subtract the values ​​from the blue and green components at each pixel, leaving only the red component.

This kind of distortion is more than just color processing, so I would like to know how to properly manipulate pixels to simulate a lens filter from a fisheye, or say a pinch of filter, etc.

EDIT:

Filtering algorithm for processing VIDEO *

+3
source share
2

, , , - . , , .

, , , OpenGL ES, :

 varying highp vec2 textureCoordinate;

 uniform sampler2D inputImageTexture;

 uniform highp vec2 center;
 uniform highp float radius;
 uniform highp float scale;

 void main()
 {
     highp vec2 textureCoordinateToUse = textureCoordinate;
     highp float dist = distance(center, textureCoordinate);
     textureCoordinateToUse -= center;
     if (dist < radius)
     {
         highp float percent = 1.0 + ((0.5 - dist) / 0.5) * scale;

         textureCoordinateToUse = textureCoordinateToUse * percent;
     }
     textureCoordinateToUse += center;

     gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse );

 }

GLSL . , , , . , scale. , .

- , . , .

+5

. , , , - opencv .

, , , , .

. , , , .

+3

All Articles