# [ACCEPTED]-Resources for image distortion algorithms-image-processing

Score: 30

I can't find any references, but I can give 33 a basic idea of how distortion effects work.

The 32 key to the distortion is a function which 31 takes two coordinates (x,y) in the distorted 30 image, and transforms them to coordinates 29 (u,v) in the original image. This specifies 28 the inverse function of the distortion, since 27 it takes the distorted image back to the 26 original image

To generate the distorted 25 image, one loops over x and y, calculates 24 the point (u,v) from (x,y) using the inverse 23 distortion function, and sets the colour 22 components at (x,y) to be the same as those 21 at (u,v) in the original image. One ususally 20 uses interpolation (e.g. http://en.wikipedia.org/wiki/Bilinear_interpolation ) to determine 19 the colour at (u,v), since (u,v) usually 18 does not lie exactly on the centre of a 17 pixel, but rather at some fractional point 16 between pixels.

A swirl is essentially a 15 rotation, where the angle of rotation is 14 dependent on the distance from the centre 13 of the image. An example would be:

``````a = amount of rotation
b = size of effect

angle = a*exp(-(x*x+y*y)/(b*b))
u = cos(angle)*x + sin(angle)*y
v = -sin(angle)*x + cos(angle)*y
``````

Here, I 12 assume for simplicity that the centre of 11 the swirl is at (0,0). The swirl can be 10 put anywhere by subtracting the swirl position 9 coordinates from x and y before the distortion 8 function, and adding them to u and v after 7 it.

There are various swirl effects around: some 6 (like the above) swirl only a localised 5 area, and have the amount of swirl decreasing 4 towards the edge of the image. Others increase 3 the swirling towards the edge of the image. This 2 sort of thing can be done by playing about 1 with the angle= line, e.g.

``````angle = a*(x*x+y*y)
``````
Score: 21

There is a Java implementation of lot of 2 image filters/effects at Jerry's Java Image Filters. Maybe you can 1 take inspiration from there.

Score: 5

The swirl and others like it are a matrix 7 transformation on the pixel locations. You 6 make a new image and get the color from 5 a position on the image that you get from 4 multiplying the current position by a matrix.

The 3 matrix is dependent on the current position.

here 2 is a good CodeProject showing how to do 1 it

http://www.codeproject.com/KB/GDI-plus/displacementfilters.aspx

Score: 2

there has a new graphic library have many 1 feature