ppu-ocv
Version:
A type-safe, modular, chainable image processing library built on top of OpenCV.js with a fluent API leveraging pipeline processing.
36 lines (35 loc) • 1.34 kB
TypeScript
/**
* This module provides utility functions for analyzing image properties.
* !IMPORTANT: Ensure ImageProcessor.initRuntime() has been called successfully
* once before using any functions from this module.
*/
import type { Canvas } from "./index";
/**
* Options for calculating mean Lab lightness.
*/
export interface CalculateMeanLightnessOptions {
/** The canvas containing the image to be processed. */
canvas: Canvas;
/** The target dimensions for analysis (resizes internally). */
dimension: {
width: number;
height: number;
};
}
/**
* Calculates the mean normalized lightness of an image using the L channel of the Lab color space.
* Lightness is normalized based on the image's own maximum lightness value before averaging.
*
* @param options - Configuration options.
* @returns Mean normalized lightness (0-1).
* @throws Error if OpenCV operations fail.
*/
export declare function calculateMeanNormalizedLabLightness(options: CalculateMeanLightnessOptions): number;
/**
* Calculates the mean pixel value of the image after converting it to grayscale.
*
* @param canvas - The source canvas to be processed.
* @returns Mean grayscale value (typically 0-255).
* @throws Error if OpenCV operations fail.
*/
export declare function calculateMeanGrayscaleValue(canvas: Canvas): number;