Convert a GrayImage to a Base64 JPEG with a quadrilateral and optional anchors drawn on it.
If transform is provided, anchors are projected from template space (relative to width=100) to image space.
Apply perspective transform to the entire image.
Maps src_img to a destination image of size width x height
using the transform pt (which maps Src -> Dst).
We iterate Dst pixels, map backwards to Src using transform_inverse (coeff_inv), and sample.