/** A greyscale picture: one byte per pixel, 0 black to 255 white. */
export interface Luminance {
    readonly data: Uint8Array;
    readonly width: number;
    readonly height: number;
}
/** A black-and-white picture: 1 for dark. */
export interface BitImage {
    readonly data: Uint8Array;
    readonly width: number;
    readonly height: number;
}
/**
 * Greyscale from RGBA (4 bytes a pixel) or grey (1 byte a pixel) data, with
 * an optional row stride in pixels for padded camera planes. Transparent
 * pixels count as white, so a code drawn on a transparent canvas still reads.
 */
export declare function toLuminance(data: Uint8Array | Uint8ClampedArray, width: number, height: number, channels: 1 | 4, rowStride?: number, storage?: Uint8Array): Luminance;
/**
 * The binariser's thresholds: one an 8x8 block, `across` by `down`, or a
 * single one for the whole picture when it is under 40 pixels a side.
 */
export interface Thresholds {
    readonly across: number;
    readonly down: number;
    readonly values: Float64Array;
    /** Flat local blocks in a picture with enough overall contrast to justify re-thresholding its inverse. */
    readonly invertedFallback: boolean;
    /** Every luminance value is identical, so neither this picture nor its reductions can contain a symbol. */
    readonly uniform: boolean;
}
/**
 * Local thresholds: each 8x8 block's threshold is the mean of the block
 * averages in the 5x5 blocks around it, and a flat block borrows its
 * neighbours' level, so shadows and gradients across the frame do not
 * swallow the code. Pictures under 40 pixels a side get one global threshold.
 */
export declare function thresholds(image: Luminance): Thresholds;
/** Invert luminance before thresholding: flat-block background estimates depend on polarity. */
export declare function invertLuminance(image: Luminance): Luminance;
/**
 * The threshold binarise() applied at pixel (px, py), which must be in the
 * picture. The last block in a row or column covers the last 8 pixels, so it
 * overlaps the one before it and wins where they overlap.
 */
export declare function thresholdAt(t: Thresholds, width: number, height: number, px: number, py: number): number;
/**
 * Local-threshold binarisation: 1 where a pixel is at or below its threshold.
 * `t` is the picture's thresholds(), for a caller that has them already.
 */
export declare function binarise(image: Luminance, t?: Thresholds): BitImage;
export declare function invert(image: BitImage): BitImage;
/**
 * The picture shrunk by `f` (decoder step 9): floor(width / f) by
 * floor(height / f) pixels, each the mean of an f x f square, rounded as
 * (sum + floor(f * f / 2)) div (f * f). Columns and rows past the last whole
 * square are dropped.
 */
export declare function shrink(image: Luminance, f: number): Luminance;
/**
 * shrink() for the factors 2, 4 and 8, from one pass over the picture: the
 * 2 x 2 sums, then sums of those, each made when first asked for. A square
 * of 4 is four squares of 2 and holds the same pixels, so the sums, and the
 * pictures, are the ones shrink() gives.
 */
export declare function reductions(image: Luminance): (f: 2 | 4 | 8) => Luminance;
