ISTA 352 - Images: Past, Present, and Future - Fall 2012

Assignment Two

Due: Late (*) Friday, Sept 21.

(*) "Late" means that the instructor might start grading by 8AM Saturday. Once the instructor starts grading, no more assignments will be accepted.

10 points

This assignment should be done individually

 



You can do the programming parts of this assignment in any language you like, although if your results are anomalous, and the grader does not speak the language you use, they may be less able to quickly figure out what the problem is and give you reasonable part marks.

 

Regardless of what language you use, please follow the instructions linked here  carefully.

 


Deliverables

Deliverables within questions are flagged with ($).

 

This assignment has 8 regular questions followed by 3 optional challenge problems which can be exchanged and/or done for modest bonus points. The first 7 problems are all worth one point, and the 8th is worth 3 points for a total of 10 points.

 


 

  1. A particular 4x4 matrix, M, maps (1, 2, 3, 4) to (3, -1, 4, -5), and (5, 6, 7, 8) to (2, -7, 1,  -8).  Before reading further think a bit about what information you have. You should understand that these two pieces of information constrain what M is, but does not uniquely determine it. However, they do tell you how any linear combination of those two vectors transform.  (If you are not confident about what “linear combination” means, you should look it up (Google is there to help!)).

a) What is M*(10, 20, 30, 40)? Don’t forget to explain ($)

b) What is M*(15,  26, 37, 48)? Don’t forget to explain ($)

 

  1. One transformation that we did not cover in class is “sheer”. In 2D there are 2 kinds: sheer along X and sheer along Y with the forms:

 

 

Provide a picture of shape like the “house” used in the slides to visualize transformations undergoing a sheer along X with a=1 and a=2 ($). You may find working with a piece of graph paper helpful either as a draft, or as the actual result (if you like, you could take a picture of it with your phone and put this into your document). Regardless of how you created it, your figure should have a caption that explains what the sheer does using the figure as an example.

  1. Create an image with dimensions 600x600 with all pixels initially white. In the following, we will use a coordinate system in the image with the origin at the center (300,300), with the usual mathematical conventions of X increasing to the right and Y increasing to the top. Image pixels and Matlab array indexes do not (necessarily) work this way, and part of the goal of this exercise is to get used to this. The figure linked here may help. In what follows, we will use x and y for our mathematical coordinate system, and i and j for image coordinates.

 

We will represent points at (i,j) with a 21x21 size block of color covering the range of (i-10:i+10,j-10:j+10). Your program needs to handle points outside the range of the image. If the box is are near the edge you need to  “clip” the parts of the box that are not visible. If the box is completely outside the image, then you will not show them at all, but your program needs to remember about them incase some operation moves them back into the window.  You'll need to re-use this box-drawing code several times in this assignment, so modular programming practices suggest that you would want to make it a function.  The inputs might be (a) an image to draw into, (b) the (i,j) coordinate of the box center, and (c) the RGB triple for the color of the box.  The function's output would be the image with the box drawn into it.

 

This file contains the points to draw in terms of (x,y). Create a matrix in homogeneous coordinates that transforms them to (i,j). Put the matrix with some explanation as to how you produced it into your writeup ($).  Use the matrix to write the boxes for the points onto your 600x600 white image. Your boxes should be blue. Include the resulting image in your PDF ($).

  1. (Continuing with the previous question)

a) Create a single matrix in homogenous coordinates that scales the X values by 3/5 and the Y values by 5/4. Put this matrix in your writeup with some explanation ($). Transform the points with this matrix and write them onto the image in green (the blue boxes should be there also).

 

b) Create a single matrix in homogenous coordinates that scales the X values by 3/5 and the Y values by 5/4 as before, and then rotates them by 30 degrees. Put this matrix in your writeup with some explanation ($). Transform the points with this matrix and write them onto the image in cyan (0,255,255) (the previous boxes should be there also).

 

c) Create a single matrix in homogenous coordinates that does all the previous operations and also translates them by the vector (100, -200). Put this matrix in your writeup with some explanation ($). Transform the points with this matrix and write them onto the image in magenta (255,255,0) (the previous boxes should be there also).

 

