image-js
Version:
Image processing and manipulation in JavaScript
37 lines • 1.58 kB
TypeScript
import type { Point } from '../utils/geometry/points.js';
/**
* Options for getPerspectiveWarp function.
*/
export interface GetPerspectiveWarpOptions {
/**
* The horizontal dimension (in pixels) of the final rectified rectangular image.
*/
width?: number;
/**
* The vertical dimension (in pixels) of the final rectified rectangular image.
*/
height?: number;
}
/**
* Returns result matrix along with vertical and horizontal dimensions for the rectangular image.
*/
export type GetPerspectiveWarpData = Required<GetPerspectiveWarpOptions> & {
matrix: number[][];
};
/**
* Computes a perspective transformation matrix to rectify a quadrilateral region into a rectangle.
*
* This function takes four corner points of a quadrilateral (e.g., a document photographed at an angle) and calculates the transformation matrix needed to "unwarp" it into a rectangular image.
* The output dimensions can be specified or calculated automatically based on the input geometry.
* @param pts - 4 reference corners.
* @param options - PerspectiveWarpOptions.
* @returns - Matrix from 4 points.
*/
export declare function getPerspectiveWarp(pts: Point[], options?: GetPerspectiveWarpOptions): GetPerspectiveWarpData;
/**
* Sorts 4 points in order =>[top-left,top-right,bottom-right,bottom-left]. Input points must be in clockwise or counter-clockwise order.
* @param pts - Array of 4 points.
* @returns Sorted array of 4 points.
*/
export declare function order4Points(pts: Point[]): Point[];
//# sourceMappingURL=getPerspectiveWarp.d.ts.map