 # NPGR007 - 002warping

## Comparison of basic interpolation methods for digital image warping

I've implemented basic interpolation methods for digital image warping - bicubic, bilinear, distance based and nearest (original assignment example).
Detailed task assignment here (in Czech).

The comparison is made in two warp factors (0.1 and 0.5) using given warping function F and its inverse function.

29     public override void F ( double x, double y, out double u, out double v )

30     {

31       if ( dirty )

32       {

33         double aspectRatio = iwidth / (double)iheight;

34         tmp1 = 0.5 * Math.Min( 1.0, aspectRatio );

35         tmp2 = 0.5 * (factor - 1.0);

36         tmp3 = 0.5 * aspectRatio;

37         tmp4 = 0.5 * (1.0 / factor - 1.0);

38         dirty = false;

39       }

40       x /= iwidth;

41       y /= iheight;

42       double ax = (x - tmp3) / tmp1;

43       double ay = (y - 0.5) / tmp1;

44       double rr = ax * ax + ay * ay;    // radius squared

45       double mag = tmp1 * Math.Exp( tmp2 * Math.Log( rr ) );

46       u = tmp3 + mag * ax;

47       v = 0.5 + mag * ay;

48       u *= owidth;

49       v *= oheight;

50     }

### Image compare tool

Click on the image below to see comparison

Custom comparison: double click on any image in the gallery bellow to set image2 and then click on any image in the gallery bellow to set image1. (Javascript has to be enabled in order to make this work) Image 1: /05_2_bilinear.png

### Comparison gallery

 Original (not warped) image - Cate Original (not warped) image - grid  Relative warping distance map (Warp factor 0.1) Relative warping distance map (Warp factor 0.5)  Bilinear interpolation of grid (Warp factor 0.1) Bilinear interpolation of grid (Warp factor 0.5)  Bicubic interpolation of grid (Warp factor 0.1) Bicubic interpolation of grid (Warp factor 0.5)  Original Nearest interpolation (Warp factor 0.5)  Distance^(1/2) (square-root) based interpolation (Warp factor 0.5) Distance based interpolation (Warp factor 0.5)  Original Distance^2 (square) based interpolation (Warp factor 0.5)  Bilinear interpolation (Warp factor 0.5) Bicubic interpolation (Warp factor 0.5)  Original Nearest interpolation (Warp factor 0.1)  Distance^(1/2) (square-root) based interpolation (Warp factor 0.1) Distance based interpolation (Warp factor 0.1)  Original Distance^2 (square) based interpolation (Warp factor 0.1)  Bilinear interpolation (Warp factor 0.1) Bicubic interpolation (Warp factor 0.1)  