Professional Documents
Culture Documents
1
1
504111543
Computer Vision Homework - 2
1)
function [ g ] = p( x, y )
% Calculate p or p_s from dz/dx.
g = (110-x)/sqrt(10^4-((x-110)^2+(y-110)^2));
end
--------------------------------------------------------------------------function [ g ] = q( x, y )
% Calculate q or q_s from dz/dy.
g = (110-y)/sqrt(10^4-((x-110)^2+(y-110)^2));
end
--------------------------------------------------------------------------function [ y ] = kok( x, t )
if t == 1
y = (sqrt(100*100-(x-110)*(x-110))+110);
else
y = (110-sqrt(100*100-(x-110)*(x-110)));
end
end
The images of sphere that illuminated from different locations. The center of the circle is (110,110).
2)
a)
=
0
0
b)
1
0
0 cos
0 0 sin
0
1 0 0
*=
0 5
&
sin 10
$ % ' )
(
cos 0
1
0
0
+
=
c)
function [ u, v] = get_x_y( U, V, W, f, s_x, s_y, o_x, o_y )
d = 45*pi/180;
r_t = [1
0
0
0 cos(d) -sin(d)
0 sin(d) cos(d)
0
0
0
5;
10;
0;
1];
i = [U V W 1]';
p_p = [f/s_x
0
0
0
o_x 0;
f/s_y o_y 0;
0
1
0];
r = r_t*i;
r = p_p*r;
u = r(1)/r(3);
v = r(2)/r(3);
end
--------------------------------------------------------------------------%
U
V
W
Coordinates
= [5 15 15
= [0 0 0
= [20 20 30
of
5
0
30
Cube
5 5 15 15];
10 10 10 10];
30 20 20 30];
figure;
%Parameters
f = 15; s_x = 2; s_y = 2; o_x = 0; o_y = 10;
axis([0 20 0 20]);
hold on
for i=1:8
x(2)],
x(4)],
x(6)],
x(3)],
x(7)],
x(4)],
x(8)],
x(5)],
x(6)],
x(8)],
x(7)],
x(8)],
[y(1),
[y(1),
[y(1),
[y(2),
[y(2),
[y(3),
[y(3),
[y(4),
[y(5),
[y(5),
[y(6),
[y(7),
y(2)]);
y(4)]);
y(6)]);
y(3)]);
y(7)]);
y(4)]);
y(8)]);
y(5)]);
y(6)]);
y(8)]);
y(7)]);
y(8)]);