I need to deform an image moving one (or more) point from its position to a different destination.
The following example (generated using warp function in Photoshop) clarifies the problem:
In the example point (100,100) has been stretched to the new position (200,200).
I tried using the warp solutions provided by OpenCV:
input_pts = np.float32([(100, 100), (400, 100), (400, 400), (100, 400)])
output_pts = np.float32([(200, 200), (400, 100), (400, 400), (100, 400)])
(M, _) = cv2.findHomography(input_pts, output_pts)
# M = cv2.getPerspectiveTransform(input_pts, output_pts)
out = cv2.warpPerspective(test_img, M, (500, 500), flags=cv2.INTER_AREA)
and
input_pts = np.float32([(100, 100), (400, 100), (100, 400)])
output_pts = np.float32([(200, 200), (400, 100), (100, 400)])
M = cv2.getAffineTransform(input_pts, output_pts)
out = cv2.warpAffine(test_img.copy(), M, (500, 500), flags=cv2.INTER_LINEAR)
without success.
I'm wondering what could be the best approach to solve this problem.