I want to warp a document image on a deformed mesh as follows:
A semi-correct approach is described here: link
However, i am in particular interested in an invertible mapping, ideally, a one way operation (without having to pad the image, as it would be the case when using cv2.remap).
Example procedure:
Step 1: Obtain deformed mesh (for a given image src)
xx_deformed = xx + vx
yy_deformed = yy + vy
where vx and vy describes the deformation (see link above).
Step 2: Map image on mesh:
warped_img = one_way_operation(src, xx_deformed, yy_deformed)
Step 3: undo deformation:
xx_inv = xx - vx
yy_inv = yy - vy
unwarped_img = one_way_operation(warped_img, xx_inv, yy_inv)
Expected result:
assert(img == unwarped_img)
Is there an elegant way to achieve this goal? I am grateful for any hint.