Starting from:

$30

Assignment 7  Computer Vision

Assignment 7
 Computer Vision

The purpose of this homework is to reinforce the topics of radiometry, reflectance, and photometric stereo.
Forsyth and Ponce’s chapter on Radiometry will be helpful for this assignment.
1. (10 points) For Lambertian surfaces, the BRDF is a constant function of the input and output directions. For such a material, we often describe the reflectance in terms of its albedo, which is given the
symbol ρ. For a Lambertian surface, the BRDF and albedo are related by fr(ˆvi
, ˆvo) = ρ/π. Using
conservation of energy, prove that 0 ≤ ρ ≤ 1.
2. (10 points) Obtain the file bunny.mat from the data folder of this assignment and load it into Matlab.
There is a single variable in this file; the variable N is an h×w ×3 array of surface normals. N(i,j,1),
N(i,j,2), and N(i,j,3) are the x, y, and z components of the surface normal at the ijth surface
point, as observed by an orthographic camera with view direction (0, 0, 1). Submit all code for this
question.
(a) Use quiver to display the x-y components of the normal field and print the result. (See the
example in Hints and Information below.)
(b) Compute and display the radiance emitted from each point assuming Lambertian reflectance and
constant albedo (equal to one), with a distant point light source in direction ˆs = (0, 0, 1), by
typing imshow(N(:,:,3)). Explain why this works.
(c) Compute, display and print the emitted radiance for three different light source directions which
are rotated i) 45◦ up, ii) 45◦
right, and iii) 75◦
right from the frontal direction ˆs = (0, 0, 1). Can
you spot errors in the field of surface normals? What are the illumination effects being ignored
in this calculation of scene radiance?
3. (10 points) A small Lambertian source dA is centered at P and emits radiance L. The orientation of
this patch is the same as that of a plane containing two points, X1 and X2. The point X1 is the point
on this plane that is closest to P, and the distance from P to X1 is D as shown.
(a) Calculate the solid angle subtended by dA at points X1 and X2.
(b) Calculate the irradiance E incident on the plane at points X1 and X2, and calculate the ratio
E(X1)/E(X2).
4. (20 points) The data folder of this assignment contains a set of seven photometric stereo images along
with a MAT file containing the light source vectors. You can load the images into Matlab and convert
them to double, grayscale format using rgb2gray and im2double.
1
(a) Estimate the surface normal and grayscale albedo for each pixel. Submit your Matlab code as
well as the results (using imshow for the albedo values and quiver for the surface normals.)
(b) Note the poor estimates of the albedo (and surface normal) in the area surrounding the nostrils.
What is the source of this error? Describe one method for finding a better estimate of this
information from these seven images.
(c) Use the recovered surface information to predict what the person would look like (in grayscale) if
illuminated from direction ˆs = (0.58, −0.58, −0.58) and from direction ˆs = (−0.58, −0.58, −0.58).
Submit your results and your code.
(d) The function integrate frankot.m in the .MLX file can be used to recover a surface z(x, y) from
your surface normals ˆn(x, y), and the surface can be displayed in Matlab. Display and submit
two views of the recovered shape.
Hints and Information
• The following code demonstrates one way to use the quiver function.
% vect_x is an HxW array of x-components
% vect_y is an HxW array of y-components
figure; % create a new figure
quiver(vect_x,vect_y,‘.’);
axis image; % set unit aspect ratio between x and y axes
axis ij; % place origin in top-left corner (like an image)
Note that the vector components should be displayed at a suitable resolution. For example, the figure
below shows the x-y components of a field of surface normals at three different resolutions. The plot in
the middle provides the best summary of the surface shape. The resolution can be adjusted by plotting
only every n
th element as in quiver(vect x(1:n:end,1:n:end),vect y(1:n:end,1:n:end),‘.’).
• When computing the output radiance from a field of surface normals ˆn(x, y) illuminated from direction
ˆs, clip negative values using L = max(0, ˆn · ˆs).
• We are commonly faced with a situation in which we need to evaluate the integral over the hemisphere
of the function cos θ, where 0 ≤ θπ is the angular distance between the radial line through a point on
the hemisphere and the radial line through its apex.
Z

cos θdω
2
The first step is to define a parameterization of the hemisphere using spherical coordinates, and the
second is to write an element of the solid angle dω in terms of this parameterization. As shown in
almost any introductory calculus book (and Forsyth & Ponce), we can write this integral as
Z 2π
0
Z π/2
0
cos θ sin θdθdφ,
which is straightforward to evaluate using the appropriate trigonometric identity.
• The following code demonstrates one way to display a surface in Matlab.
% Z is an HxW array of surface depths
figure;
s=surf(-Z); % use the ‘-’ sign since our Z-axis points down
% output s is a ‘handle’ for the surface plot
% adjust axis
axis image; axis off;
% change surface properties using SET
set(s,’facecolor’,[.5 .5 .5],’edgecolor’,’none’);
% add a light to the axis for visual effect
l=camlight;
% enable mouse-guided rotation
rotate3d on
When making a figure in Matlab, each object (figure, axe, line, image, surface, etc.) is given a numerical
ID or handle that can be used to adjust its properties. You can use these, for example, to turn grid
lines on and off, change the color of the axis, change the color of a line in a graph, change the shininess
of a plotted surface, and so on. The handle s in the previous example can be used to change the
properties of the surface. To see a list of its current properties type get(s), and to change these
properties use set(s) as in the example above. Check the Matlab online documentation to find out
what these properties mean. (Type helpdesk on your local machine, or search for “Matlab helpdesk”
in a web browser and navigate to Handle Graphics Object Properties.)
3

More products