ECE 280/Imaging Lab 2
This page serves as a supplement to the second Digital Image Processing Labs for ECE 280. It has been updated for the Spring 2021 semester. This worksheet assumes you have done everything necessary to successfully complete Imaging Lab 1, including working with MATLAB and understanding basic image processing commands in MATLAB.
Corrections / Clarifications to the Handout
- None yet
Links
Examples
The following sections will contain both the example programs given in the lab as well as the image or images they produce. You should still type these into your own version of MATLAB to make sure you are getting the same answers. These are provided so you can compare what you get with what we think you should get.
Example 1: Signal Analysis
Since the point of Exercise 1 is to write the code to perform the calculations in this example, we'l.. just move right along to...
Example 2: MATLAB fft
x = [1, 5, 2, 3, 1]
X = fft(x)
yields
[12.0000 + 0.0000i, -1.1910 - 3.2164i, -2.3090 - 3.3022i, -2.3090 + 3.3022i, -1.1910 + 3.2164i
Example 3: MATLAB fft2 and ifft2
clear
x1 = [1, 1; 1, 1]
x2 = [1, 1; 0, 0]
x3 = [1, 0; 1, 0]
x4 = [1, 0; 0, 1]
X1=fft2(x1)
X2=fft2(x2)
X3=fft2(x3)
X4=fft2(x4)
x1a = ifft2(X1)
x2a = ifft2(X2)
x3a = ifft2(X3)
x4a = ifft2(X4)
yields:
x1 =
1 1
1 1
x2 =
1 1
0 0
x3 =
1 0
1 0
x4 =
1 0
0 1
X1 =
4 0
0 0
X2 =
2 0
2 0
X3 =
2 2
0 0
X4 =
2 0
0 2
x1a =
1 1
1 1
x2a =
1 1
0 0
x3a =
1 0
1 0
x4a =
1 0
0 1
Example 4: One-Dimensional Frequency Mapping
M = 15;
for m=0:((M+1)/2-1)
Xm = zeros(M,1);
Xm(m+1) = M/2;
if m==0
Xm(m+1)= M;
else
Xm(M+1-m) = M/2;
end
x = ifft(Xm);
figure(m+1); clf
bar(x)
end
Example 4a: One-Dimensional Frequency Mapping (Odd Symmetry)
M = 15;
for m=0:((M+1)/2-1)
Xm = zeros(M,1);
Xm(m+1) = M/2/j;
if m==0
Xm(m+1)= M;
else
Xm(M+1-m) = -M/2/j;
end
x = ifft(Xm);
figure(m+1); clf
bar(x)
end
Example 5: MATLAB fft2 and ifft2 for Even Dimensions
x1 = [4, 5, 8, 1; 8, 4, 3, 1; 8, 7, 7, 5; 2, 7, 7, 10]
fft2(x1)
yields
$$ \begin{align*} X1 &= \begin{bmatrix} 87 & -3-6j & 7 & -3+6j\\ -9+10j & -11-12j & {\color{Blue}3-14j} & 1-8j\\ 3 & -3-6j & 11 & -3+6j\\ -9+10j & 1+8j & 3+14j & -11+12j \end{bmatrix} \end{align*} $$