Function defKernel

  • HOF convolution or pooling kernel code generator. Takes either a PoolTemplate function or array of kernel coefficients and kernel width/height. Returns optimized kernel function for use with convolve. If normalize is true (default: false), the given coefficients are divided by their sum (only used if provided as array).

    Parameters

    • tpl: NumericArray | PoolTemplate
    • w: number
    • h: number
    • normalize: boolean = false

    Returns Fn<FloatBuffer, FnN3>

    Remarks

    If total kernel size (width * height) is < 512, the result function will use unrolled loops to access pixels and hence kernel sizes shouldn't be larger than ~22x22 to avoid excessive function bodies. For dynamically generated kernel functions, only non-zero weighted pixels will be included in the result function to avoid extraneous lookups. Row & column offsets are pre-calculated too. Larger kernel sizes are handled via defLargeKernel.

Generated using TypeDoc