Put the single image with four sets of points into your write up with an informative caption ($). You will need to write at least a few sentences, perhaps 5 or 6 of them.

  1. Consider an orthogonal transformation, O, that rotates the X-axis unit vector (i-hat) so that it is parallel to the vector from the origin to (-2,7). Similarly, suppose that it also maps the Y-axis unit vector (j-hat) so that it is parallel to the vector from the origin to (-7,-2). (You may want to take a moment to convince yourself that there are only two possible places for the Y axis to go, given where the X axis went and that O is orthogonal, but things are less constrained in 3D, so the general approach is to think in terms of where all the axis go, as I have done here for the 2D case).

 

Provide such a matrix in your writeup (with explanation) ($) as well as the verification that that it is orthogonal and that it satisfies the mapping requirements ($). You can cut and paste Matlab output for some of this if you like, but don’t forget explanation.

  1. Visualizing the answer for the previous question.

You will reuse the transformation just found, O, but you will need to promote it to a 3x3 matrix for homogenous coordinates if you have not done so already.

a) Use your orthogonal transformation, O, to provide a single matrix that applies the transformation, O, in (x,y) followed by the mapping to image coordinates on our 600x600 canvas. Put this matrix in your write up with explanation about where it came from ($). Use this matrix to compute the transformed locations of the points from question three. Show these as blocks in red, together with blocks for the original points in blue.

b) Add a scaled (by 30) version of the X and Y unit axes vector segments, as well as the two vectors (-2, 7) and (-7,-2), both drawn as line segments. To do this, first get the scaled and transformed image coordinates, and then get the intermediate points and plot them. To get the intermediate points, you can use someone else’s implementation of Bresenham’s algorithm if you like. A Matlab one that I got from the web with a few tweaks is conveniently copied here. (Remember that if a dot-m file (e.g. bresenham.m) is in your working directory, you should be able to do “help [function]” (e.g., “help bresenham”)).  Draw the axes segments should be green, and the two other segments cyan (0,255,255) ($).

c) Finally, using the matrix from (a), and your line drawing capability to draw the rotation of the scaled (by 30) X and Y unit axes vector segments as magenta (255,0,255). Do they end up where you expect? Provide the final image, with an informative caption, to your writeup ($).

  1. Camera coordinates (2D).

The 2D camera shown in this figure is very self-centered. It wants everything in its own coordinate system. Develop a single matrix that transforms points in (x,y) to camera centric coordinates ($). Apply your matrix to the camera axis points (6,12), (4,11), and (7,10) as a check ($). Do this points end up where you expect? Explain ($). Finally compute the camera coordinates for the point with (x,y) coordinates (-5,-9)   ($).

  1. (++, i.e., this question is worth 3 points). Below are links to two images. Dump these into a into a drawing program, and draw enough lines over the image to make a case that the image is either approximately in perspective or not. (Have a look at the building examples in the lecture notes if this is not making sense). You should understand and state your assumptions, and explain your reasoning. To get you started: You can assume that that the chandelier is perfectly symmetric.

Your deliverables ($)  should be a PDF with your images with lines drawn on them and an explanation of what you conclude.

For the chandelier image, you must also put small circles (i.e., "dots") that make it clear where the lines come from. In the case of the building, it will be generally clear how you drew the line, but in the case of the chandelier image this will not be the case. Help the grader by showing the points that you are drawing lines through. If you color code the points and/or lines, this will help provide points of reference in your explanation.

Note this assignment requires some judgments about what reasonable deviations from the model are, as well as the accuracy of your line drawings. Good cases can be made in both examples, but you need to be careful and skeptical.

Image one

Image two

Challenge problems

Challenge problems are not required, but can be exchanged for non-challenge problems, or done for modest extra credit. They provide flexibility for students who are especially interested in the subject, and who are comfortable with their understanding of the basics. They can be difficult and often require some math skills that are not pre-requisite for this course. I recommend being careful about spending too much time on them.

 

  1. (*) Show that matrix multiplication maps line segments to line segments.   (Hint)

 

  1. (**) In class we learned that under perspective projection, parallel lines (generally) converge to a point. Can you prove this?

 

  1. (**) We also learned that under perspective projection, the vanishing points for sets of coplaner parallel lines are colinear. Can you prove this?

 

What to Hand In

Consult the instructions linked here for conventions for preparing and handing in assignments. In 2012, hand in assignments via email to Kyle Simek (ksimek@email.arizona.edu).