Resampling Engine R13

R13 supports 13 resampling algorithm. :)

Supported algorithm:
Lanczos4, Lanczos3, Lanczos2, Mitchell, Lanrange, Hermite, Bell, B-Spine, Gauss, Bicubic, Average Pixel, Bilinear, Nearest Neighbor

Feature:
Easy to use
Fixed aspectratio
It doesn't use SIMD-technique. But it's fast enough. :)
It supports a lot of file format

Download:
R13 v1.33 english version
r13v133e.zip


Sample:
Sample down resampling
CZP(Circular zone plate) 512 x 512 -> 256 x 256 (50%)
Lanczos4

63[ms]

Lanczos3

47[ms]

Lanczos2

31[ms]

Mitchell

31[ms]

Lagrange

31[ms]

Hermite

31[ms]

Bell

31[ms]

B-Spline

47[ms]

Gauss

31[ms]

Bicubic

47[ms]

Average Pixel

15[ms]

Bilinear

15[ms]

N-N

0[ms]

Sample2 down resampling
CZP(Circular zone plate) 512 x 512 -> 154 x 154 (30%)
Lanczos4

31[ms]

Lanczos3

16[ms]

Lanczos2

16[ms]

Mitchell

16[ms]

Lagrange

15[ms]

Hermite

16[ms]

Bell

31[ms]

B-Spline

31[ms]

Gauss

31[ms]

Bicubic

16[ms]

Average Pixel

15[ms]

Bilinear

0[ms]

N-N

0[ms]

Sample3 down resampling
Lanczos4

32[ms]

Lanczos3

15[ms]

Lanczos2

16[ms]

Mitchell

16[ms]

Lagrange

15[ms]

Hermite

16[ms]

Bell

15[ms]

B-Spline

16[ms]

Gauss

15[ms]

Bicubic

15[ms]

Average Pixel

0[ms]

Bilinear

0[ms]

N-N

0[ms]

Sample4 Upscale resampling
Sample picture is 2x2 4pixel bitmap.
[0,0],[1,1]=Black [0,1],[1,0]=White
Lanczos4

0[ms]

Lanczos3

16[ms]

Lanczos2

0[ms]

Mitchell

0[ms]

Lagrange

0[ms]

Hermite

0[ms]

Bell

0[ms]

B-Spline

0[ms]

Gauss

15[ms]

Bicubic

0[ms]

Bilinear

0[ms]

N-N

0[ms]

Average Pixel algorithm work only down size resampling.



czp.png



// code for CZP
procedure CreateCZP(SrcBmp: TBitmap);
var
  x, y: Integer;
  Gray: Integer;
  SrcRow: PByte;
begin
  SrcBmp.PixelFormat := pf24bit;
  SrcBmp.Width := 512;
  SrcBmp.Height := 512;

  for y:=0 to SrcBmp.Height-1 do
  begin
    SrcRow := SrcBmp.ScanLine[y];

    for x:=0 to SrcBmp.Width-1 do
    begin
      Gray := Round(128*sin(PI/512*((x-256)*(x-256))
        + PI/512*((y-256)*(y-256)) ))+128;
      if Gray>255 then
        Gray := 255;
      if Gray<0 then
        Gray := 0;

      SrcRow^ := Gray; Inc(SrcRow);
      SrcRow^ := Gray; Inc(SrcRow);
      SrcRow^ := Gray; Inc(SrcRow);
    end;
  end;
end;
I guess it is better to use Trunc(hoge+0.5) than Round(hoge).