COMP4901L Homework Assignment 4 Physics-based vision solved


Category: You will receive a download link of the .ZIP file upon Payment


5/5 - (1 vote)

1 Overview
The purpose of this homework is to go over the topics of radiometry, reflectance, photometric stereo,
and color. Given the short nature of this homework, and unlike previous assignments, it consists
of a few smaller and independent problems, rather than a sequence of related problems.
1.1 Lambertian albedo (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(vˆi
, vˆo) = ρ/π. Using
conservation of energy, prove that 0 ≤ ρ ≤ 1.
1.2 Foreshortening (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.
1. Calculate the solid angle subtended by dA at points X1 and X2.
2. Calculate the irradiance E incident on the plane at points X1 and X2, and calculate the ratio
1.3 Simple rendering (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 ij−th surface
point, as observed by an orthographic camera with view direction (0, 0, 1).
• Use quiver to display the x-y components of the normal field and print the result.
• 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.
• 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?
In your write-up: Please include figures for the normal visualizations and the three renderings
of the bunny, as well as answers to the associated questions.
1.4 Photometric stereo (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.
1. 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.)
Figure 1: A few bunny renderings.
2. 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.
3. 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.
4. The function integrate frankot.m in the matlab folder 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.
Figure 2: Two views of the recovered face shape.
In your write-up: Include figures for the recovered normals and albedo, the re-rendered face
images, and the final reconstructed surface, as well as answers to all associated questions.
1.5 Dichromatic reflectance (30 points)
A reasonable reflectance model for dielectric (non-conducting) surfaces is the so-called dichromatic
model, according to which the spectral BRDF is written as a linear combination of a Lambertian
diffuse component fd and a wavelength-independent specular component fs:
f(λ, ωˆi
, ωˆo) = fd(λ) + fs( ˆωi
, ωˆo)
When we image a scene consisting of such surfaces under a directional light source with spectral
power distribution I(λ) and direction ˆl = (lx, ly, lz), the RGB values C~ ((C~R(~u), C~G(~u), C~B(~u))
recorded at pixel ~u = (u, v) can be expressed as
C~ (~u) = h~n(~u),
~d(~u) + gs(~u)~s,
where h·, ·i, is the inner product operation, ˆn(~u) is the surface normal at the scene point imaged
by pixel ~u, and gs(~u) is a function that depends non-linearly on ˆn(~u) (as well as view and lighting
directions) through the specular component of the BRDF.
1. Assuming that the spectral sensitivities of a camera’s three filters are (cR(λ), cG(λ), cB(λ))
and that the BRDF at the surface point imaged at pixel ~u is f(λ, ωˆi(~u), ωˆo(~u)) = fd(λ, ~u) +
fs( ˆωi(~u), ωˆo(~u)), write expressions for the elements of the diffuse color vectors ~d(~u) and the
source color vector ~s.
2. Suppose you are given two unit-length three-vectors ˆr1 and ˆr2 that are orthogonal to ~s. Show
that the two-channel image1 given by the per-pixel inner products (hrˆ1, Cˆ(ˆu)i,hrˆ2, Cˆ(ˆu)i):
(a) does not depend on the specular components of the BRDFs, fs( ˆωi(~u), ωˆo(~u)).
(b) depends linearly on the surface normals, ˆn(~u).
3. Show that the two properties from part (b) are also satisfied by the single-channel (grayscale)
image J(~u) = ||J~(~u)||.
4. Write a function imout=makeLambertian(im,s) that takes an RGB image im and a source
color vector s and computes the grayscale image J(~u) from part (c). Run this function on the
image fruitbowl.png from the data folder using s=[0.6257 0.5678 0.5349] and submit
the results. Explain in three sentences or less why imout might be more useful than im to
a computer vision system. Note that a simple way to numerically obtain a set of N − 1
unit-length vectors that are orthogonal to N-vector is to use the null command in Matlab.
1.6 Color metamers (Extra Credit) (20 points)
Two distinct spectral distributions are metameric if they induce the same responses in the cones
of a human retina. Said another way, metamers are distinct spectral distributions that map to the
same tristimulus vector (in CIE XYZ or any other linear color space). If you own a grocery store
that sells bananas, it is in your interest to choose your light source so that overripe bananas look
that same as those in their prime. That is, you want the light reflected from ripe and overripe
bananas to be metameric.
Let ~f and ~g be N ×1 vectors that come from discretizing the spectral reflectance functions f(λ)
and g(λ) of ripe and overripe bananas, respectively. (For example, if we sampled from 400nm to
700nm in increments of 10nm, we’d have N = 31.) Let R be the 3 × N matrix whose rows are
obtained by discretizing the CIE XYZ color matching functions.
1This image can have pixels with negative values, and these negative values are just as useful as the positive ones.
Figure 3: Left: Original color image. Right: Image converted to grayscale with specularities
1. Show that the tristimulus vector C~
f = (Xf , Yf , Zf ) for a ripe banana f(λ) under illuminant
spectrum l(λ) can be written as C~
f = Lf
~l where Lf is a 3×N matrix and ~l is the discretization
of l(λ).
2. Given ~f and ~g, a good way to choose ~l is to minimize the distance, in a least-squares sense, of
the two resulting tristimulus vectors. Write an expression for the Euclidean distance between
the two tristimulus vectors in terms of Lf , its counterpart Lg , and ~l.
3. Write a Matlab function T=metamericLight(f,g) that finds the temperature T in the closed
interval T ∈ [2500K, 10, 000K], with precision ±50K, of the blackbody radiator that minimizes the distance derived in part (b). The spectral power distribution for a blackbody
radiator (see FP Sect. 6.1.2) with temperature T is
LT (λ) ∝
λT − 1
where a = 1.4388 × 10−2
(m · K).
4. The file bananas.mat from the data folder contains two spectral reflectance functions, ripe
and overripe, which are sampled in 10nm increments from 400nm to 700nm and correspond
roughly to the data from Day 5 and Day 7 of Figure 4. Use your function to find the optimal
metamer-inducing blackbody temperature for these materials, and plot the distance as a
function of temperature, and the spectral power distribution of the best illuminant. You
will need to use the file ciexyz64 1.csv from the data folder, which contains tabulated data
for the CIE XYZ color matching functions. In Matlab, you can read data from a CSV file
using the csvread command. Remember to normalize the spectral power distributions of
blackbody radiators in a way that is meaningful for the minimization criterion of part (b).
Figure 4: Relative spectral reflectance curves for different colors of bananas during ripening. Day
five is the first day of shelf life. (Taken without permission from Morita et al., “Evaluation of
Change in Quality of Ripening Bananas Using Light Reflectance Technique,” in Memoirs of the
Faculty of Agriculture, Kagoshima University, 1992.)