image-js
Version:
Image processing and manipulation in JavaScript
61 lines • 2.12 kB
TypeScript
import type { Image } from '../Image.js';
import type { Mask } from '../Mask.js';
export declare const ThresholdAlgorithm: {
readonly HUANG: "huang";
readonly INTERMODES: "intermodes";
readonly ISODATA: "isodata";
readonly LI: "li";
readonly MAX_ENTROPY: "maxEntropy";
readonly MEAN: "mean";
readonly MIN_ERROR: "minError";
readonly MINIMUM: "minimum";
readonly MOMENTS: "moments";
readonly OTSU: "otsu";
readonly PERCENTILE: "percentile";
readonly RENYI_ENTROPY: "renyiEntropy";
readonly SHANBHAG: "shanbhag";
readonly TRIANGLE: "triangle";
readonly YEN: "yen";
};
export type ThresholdAlgorithm = (typeof ThresholdAlgorithm)[keyof typeof ThresholdAlgorithm];
interface ThresholdOptionsBase {
/**
* Number of slots that histogram can have. Slots must be a power of 2.
*/
slots?: number;
/**
* Image to use as the output.
*/
out?: Mask;
}
export interface ThresholdOptionsThreshold extends ThresholdOptionsBase {
/**
* Threshold value that should be used. Threshold is a value in range [0,1],
* which will be interpreted as a percentage of image.maxValue.
*/
threshold: number;
}
export interface ThresholdOptionsAlgorithm extends ThresholdOptionsBase {
/**
* Specify a function to computes the threshold value.
* @default `'otsu'`
*/
algorithm?: ThresholdAlgorithm;
}
export type ThresholdOptions = ThresholdOptionsThreshold | ThresholdOptionsAlgorithm;
/**
* Compute threshold value for an image using the specified algorithm.
* @param image - The grey image.
* @param options - Threshold options.
* @returns The threshold value for the image.
*/
export declare function computeThreshold(image: Image, options?: ThresholdOptionsAlgorithm): number;
/**
* Create a black and white image based on a threshold value.
* @param image - The grey image to convert.
* @param options - Threshold options.
* @returns The resulting mask.
*/
export declare function threshold(image: Image, options?: ThresholdOptions): Mask;
export {};
//# sourceMappingURL=threshold.d.ts.map