LESSON

# Using Homographies in MATLAB

#### Transcript

Let's use the previous MATLAB example to illustrate some principles around homographies. First thing I'm going to do is to close these 2 windows and create a new variable called Little P, which contains the projection of those world points. Here we go.

So, this is the image plane coordinates of the points as viewed by that camera up in the air. The world points P are a set of 3 dimensional coordinates. Note that the Z coordinate of all of these points is equal to 0. So, I'm going to create a new vector, just P and it's just the first 2 rows and it contains all of the columns. So, this is Q. So, Q are a set of coordinates of points on the ground plane that the camera is looking at and P is a set of pixel coordinates in the view from that camera up in the air and now that I have these 2 sets of corresponding 2-D points, I can compute N homography. I'll just use the homography function and I pass in the first set of points, little P and the second set of points, Q and here is the homography matrix that's been computed.

Now that I have the homography H, I can apply it to a single point or to multiple points. To help me with that, there is a toolbox helper function called 'homtrans' which applies the homography H to the set of pixels P. This is our image plane coordinates and the result is the set of coordinates of points on the ground.

We have mapped a set of points in the image whose coordinates are measured in units of pixels into a set of points on the ground plane and there coordinates are described in units of meters. Similarly, I can use the inverse of the homography matrix to go the other way.

So now, I pass in the coordinates of the points and the ground and the result is the set of image plane coordinates. So, the homography is really useful tool if I want to map the coordinates of points between one plane and another.

We use MATLAB and some Toolbox functions to compute an homography and also apply it. ### Professor Peter Corke

Professor of Robotic Vision at QUT and Director of the Australian Centre for Robotic Vision (ACRV). Peter is also a Fellow of the IEEE, a senior Fellow of the Higher Education Academy, and on the editorial board of several robotics research journals.

### Skill level

This content assumes an understanding of high school level mathematics; for example, trigonometry, algebra, calculus, physics (optics) and experience with MATLAB command line and programming, for example workspace, variables, arrays, types, functions and classes.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9406669,"math_prob":0.87268114,"size":2287,"snap":"2021-43-2021-49","text_gpt3_token_len":502,"char_repetition_ratio":0.17345598,"word_repetition_ratio":0.043373495,"special_character_ratio":0.20900743,"punctuation_ratio":0.09287257,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98782784,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-28T19:57:18Z\",\"WARC-Record-ID\":\"<urn:uuid:fdace7d5-9eb1-4dc2-9f61-2d897a6f1798>\",\"Content-Length\":\"41443\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:dceefaee-2a7c-4c0c-a1ea-f4a8cb6b2ae0>\",\"WARC-Concurrent-To\":\"<urn:uuid:74878523-83e8-42f6-a1cb-4c56b320cd45>\",\"WARC-IP-Address\":\"111.223.225.2\",\"WARC-Target-URI\":\"https://robotacademy.net.au/lesson/using-homographies-in-matlab/\",\"WARC-Payload-Digest\":\"sha1:FQ5DITBBMADXXKQXBC45ET2LSEV7YHYB\",\"WARC-Block-Digest\":\"sha1:NF4MT3GHSJ4BGXU7YUBXAZGAPHPIHRQ3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323588526.57_warc_CC-MAIN-20211028193601-20211028223601-00563.warc.gz\"}"}