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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Tonee Bayhon
Tonee Bayhon

Written by Tonee Bayhon

Am I doing this data science thing right?

No responses yet