Open jcphill opened 1 year ago
I need this as well!
I made a fork and copied some lines to the behavior for projective and affine transformations. There is some repeated code, but this should make it so that the output is properly cropped. This doesn't affect the behavior of transformHTMLElement, though. https://github.com/Xiione/Homography.js
I would like to extract a rectangular tile from a source image via a projective transformation based on mapping the corners of the tile to points in the source image, i.e., destiny points [[0, 0], [0, h], [w, 0], [w, h]].
The current implementation will return an output image that contains the entire input image with dimensions based on the input image dimensions. What I want is a output image of h rows by w pixels that matches the bounding box of the destiny points.
This behavior is already provided for piecewise affine transformations by the second case of _induceBestObjectiveWidthAndHeight() at https://github.com/Eric-Canas/Homography.js/blob/1200c41d713cc40007b3b71c8ab9b4214d837e84/Homography.js#L706C1-L710