Docsity

Programming Assignment 1 - Computer Vision 1 | CAP 5416, Assignments of Computer Science

Toggle sidebar
bg1
CAP5416, CAP4410: Programming Assignment #1
Due Date: 9/24/08
Guidelines
•Use C,C++ or MATLAB to solve the programming problems.
•Do not use built-in MATLAB functions to solve substantial portions
of the problems.
•Simple image format like PGM is recommended. See resources web
page for details.
•Supplementary material for this assignment will be posted online.
•Add a short report with a summary of results with necessary images.
•Organize report, code, and results in a folder and upload a zipped
archive (.zip only) online at the course site. (CourseTool)
Programming Exercises
1. Transforming Images
Apply a rigid transform T(X), to a given 2D gray level image. Let
X(i, j) and Y(i, j ) be spatial coordinates of pixels in the given image
Isand its warped image It, respectively. In order to compute the
image intensity in the warped image It, we need to perform an inverse
transform for each pixel in the warped image to Is. The transformed
point however might not lie on the image grid in Is. So, use bilinear
interpolation L, to estimate intensity at Is(X).
T(X) = R∗X+t=Y(1)
⇒X=T−1(Y(i, j)) (2)
It(i, j) = L(Is(X)) (3)
(a) Write a program to rigidly transform an image. Perform counter-
clockwise rotation around the image center. Use the following specifi-
cation:
1
pf3
pf4
pf5

Partial preview of the text

Download Programming Assignment 1 - Computer Vision 1 | CAP 5416 and more Assignments Computer Science in PDF only on Docsity!

CAP5416, CAP4410: Programming Assignment

Due Date: 9/24/

Guidelines

  • Use C,C++ or MATLAB to solve the programming problems.
  • Do not use built-in MATLAB functions to solve substantial portions of the problems.
  • Simple image format like PGM is recommended. See resources web page for details.
  • Supplementary material for this assignment will be posted online.
  • Add a short report with a summary of results with necessary images.
  • Organize report, code, and results in a folder and upload a zipped archive (.zip only) online at the course site. (CourseTool)

Programming Exercises

  1. Transforming Images Apply a rigid transform T (X), to a given 2D gray level image. Let X(i, j) and Y (i, j) be spatial coordinates of pixels in the given image Is and its warped image It, respectively. In order to compute the image intensity in the warped image It, we need to perform an inverse transform for each pixel in the warped image to Is. The transformed point however might not lie on the image grid in Is. So, use bilinear interpolation L, to estimate intensity at Is(X).

T (X) = R ∗ X + t = Y (1) ⇒ X = T −^1 (Y (i, j)) (2) It(i, j) = L(Is(X)) (3)

(a) Write a program to rigidly transform an image. Perform counter- clockwise rotation around the image center. Use the following specifi- cation:

C/C++ : ./rigidTransform input.pgm output.pgm angle TrX TrY MATLAB: rigidTransform( inputFile, outputFile, angle, TrX ,TrY) Units : angle (degrees), translation (pixel unit)

(b) Take any image of your choice, rotate it by 35◦^ and translate it by (− 1. 5 , 5 .5) pixels.

  1. Camera Calibration

Estimate the perspective projection matrix M of a camera given a set of object points, Pi = (xi, yi, zi, 1), and their image coordinates, (ui, vi). Let the rows of 3 × 4 camera matrix M be denoted as mt 1 , mt 2 , and mt 3. The relation between the object points in the 3D scene and their image coordinates becomes:

ui = mt 1 Pi/mt 3 Pi vi = mt 2 Pi/mt 3 Pi (4) ⇒ (m 1 − uim 3 )tPi = 0, (m 2 − vim 3 )tPi = 0 (5)

The given set of n point pairs result in 2n homogenous linear equations (Eq-5) in the 12 unknown elements of M, expressed as Pm = 0, where

P ≡

P 1 t 0 t^ −u 1 P 1 t 0 t^ P 1 t −v 1 P 1 t

......... P (^) nt 0 t^ −unP (^) nt 0 t^ P (^) nt −vnP (^) nt

m ≡

m 1 m 2 m 3

Since each point pair yields two constraints, we need at least six such pairs to solve for m using a linear least squares method. The normal- ized eigen vector of PtP corresponding to the smallest eigen value will minimize |Pm|^2. Refer sections 2.2.2, 3.1.1, and 3.2.1 (Forsyth and Ponce). Write a program to solve for M, given a set of n point pairs. Using the recovered matrix M to project Pi onto the image plane and compute mean square error between actual and estimated 2D image points. Code Formats - C,C++ : ./camCalib Pts2D.txt Pts3D.txt MATLAB : camCalib( ’Pts2D.txt’, ’Pts3D.txt’ ) Data : Pts2D.txt, Pts3D.txt files are posted online. Output: < print 3 x 4 M matrix >

Figure 1: Images of building before and after perspective correction. Source:f-spot.com

that there is sufficient overlap between the two images, to let the user select at least four correspondences from the two images. C/C++ : ./prspCorrection input.pgm output.pgm (OR) C/C++ (without GUI) : ./prspCorrection input.pgm output.pgm x1 y x2 y2 x3 y3 x4 y MATLAB: prspCorrection( inputImageFile, outputImageFile )

  1. Computing Fundamental Matrix Fundamental matrix F relates any pair of corresponding points {Xs, Xt} in two images as Xtt F Xs = 0, owing to the epipolar geometry. It can be used to estimate dense correspondence between images. The con- straint on F is linear in the unknown entries of F. Since F is singular, it has 8 degrees of freedom. Thus at least 8 correspondences are re- quired to compute F. Build a system of homogenous linear equations, Af = 0 , from 8 or more point pairs and use the method in Problem- to solve for f. However, F thus obtained is not guaranteed to be sin- gular. This can be enforced by replacing the least singular value in the SVD of F with zero. See section 11.2 (Hartley and Zisserman) for details. Program Specifications : Take two images with considerable overlap, collect point correspondences with an user-interface and compute F. Draw epipolar lines in either images for the initial set of points. Draw a circle of 3 pixel radius around epipole in each image. Print the average orthogonal distance between the epipolar lines and their correspond-

ing points. Note that when F is accurate, epipolar line should pass through the corresponding point. Comment on results in the report.

C/C++ : Use GLUT/OpenGL, QT, GTK, etc. to display images and collect correspondences. ./getFmatrix img1.pgm img2.pgm MATLAB : use ginput() to read mouse-clicks. getFmatrix( img1File, img2File )