removed files from the old exercise
@@ -1,33 +0,0 @@
|
||||
clear; close all; clc;
|
||||
|
||||
N = 128;
|
||||
n = 0:N-1;
|
||||
w1 = 2*pi*0.1;
|
||||
w2 = 2*pi*0.15;
|
||||
x = cos(w1*n) + cos(w2*n);
|
||||
|
||||
% a)
|
||||
|
||||
X = fft(x);
|
||||
magX = abs(X);
|
||||
|
||||
figure;
|
||||
stem(n, magX, 'filled');
|
||||
xlabel('n');
|
||||
ylabel('|X[n]|');
|
||||
title('Magnitude Spectrum of x[n]');
|
||||
grid on;
|
||||
|
||||
% b)
|
||||
|
||||
y = hamming(N)' .* x;
|
||||
|
||||
Y = fft(y);
|
||||
magY = abs(Y);
|
||||
|
||||
figure;
|
||||
stem(n, magY, 'filled');
|
||||
xlabel('n');
|
||||
ylabel('|Y[n]|');
|
||||
title('Magnitude Spectrum of y[n]');
|
||||
grid on;
|
||||
@@ -1,33 +0,0 @@
|
||||
clc;
|
||||
clear;
|
||||
close all;
|
||||
|
||||
%% Parameters
|
||||
f1 = 2000;
|
||||
f2 = 4000;
|
||||
f3 = 6000;
|
||||
|
||||
f3_rec = -3000
|
||||
|
||||
%% Time vectors
|
||||
t=0:1e-6:1e-3;
|
||||
|
||||
%% Signals
|
||||
x = 1+0.5*cos(2*pi*f1*t)+2*sin(2*pi*f2*t)+sin(2*pi*f3*t);
|
||||
x1 = 1+0.5*cos(2*pi*f1*t)+2*sin(2*pi*f2*t)+sin(2*pi*f3_rec*t);
|
||||
x2 = 1+0.5*cos(2*pi*f1*t)+2*sin(2*pi*f2*t)+sin(2*pi*f3*t);
|
||||
|
||||
%% Plot
|
||||
figure
|
||||
hold on
|
||||
|
||||
plot(t, x, 'b', 'LineWidth', 1.5)
|
||||
plot(t, x1, 'r', 'LineWidth', 1.5)
|
||||
plot(t, x2, '--g', 'LineWidth', 1.5)
|
||||
|
||||
grid on
|
||||
|
||||
xlabel('Time (ms)')
|
||||
ylabel('x(t)')
|
||||
|
||||
legend('x(t)', 'x1(t)', 'x2(t)');
|
||||
@@ -1,51 +0,0 @@
|
||||
clear; close all; clc;
|
||||
|
||||
img = imread('pavian.png'); % Choose any picture you like here
|
||||
img = rgb2gray(img);
|
||||
|
||||
%% Display image
|
||||
figure; subplot(131);
|
||||
imshow(img);
|
||||
title('Ausgangsbild');
|
||||
|
||||
%% FFT
|
||||
fft2d = fft2(img);
|
||||
|
||||
% Display the FFT image.
|
||||
subplot(132);
|
||||
imshow(log(fftshift(abs(fft2d))), []);
|
||||
title('2D-FFT');
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%
|
||||
|
||||
% Approach: We want to remove the low frequencies (high pass filter) to
|
||||
% keep the areas of the image where the lightness changes relative to
|
||||
% nearby pixels
|
||||
|
||||
% Shift FFT so low frequencies are in the center
|
||||
F = fftshift(fft2d);
|
||||
|
||||
% Get image size
|
||||
[M, N] = size(F);
|
||||
|
||||
% Radius of how much to remove
|
||||
r = 25;
|
||||
|
||||
% We cut out the center of the fft low frequencies
|
||||
H = ones(M, N);
|
||||
H(M/2-r:M/2+r, N/2-r:N/2+r) = 0;
|
||||
|
||||
% Apply filter
|
||||
F_filtered = F .* H;
|
||||
|
||||
% Shift back
|
||||
fft2d = ifftshift(F_filtered);
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
%% IFFT to obtain filtered image
|
||||
img_filtered = ifft2(fft2d);
|
||||
subplot(133);
|
||||
imshow(real(img_filtered), []);
|
||||
title('Gefiltertes Ausgangssignal');
|
||||
BIN
fig/fig1.1.png
|
Before Width: | Height: | Size: 29 KiB |
BIN
fig/fig1.2.png
|
Before Width: | Height: | Size: 23 KiB |
BIN
fig/fig1.3.png
|
Before Width: | Height: | Size: 102 KiB |
BIN
fig/fig1.4.png
|
Before Width: | Height: | Size: 50 KiB |
BIN
fig/fig3.1.png
|
Before Width: | Height: | Size: 354 KiB |
BIN
fig/fig4.1.png
|
Before Width: | Height: | Size: 31 KiB |
BIN
fig/fig4.2.png
|
Before Width: | Height: | Size: 28 KiB |