This project consisted really of 3 parts: Calculating the H-Matrix (which is the matrix used to transform image A to the shape of image B, or a square for rectification), transforming the actual rectification (Where we align the image to a square), and actually stitching the images together.
To calculate the H-Matrix, I used this equation.
I always use the 4 corners of some square or rectangle shape for my x, y points, although you could use as many as you want. Here are some examples of rectified images:
To transform the image, I used scipy.transform.warp() which was said on the piazza. This multiplied the original image's pixels by the H-Matrix in order to find the new image's place. For my 3 images, say image A, image B, and image C, I warped image A -> image B, and image C -> B so that they all combine with image B.
In this example, I transformed one image of a coffee machine so that the screen of image A became the same shape as the screen in image B.
cropped:
cropped:
cropped: