Docsity

CSE152 Assignment 1: Computer Vision - Perspective Transform and Image Manipulation, Exercises of Computer Vision

Toggle sidebar
bg1
CSE152 – Intro to Computer Vision – Assignment #1
Instructor: Prof. David Kriegman.
http://cseweb.ucsd.edu/classes/sp12/cse152-a
Due Date: Thu. April 26, 2012.
Instructions:
•Attempt all questions
•Turn in a hard copy in class, which should include answers to all paper-and-pencil questions
and a printout of all matlab code and results for programming questions
•In addition, email a copy of your code with the subject CSE152 Assignment 1 to sbran-
[email protected]. Attach code as a zip or tar file.
Questions:
1. [35 points] Suppose we are viewing a square with vertices P1= (−1,−1,0)T,P2= (1,−1,0)T,
P3= (1,1,0)T,P4= (−1,1,0)Tin world coordinates. Consider a perspective view of this
square acquired from pinhole camera A.
(a) [3 points] Assume camera Ahas an image plane at a focal length of fA= 1 in front of
the camera. Find the intrinsic parameter matrix AMin for camera A.
(b) [5 points] Assume the camera is positioned (relative to world coordinates) by applying
a rotation of π
4radians about the x-axis, followed by a rotation of −π
4radians about the
y-axis. The center of the camera is placed such that the origin is at AO= (0, .5,2)Tin
the coordinate system of camera A. Compute the 3X3 rotation matrix ARgoing from
world coordinates to camera coordinates.
(c) [4 points] Compute the 4X4 extrinsic parameter matrix AMex defining a rigid trans-
formation going from world coordinates to camera coordinates. Use it to solve for the
vertices of the square in camera A’s coordinate system AP1,AP2,AP3,AP4.
(d) [5 points] Combine the results of the previous two parts to solve for the 3X4 perspective
camera projection matrix. Use it to solve for the pro jection of P1,P2,P3,P4onto the
image plane and plot their locations (e.g., draw a quadrilateral depicting the projected
image of the square).
(e) [4 points] Solve for the 2 vanishing points of the projected image of the square.
(f) [4 points] Find the affine projection matrix that approximates the perspective projection
from part c and corresponds to an expansion about the center of the square AO. Compute
the projected locations of AP1,AP2,AP3,AP4under this affine camera model, and plot
the results as in part d.
(g) [4 points] Find the orthographic projection matrix that approximates the perspective
projection from part c and corresponds to an expansion about the center of the square
AO. Compute the projected locations of AP1,AP2,AP3,AP4under this orthographic
camera model, and plot the results as in part d.
(h) [6 points] Suppose we were to move the camera to a new configuration B, obtained by
zooming in the camera while panning out, such that the projected image of the square
stays roughly the same size. This effect is achieved by setting the focal length of the
camera to fB= 10, while moving the camera further away to BO= (0,5,20)T. Are the
affine and orthographic camera approximations more appropriate for camera configuration
1
pf2

Partial preview of the text

Download CSE152 Assignment 1: Computer Vision - Perspective Transform and Image Manipulation and more Exercises Computer Vision in PDF only on Docsity!

CSE152 – Intro to Computer Vision – Assignment # Instructor: Prof. David Kriegman. http://cseweb.ucsd.edu/classes/sp12/cse152-a Due Date: Thu. April 26, 2012.

Instructions:

  • Attempt all questions
  • Turn in a hard copy in class, which should include answers to all paper-and-pencil questions and a printout of all matlab code and results for programming questions
  • In addition, email a copy of your code with the subject CSE152 Assignment 1 to sbran- [email protected]. Attach code as a zip or tar file.

Questions:

  1. [35 points] Suppose we are viewing a square with vertices P 1 = (− 1 , − 1 , 0)T^ , P 2 = (1, − 1 , 0)T^ , P 3 = (1, 1 , 0)T^ , P 4 = (− 1 , 1 , 0)T^ in world coordinates. Consider a perspective view of this square acquired from pinhole camera A.

(a) [3 points] Assume camera A has an image plane at a focal length of fA = 1 in front of the camera. Find the intrinsic parameter matrix AMin for camera A. (b) [5 points] Assume the camera is positioned (relative to world coordinates) by applying a rotation of π 4 radians about the x-axis, followed by a rotation of − π 4 radians about the y-axis. The center of the camera is placed such that the origin is at AO = (0,. 5 , 2)T^ in the coordinate system of camera A. Compute the 3X3 rotation matrix AR going from world coordinates to camera coordinates. (c) [4 points] Compute the 4X4 extrinsic parameter matrix AMex defining a rigid trans- formation going from world coordinates to camera coordinates. Use it to solve for the vertices of the square in camera A’s coordinate system AP 1 , AP 2 , AP 3 , AP 4. (d) [5 points] Combine the results of the previous two parts to solve for the 3X4 perspective camera projection matrix. Use it to solve for the projection of P 1 , P 2 , P 3 , P 4 onto the image plane and plot their locations (e.g., draw a quadrilateral depicting the projected image of the square). (e) [4 points] Solve for the 2 vanishing points of the projected image of the square. (f) [4 points] Find the affine projection matrix that approximates the perspective projection from part c and corresponds to an expansion about the center of the square AO. Compute the projected locations of AP 1 , AP 2 , AP 3 , AP 4 under this affine camera model, and plot the results as in part d. (g) [4 points] Find the orthographic projection matrix that approximates the perspective projection from part c and corresponds to an expansion about the center of the square AO. Compute the projected locations of AP 1 ,^

AP

2 ,^

AP

3 ,^

AP

4 under this orthographic camera model, and plot the results as in part d. (h) [6 points] Suppose we were to move the camera to a new configuration B, obtained by zooming in the camera while panning out, such that the projected image of the square stays roughly the same size. This effect is achieved by setting the focal length of the camera to fB = 10, while moving the camera further away to B^ O = (0, 5 , 20)T^. Are the affine and orthographic camera approximations more appropriate for camera configuration

A or for camera configuration B (a camera approximation is appropriate if the projection onto the image plane is similar to the projection using the full perspective camera matrix)? Explain your answer.

  1. [15 points] Write a matlab function imgOut = TransformHSV(imgIn,θ,s,v) to manipulate the color of an image in HSV color space. The function should do the following: - Convert the image from RGB to HSV color space - Apply a clockwise rotation of the hue channel by θ degrees - Multiply the saturation channel by s - Multiply the value channel by v - Convert the transformed HSV image back into RGB color space

DO NOT use the built-in rgb2hsv or hsv2rgb functions in Matlab, except to compare your re- sults. Test your function on the image color.bmp, and generate results for TransformHSV(img,90,1,1), TransformHSV(img,0,.3,1), TransformHSV(img,0,1,.3). Include the generated images in your writeup.

  1. [20 points] In this exercise, we will render the image of a cone-like surface illuminated by two different point light sources using a Lambertian reflectance model. The surface is defined by the equation z =

x^2 + 4y^2 for all x^2 + 4y^2 ≤ 1. The first point light source is located at (1, 1 , 2)T^ , and the second light source is located at (− 1 , − 1 , 2)T^. Both light sources have intensity .5. The ellipsoid surface is Lambertian, and has an albedo of 1 throughout the entire surface. Write a Matlab function that renders a 401x201 image of the surface with pixels corresponding to the locations x = −1 : 0.005 : 1 and y = −.5 : 0.005 : .5. Set all pixels outside the circle x^2 + 4y^2 > 1 equal to 0. Generate an image of the surface that is illuminated by just the first light source, a second image that is illuminated by just the second light source, and a 3rd image that is illuminated by both light sources. Include all 3 output images in your writeup.