UNPKG

@thi.ng/pixel-dither

Version:

Extensible image dithering w/ various algorithm presets

33 lines 1.22 kB
import type { IntBuffer } from "@thi.ng/pixel"; import type { BayerMatrix, BayerSize } from "./api.js"; /** * Creates a Bayer matrix of given kernel size (power of 2) for ordered * dithering and use with {@link orderedDither}. * * @remarks * Reference: * https://en.wikipedia.org/wiki/Ordered_dithering * * @param size - */ export declare const defBayer: (size: BayerSize) => BayerMatrix; /** * Applies in-place, ordered dithering using provided dither matrix * (or matrix size) and desired number of dither levels, optionally * specified individually (per channel). Each channel is be * processed independently. Channels can be excluded from dithering * by setting their target colors to zero or negative numbers. * * @remarks * A `size` of 1 will result in simple posterization of each * channel. The `numColors` value(s) MUST be in the `[0 .. * numColorsInChannel]` interval. * * Also see: {@link defBayer} * * @param img - pixel buffer * @param size - bayer dither matrix/size * @param numColors - num target colors/steps */ export declare const orderedDither: (img: IntBuffer, size: BayerSize | BayerMatrix, numColors: number | number[]) => IntBuffer; //# sourceMappingURL=ordered.d.ts.map