cnvY

Syntax

int cnvY(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 Y direction, and dividing the sum by 'd'.

Description

Applies a 1-D convolution to the image in the vertical / y direction. That is, cnvY convolves pixels at co-these ordinates:

(x,y-k), (x,y-k+1), ... (x,y-1), (x,y), (x,y+1), ... (x,y+k-1), (x,y+k)

Example

%fml
// 3-pixel radius blur in the y-direction

ForEveryTile: {

  // Convolution coefficients
  // 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 = cnvY(3, 0, 16, src, x, y, z);
        pset(x, y, z, val);

      }
    }
  }

  return true;
}

See Also

cnv, cnvX, xyzcnv