Last active
April 16, 2021 02:07
-
-
Save leandromoreira/9bb7b519173ba5158b5b4b213c46d8fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% it creates a simple gray image (4x4) | |
I = [255, 255, 30, 100 | |
255, 50, 90, 20 | |
70, 70, 20, 10 | |
100, 20, 10, 0]; | |
% it converts it to grayscale | |
I = mat2gray(I); | |
% shows it | |
imshow(I); | |
IDFT = []; | |
% DFT | |
N1 = 4; | |
N2 = 4; | |
e = exp(1); | |
% DFT implementation | |
for u=0:(N1-1) | |
for v=0:(N2-1) | |
% X(u, v) | |
DFT = 0; | |
for x=0:(N1-1) | |
for y=0:(N2-1) | |
Intensity = I(x+1,y+1); | |
FirstDimension = e ^ (-1i*( (2*pi/N1) * u * x)); | |
SecondDimension = e ^ (-1i*( (2*pi/N2) * v * y)); | |
DFT = DFT + (Intensity * FirstDimension * SecondDimension); | |
end | |
end | |
IDFT(u+1, v+1) = DFT; | |
end | |
end | |
IDFT | |
%MATLAB_FFT=fft2(I) | |
surf(log(abs(fftshift(IDFT)))); | |
InverseI=abs(ifft2((IDFT))) | |
I |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://share.pho.to/ARkgK