程序代写代做代考 18-793 Image and Video Processing

18-793 Image and Video Processing
Submission instructions.
Fall 2020
• Submissions are due on Thursday 09/17 at 10.00pm ET
• Please upload scans of your solution in GradeScope (via Canvas) • Please ensure that your scans are readable.
Homework 2
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 coding 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. Let x(t) = e−t2/2σ2. Derive an expression for X(f), the (CT)FT of x(t). Hint: Start with the following property of Gaussians.
dx(t)=− t x(t) dt σ2
Take FT of both sides, use properties of FTs to simplify.
2. (Gabor on paper) You are given the following 1D Fourier pair.
−t2/2σ2 FT √ −2π2f2σ2 e ←−−→ 2 π σ 2 e
We can define a Gabor function by parameterizing it using the signal bandwidth σ, orientation θ, and frequency v0.
gσ,v0,θ(x, y) = e−(x2+y2)/2σ2 e−j2πv0(x cos θ+y sin θ) Derive the expression for Gσ,v0,θ, the 2D FT of gσ,v0,θ.

2 Homework 2 3. (Gabor on MATLAB (or Python if you take that route))
As discussed in class, a Gabor function by parameterizing it using the signal bandwidth σ, orientation θ, and frequency v0.
gσ,v0,θ(x, y) = e−(x2+y2)/2σ2 e−j2πv0(x cos θ+y sin θ)
Do the following in MATLAB.
Step 1. Load the grayscale image test.png (the image can be downloaded from piazza).
Step 2. Write a MATLAB function that provides the Gabor filter as defined above. The function should take in 3 inputs, σ, θ and v0, and return the Gabor filter for values of x and y in a range of −25 to 25, each; hence, each filter is of size 51 × 51 pixels.
Step 3. Convolve the Gabor filter with the image in Step 1 and display the magnitude of the resulting output. You can use conv2 or the imfilter command.
Deliverables: MATLAB code for constructing the gabor filter, and magnitude of the convolved image from Step 3 for the following Gabor functions.
• σ=5,v0 =1/5,θ=π/2
• σ=5,v0 =1/5,θ=π/4
• σ=5,v0 =1/5,θ=0
• σ=10,v0 =1/5,θ=2π/3
4. (Line integral) Suppose that you are given an image, denoted as I(x, y). The line-integral along an inclination θ◦ is defined as (see diagram below):
􏰀
τ
􏰀
τ
Write a MATLAB script to compute the line-integral as defined above. Outside of basic commands, you are restricted to commands like meshgrid and interp2. Commands relat- ing to image rotation (imrotate), resize (imresize), and radon transforms (radon) are not to be used.
Use the camerman image in MATLAB as your test image; the cameraman image is an inbuilt image in matlab. You can load it into your workspace by using the command:
>> img = imread(’cameraman.tif’); img = double(img)/255;
Deliverable: Plot lθ for the θ = 0, 90◦, 45◦, 37.5◦. (and as always, your code.) Some points to remember
lθ(α) = =
I[xα(τ),yα(τ)]dτ
I (α cos(θ) − τ sin(θ), α sin(θ) + τ cos(θ)) dτ

Homework 2 3
• Note that, while the above descriptions are for continuous images, in reality we only have samples of the image as a 2D matrix and so we will work with samples by replacing the integration with appropriate summations.
• Choose range for α and τ appropriately.
• You can assume that the value of the image outside the defined range is zero.
• Revisit the first recitation if you need a refresher on how to use meshgrid and interp2
5. (For fun — no credit, no need to upload) (Playing with phase and magnitude) This problem needs to be done in MATLAB.
Step 1. Load two grayscale images of your choice of the same size. You are welcome to pick MATLAB’s test images. Let’s refer to these images as f1 and f2.
Step 2. Compute the 2D FT of both images, F1 and F2, using the fft2 command.
Step 3. Create two new signals (in Fourier domain) by swapping the magnitude spectra
of the FTs of F1 and F2. That is, create two new signals defined as G1 and G2 such that G1 = |F2|ej∠F1 , G2 = |F1|ej∠F2
Step 4. Using the ifft2 command, invert the FTs of G1 and G2, to obtain the images g1 and g2, respectively. The imaginary component of these images should be very close to zero. Verify this. (Briefly explain why we expect the imaginary component to be zero and also why it is often not exactly zero). You can use the real command to remove the imaginary components once you have verified that is tiny.
Step 5. Using the command imshow (or imagesc) display the images g1 and g2.
Step 6. Describe the images g1 and g2 and provide a brief explanation for your observa- tions.
𝑦 𝜏𝛼
𝜃
x↵ ⌧ ,y↵ ⌧ = ↵cos✓⌧sin✓,↵sin✓+⌧cos✓ 𝑥
𝛼
`✓ ↵

4 Homework 2
Step 7. Repeat Steps 1-6, but instead of swapping the magnitude spectra, set the magni- tude spectra to 1. That is,
G1 = ej∠F1 , G2 = ej∠F2