= cnvX =
== Syntax == int cnvX(int k, int off, int d, function* pGetf, int x, int y, int z) == Arguments == :k ::The kernel radius. Must be a positive number. :off ::The starting index within the anonymous array of put / get cells where the kernel coefficients are stored. The number of coefficients is n=k*2+1, where 'k' is the kernel radius. :d ::The denominator by which the convolution sum will be divided. :pGetf ::The FM built-in function that will be called to fetch values from an image buffer at the designated coordinates. Must be 'src', 'tget', 't2get', or 'pget'. :x ::The x-coordinate at which the (center of the) kernel is to be applied. :y ::The y-coordinate at which the (center of the) kernel is to be applied. :z ::The channel number to which the kernel is applied. == Return == The integer result obtained by summing the products of the n kernel coefficients with n image pixels in the X or Y direction, and dividing the sum by 'd'. == Description == Applies a 1-D convolution to the image in the horizontal / x direction. That is, cnvX convolves pixels at co-these ordinates: (x-k,y), (x-k+1,y), ... (x-1,y), (x,y), (x+1,y), ... (x+k-1,y), (x+k,y) == Example == <code> %fml // 3-pixel radius blur in the x-direction ForEveryTile: { // Convolution co-efficients // in first 7 cells put(1, 0); put(2, 1); put(3, 2); put(4, 3); put(3, 4); put(2, 5); put(1, 6); int val; for (z = 0; z < 3; z++) { for (y = y_start; y < y_end; y++) { for (x = x_start; x < x_end; x++) { val = cnvX(3, 0, 16, src, x, y, z); pset(x, y, z, val); } } } return true; }</code> == See Also == |