import type { Fn, FnN3, NumericArray } from "@thi.ng/api";
import { FloatBuffer } from "@thi.ng/pixel/float";
import type { ConvolutionKernelSpec, ConvolveOpts, KernelFnSpec, KernelSpec, PoolTemplate } from "./api.js";
/**
 * Convolves a single channel from given `src` float buffer with provided
 * convolution or pooling kernel with support for strided sampling (resulting in
 * smaller dimensions). Returns result as single channel buffer (in
 * {@link FLOAT_GRAY} format).
 *
 * @remarks
 * Use {@link convolveImage} to process multiple or all channels in a buffer.
 *
 * Reference:
 * https://en.wikipedia.org/wiki/Kernel_(image_processing)
 *
 * @param src -
 * @param opts -
 */
export declare const convolveChannel: (src: FloatBuffer, opts: ConvolveOpts) => FloatBuffer;
/**
 * Similar to {@link convolveChannel}, but processes multiple or all channels
 * (default) in a buffer and returns a new buffer in same format as original.
 *
 * @remarks
 * This function re-uses as much as internal state & memory as possible, so will
 * be faster than individual applications of {@link convolveChannel}.
 *
 * @param src -
 * @param opts -
 */
export declare const convolveImage: (src: FloatBuffer, opts: Exclude<ConvolveOpts, "channel"> & {
    channels?: number[];
}) => FloatBuffer;
/**
 * HOF convolution or pooling kernel code generator. Takes either a
 * {@link PoolTemplate} function or array of kernel coefficients and kernel
 * width/height. Returns optimized kernel function for use with
 * {@link __convolve}. If `normalize` is true (default: false), the given
 * coefficients are divided by their sum (only used if provided as array).
 *
 * @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
 * {@link defLargeKernel}.
 *
 * @param tpl -
 * @param w -
 * @param h -
 * @param normalize -
 */
export declare const defKernel: (tpl: NumericArray | PoolTemplate, w: number, h: number, normalize?: boolean) => Fn<FloatBuffer, FnN3>;
/**
 * Loop based fallback for {@link defKernel}, intended for larger kernel sizes
 * for which loop-unrolled approach is prohibitive. If `normalize` is true
 * (default: false), the given coefficients are divided by their sum.
 *
 * @param kernel -
 * @param w -
 * @param h -
 * @param normalize -
 */
export declare const defLargeKernel: (kernel: NumericArray, w: number, h: number, normalize?: boolean) => Fn<FloatBuffer, FnN3>;
export declare const POOL_NEAREST: PoolTemplate;
export declare const POOL_MEAN: PoolTemplate;
export declare const POOL_MIN: PoolTemplate;
export declare const POOL_MAX: PoolTemplate;
/**
 * Higher order adaptive threshold {@link PoolTemplate}. Computes: `step(C -
 * mean(K) + B)`, where `C` is the center pixel, `K` the entire set of pixels in
 * the kernel and `B` an arbitrary bias/offset value.
 *
 * @example
 * ```ts
 * import { convolveChannel, POOL_THRESHOLD } from "@thi.ng/pixel";
 *
 * // 3x3 adaptive threshold w/ bias = 1
 * convolveChannel(src, { kernel: { pool: POOL_THRESHOLD(1), size: 3 }});
 * ```
 *
 * @param bias -
 */
export declare const POOL_THRESHOLD: (bias?: number) => PoolTemplate;
export declare const SOBEL_X: KernelSpec;
export declare const SOBEL_Y: KernelSpec;
export declare const SHARPEN3: KernelSpec;
export declare const HIGHPASS3: KernelSpec;
export declare const BOX_BLUR3: KernelSpec;
export declare const BOX_BLUR5: KernelSpec;
export declare const GAUSSIAN_BLUR3: KernelSpec;
export declare const GAUSSIAN_BLUR5: KernelSpec;
/**
 * Higher order Gaussian blur kernel for given pixel radius `r` (integer).
 * Returns {@link ConvolutionKernelSpec} with resulting kernel size of `2r+1`.
 *
 * @param r -
 */
export declare const GAUSSIAN: (r: number) => ConvolutionKernelSpec;
/**
 * Higher-order Lanczos filter kernel generator for given `a` value (recommended
 * 2 or 3) and `scale` (num pixels per `a`).
 *
 * @remarks
 * https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel
 *
 * @param a -
 * @param scale -
 */
export declare const LANCZOS: (a: number, scale?: number) => ConvolutionKernelSpec;
export declare const UNSHARP_MASK5: KernelSpec;
/**
 * 3x3 convolution kernel to detect local maxima in a Von Neumann neighborhood.
 * Returns in 1.0 if the center pixel is either higher valued than A & D or B & C,
 * otherwise return zero.
 *
 * @remarks
 * ```text
 * |---|---|---|
 * |   | A |   |
 * |---|---|---|
 * | B | X | C |
 * |---|---|---|
 * |   | D |   |
 * |---|---|---|
 * ```
 *
 * Also see {@link MAXIMA4_DIAG} for alternative.
 */
export declare const MAXIMA4_CROSS: KernelFnSpec;
/**
 * Similar to {@link MAXIMA4_CROSS}, a 3x3 convolution kernel to detect local
 * maxima in a 45 degree rotated Von Neumann neighborhood. Returns in 1.0 if the
 * center pixel is either higher valued than A & D or B & C, otherwise return
 * zero.
 *
 * @remarks
 * ```text
 * |---|---|---|
 * | A |   | B |
 * |---|---|---|
 * |   | X |   |
 * |---|---|---|
 * | C |   | D |
 * |---|---|---|
 * ```
 */
export declare const MAXIMA4_DIAG: KernelFnSpec;
/**
 * Union kernel of {@link MAXIMA4_CROSS} and {@link MAXIMA4_DIAG}.
 */
export declare const MAXIMA8: KernelFnSpec;
//# sourceMappingURL=convolve.d.ts.map