Older Newer
Sat, 14 Jul 2007 20:24:06 . . . . (Martin Koch)?


Changes by last author:

Added:
= FunctionName =

== Syntax ==

:int quickMedian(int low, int high)

== Arguments ==

:low:

:: lowest put/get cell that contains values, usually zero.

:high:

:: highest put/get cell that contains values, usually calculated as (radius*2+1) * (radius*2+1)

== Return ==

: The return value is the median value.

== Description ==

:specify.

== Example ==

<code>

%ffp

ctl(7): "Radius ", range=(1,15), val=1, page=1

ForEveryTile:

{

for (y=y_start; y<y_end; y++)

for (x=x_start; x<x_end; x++)

for (z=0; z<3; z++)

{

quickFill(x,y,z,0,ctl(7),0,0,X,Y);

pset(x,y,z,quickMedian(0,(ctl(7)*2+1)*(ctl(7)*2+1)-1));

}

return true;

}

</code>

== Also see ==

:quickFill()

== Comments ==

:Please notice that quickMedian() works fast for radius values from 1 to 8, but above that it gets very slow. There are much faster algorithms that use tables or histogram for calculating median values with a high radius. There are also slightly faster algorithms for medians with a radius of 1 or 2.

:Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.