Skip to content

Add imcrop and warp_affine(try_large_warp=True)

Matthew Bernstein requested to merge add_imcrop_large_warp into master

Added an option to let warp_affine bypass this error when calling cv2.warpAffine on images with a dimension >= 32767. This is done by splitting the image into pieces, warping, and then merging them back together. This is not intended to be identical to the output of a non-piecewise warp; there will be small edge artifacts, though it's more than good enough for visualization purposes.

Also exposed a subtask as the option warp_affine(dsize='max'): when transform would bring image pixels into negative coordinates so they cannot be displayed, add a translation to it so that all pixels remain positive and none are discarded.

Also took the opportunity to write the cropping function I've always wanted. imcrop takes a string code using the about option to automatically figure out 9-point crops (center, corner, edge). It also handles negative coordinates, coordinates outside the image bounds, and floating-point coordinates, padding the image when necessary so that dsize is always respected.

Edited by Matthew Bernstein

Merge request reports