18-793 Image and Video Processing Fall 2019
Solution to Homework 1
Submission instructions.
• Submissions are due on Thursday 09/05 at 7.00pm ET == 4.00pm PT
• Please upload scans of your solution in GradeScope (via Canvas)
• You are expected to upload solutions to each problem separately. Please ensure that your scans are readable.
Instructions
• Please solve all non-MATLAB problems using only paper and pen, without resorting to
a computer.
• Please show all necessary steps to get the final answer. However, there is no need to be overly elaborate. Crisp and complete answers.
• For all MATLAB problems, include all code written to generate solutions.
• Please post all questions on the discussion board on the Piazza course website, rather than email-ing the course staff. This will allow other students with the same question to see the response and any ensuing discussion.
• If you feel some information is missing, you are welcome to make reasonable assumptions and proceed. Sometimes the omissions are intentional. Needless to say, only reasonable assumptions will be accepted.
1. (4.9 pts) (Quantum efficiency and photon noise) Suppose that the average rate of arrival
of light at a pixel (x, y) and wavelength λ is given as P (x, y, λ) photons/second. The average electron count at the pixel is given as
average e(x, y) = T0
where T0 is the exposure time in seconds and Q(·) is the quantum efficiency (QE) of the
pixel.
However this is the average or expected number of photons. In practice, any actual measurement is a sampling of a Poisson random variable whose parameter is the average value. That is, a measurement of electron count at a pixel is given as
e(x, y) ∼ Poisson T0 P (x, y, λ)Q(λ)dλ .
P (x, y, λ)Q(λ)dλ,
2
Solution to Homework 1
When the pixel has a full well capacity of F electrons, the measurement morphs to
e(x, y) ∼ min F, Poisson T0 P (x, y, λ)Q(λ)dλ .
In HW1 P1.mat you are given a matrix P(·,·,·) and QE for a RGB sensor, which can be treated as having three sensors with different QE profiles.
Assume a full well capacity F = 1000e−. For the following exposure values, produce 3-color images observed by the sensor.
(a) T0 = 100μs (b) T0 = 1ms
(c) T0 = 10ms (d) T0 = 100ms
(e) T0 = 1000ms (f) T0 = 10s
Deliverables: 1) MATLAB code for implementing the solution. 2) Six photographs, one each for the six subparts above.
Notes:
(a) Choose an ADC gain for each RGB image such that its maximum value is 1. Also
make sure that the simulated image is of type double or single.
(b) You can assume that the ADC has no quantization effect on the image.
(c) Since displays have a nonlinear response, you need to gamma correct the image for better visualization. Use the following command for that:
>> imshow( (max(0, img)).∧(1/2.2));
(d) Visualize your image using imshow command and imwrite to save them
(e) The commands poissrnd or random are useful for simulating Poisson measurements
Solution to Homework 1 3
Solution 1: MATLAB Code:
1 clear all
2 close all
3
4 %% Loading data
5 load HW1 P1.mat
6
7 %% Setting up constants
8 F = 1000;
9 siz = size(P);
10
11 %%
12 P = reshape(P, [], siz(3));
13 QE = [R response(:) G response(:) B response(:) ];
14
15 for 16
17
18
19
20
21
22
23
24
25 end
T0 = [0.0001 0.001 0.01 0.1 1 10]
PP = reshape(P*QE*T0, siz(1), siz(2), 3);
I = random(‘poiss’, PP);
I = min(F, I);
I = I/max(1, max(I(:)));
figure
imshow(I.ˆ(1/2.2));
4
Solution to Homework 1
Images generated:
(a) T = 0.0001s
(b) T = 0.001s
(c) T = 0.01s
(d) T = 0.1s
(e) T = 1s
(f) T = 10s
Figure 1: Images generated with different exposure time
Solution to Homework 1 5 2. (5 pts) (Signal to noise ratio)
There are two sources of noise when acquiring an image:
• the photon noise, that captures the inherent variability in photon arrivals, that is modeled as a Poisson random variable,
• the readout noise, capturing thermal effects in the electronics, that is modeled with a Gaussian random variable.
You can assume that these two sources of noise are statistically independent.
For simplicity we are going to assume that there are no quantization related artifacts. We are going to assume an ideal sensor with a quantum efficiency of 1 and infinite well capacity.
Under these assumptions, the measurements made can be written as i ∼ Poisson(λT0) + n,
where λ is the expected arrival rate of photons, T0 is the exposure time, and n is the readout noise whose variance is σ2. We will measure the signal to noise ratio as
|E [i]|2 SNR = var(i) .
(Part a) Derive an expression for the SNR in terms of σ2, λ and T0.
(Partb)LetT0 =1s. Letσ=100e. Letsvaryλfrom1to105 inmultiplesof10(so 1, 10, 100, 103, 104, 105). Plot the variance of i as a function of λ (do use log scale for both axes using loglog command). Interpret and explain the plot.
(Part c) Repeat part b, except plot the SNR instead as a function of λ (do use log scale for both axes using loglog command). Interpret and explain the plot.
6
Solution to Homework 1
(1)
(2)
(3)
Solution 2:
(Part a) We first find the expected value of i:
E[i] = E[P oisson(λT0) + n] = E[P oisson(λT0)]
= λT0
Notice that expected valued of the Gaussian readout noise is 0. To find var(i):
var(i) = var(P oisson(λT0) + n) = λT0 + σ2
Finally, to get the SNR expression in terms of λ, T0, andσ2: SNR= E[i]2
(Part b) MATLAB Code:
var(i) = λ 2 T 02
λT0 + σ2
1 clear all
2 close all
3
4 %% Setup the values
5 sigma = 100;
6 L = [1 10 100 1000 10000];
7
8 %% Graph the curves
9 v=L+sigmaˆ2;
10 figure
11 loglog(L, v)
12 grid on;
13 title(‘Variation of var(i) with respect Lambda’);
14 xlabel(‘Lambda’);
15 ylabel(‘var(i)’);
16
17 SNR = L.ˆ2 ./ (L + sigmaˆ2);
18 figure
19 loglog(L, SNR)
20 grid on;
21 title(‘Variation of SNR with respect Lambda’);
22 xlabel(‘Lambda’);
23 ylabel(‘SNR’);
Solution to Homework 1 7 Plotting variance of i as a function of λ:
Figure 2: Variance of i with respect to λ
Interpretation: As we increase the rate of arrival of photons, the variance of i increases linearly (but exponentially in log domain). This means that increasing the rate of arrival of photons will increase the variance.
8
Solution to Homework 1
(Part c) Plotting SNR as a function of λ:
Figure 3: SNR with respect to λ
Interpretation: As we increase the rate of arrival of photons, the SNR increases almost linearly in the log scale. This means that higher arrival rate of photons provide a better SNR.