Older Newer
Sat, 05 Apr 2003 21:07:50 . . . . (Pete)?


Changes by last author:

Added:
= cnv =

== Syntax ==

:int cnv(int m11, int m12, int m13, int m21, int m22, int m23, int m31, int m32, int m33, int d)

== Arguments ==

:m11

::An integer weighting for the pixel at [x-1,y-1]

:m12

::An integer weighting for the pixel at [x,y-1]

:m13

::An integer weighting for the pixel at [x+1,y-1]

:m21

::An integer weighting for the pixel at [x-1,y]

:m22

::An integer weighting for the pixel at [x,y]

:m23

::An integer weighting for the pixel at [x+1,y]

:m31

::An integer weighting for the pixel at [x-1,y+1]

:m32

::An integer weighting for the pixel at [x,y+1]

:m33

::An integer weighting for the pixel at [x+1,y+1]

:d

::An integer divisor - usually the sum of the nine weighting values

== Return ==

:An integer in the range 0 to 255

== Description ==

:This function is valid only in the RGBA and ForEveryPixel handlers; the xyzcnv function performs the same operation in the ForEveryTile handler. The cnv function performs a basic convolution operation using a 3 by 3 matrix of image pixels and a corresponding matrix of weightings. The parameters to the function call represent the values of the weighting matrix, presented in row order - in other words, in the designation used here the first digit after the 'm' represents the row number and the second the column. The divisor 'd' should usually be given as the sum of the nine weightings. The cnv function sums the values for the nine pixels centered on the current [x,y] position and channel, multiplying each pixel value by the corresponding weighting from the matrix; the value returned is then that sum divided by the divisor 'd'.

== Example ==

<code>

%ffp

R,G,B,A : cnv(1,2,1, 2,4,2, 1,2,1, 16) // Simple 3x3 Gaussian blur

</code>

== Also see ==

:xyzcnv

== Comments ==

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