Find your data in the assignment '00data: Your data' in the submission system; the image daliborka_01.jpg
and the set of seven 2D points U2
.
Make Matlab script hw01.m
to do the following.
daliborka_01.jpg
image into your Matlab workspace and display it. Use subfig.m
utility in Tools repository. img = imread( 'daliborka_01.jpg' ); % load the image subfig(2,2,1); % create a new figure image( img ); % display the image, keep axes visible axis image % display it with square pixels
[x,y] = ginput(7)
u
. Every point is represented by a column vector of coordinates, i.e. u(:,1)
are coordinates of the first point.
round
function to convert fractional coordinates into integer coordinates). Use the following colors in the following order: red = [255 0 0], green = [0 255 0], blue = [0 0 255], magenta = [255 0 255], cyan = [0 255 255], yellow = [255 255 0], white = [255 255 255] to colorize the respective seven points. The colors are defined by their R, G, B values: color = [R G B]. The order of colors must correspond to the order of points in the matrix u
. Store the modified bitmap image as a file 01_daliborka_points.png
.imwrite(img, '01_daliborka_points.png');
A
(2×3 matrix) from n given points u2
to points u
as a function A = estimate_A( u2, u ); % u2 and u are 2xn matrices
nchoosek(1:n, 3 )
Ai
(exactly).
U
and points U2
transferred by A
. Find the maximum error over the correspondences.
Ai
select the one A
that has the maximum transfer error minimal.
n = size(u,2); % number of columns
u
using the same colors as above, and 100× magnified transfer errors for the best A
as red lines.% assume we have points in ''u'' and points ''u2'' transferred by ''A'' in ''ux'' e = 100 * ( ux - u ); % magnified error displacements ... hold on % to plot over the image ... plot( u(1,4), u(2,4), 'o', 'linewidth', 2, 'color', 'magenta' ) % the 4-th point plot( [ u(1,4) u(1,4)+e(1,4) ], [ u(2,4) u(2,4)+e(2,4) ], 'r-', 'linewidth', 2 ); % the 4-th error ... hold off(If the errors are too large, it is optional to plot them magnified only 10×, as blue lines).
01_daliborka_errs.pdf
. Use fig2pdf.m
utility in Tools repository.fig2pdf( gcf, '01_daliborka_errs.pdf' )
01_points.mat
.save( '01_points.mat', 'u', 'A' )
Upload an archive containing the following files:
01_points.mat
01_daliborka_points.png
01_daliborka_errs.pdf
estimate_A.m
hw01.m
- your Matlab implementation. It makes all required figures, output files and prints.
Note: All files must be in the same directory. Do not use any subdirectories.