Combining two warpAffine, shift and rotate image

asked 2019-01-30 03:10:32 -0600

Hi,

I currently use the following sequence of code to first shift an image, then rotate the same image:

    M = np.float32([[1,0,20],[0,1,10]])
    shifted = cv2.warpAffine(img,M,(y_size,x_size), flags=cv2.INTER_LANCZOS4)
    center_of_rot = (500, 500)
    M = cv2.getRotationMatrix2D(center_of_rot, 1.23, 1.0)
    rotated = cv2.warpAffine(shifted, M, (y_size, x_size), flags=cv2.INTER_LANCZOS4)

I think it's possible to somehow multiply the two matrices and only do one operation instead of two warpAffine, I am looking for some guidance since I really suck at math.

Thanks!

edit retag flag offensive close merge delete