A Top-Down Approach: Using Projective Transformation for a Different View

Tonee Bayhon
2 min readFeb 1, 2021

--

In this article, I will tackle how to project an image from a perspective to a top-down view. We will use the following book cover for this purpose:

This should be straight forward. We will identify the corners of the book in the original image. We go about this counter-clockwise starting from the upper-left corner:

We input those x,y coordinates and should be as follows:

src = np.array([2654, 92,
677, 686,
1118, 1781,
3401, 779,
]).reshape((4, 2))

Then we will determine the coordinates by which we will project our original image onto:

dst = np.array([0, 0,
0, 2000,
1100, 2000,
1100, 0,
]).reshape((4, 2))

Fortunately, we have an skimage package that will automatically transform this image for us:

from skimage import transform
tform = transform.estimate_transform('projective', src, dst)

Finally, we will transform our image:

tf_img = transform.warp(dune, tform.inverse)
fig, ax = plt.subplots(figsize=(10,15))
ax.imshow(tf_img[:,:1100,:]);

Neat, right? Where can we use this technique? I’ve seen others use this to project chess boards or basketball courts in order to do some analysis. Personally, for someone who takes pictures, I find that I could use this to take pictures at an angle to avoid glare, reflections, and shadow. Then, I can transform them to a projection that I like. Whatever purpose you’d like to use it for, we already have the simplest tools at our disposal without resorting to graphics editing applications.

--

--