BogoToBogo
  • Home
  • About
  • Big Data
  • Machine Learning
  • AngularJS
  • Python
  • C++
  • go
  • DevOps
  • Kubernetes
  • Algorithms
  • More...
    • Qt 5
    • Linux
    • FFmpeg
    • Matlab
    • Django 1.8
    • Ruby On Rails
    • HTML5 & CSS

Matlab Tutorial - Introduction to FFT & DFT

Matlab_logo.png




Bookmark and Share





bogotobogo.com site search:




FFT

A Fast Fourier transform (FFT) is a fast computational algorithm to compute the discrete Fourier transform (DFT) and its inverse. The Fast Fourier Transform does not refer to a new or different type of Fourier transform. It refers to a very efficient algorithm for computing the DFT.

The time takes to perform a DFT on a computer depends primarily on the number of multiplications involved ($O (N^2))$ while FFT only needs $Nlog_2(N)$.

The central insight which leads to this algorithm is the realization that a discrete Fourier transform of a sequence of $N$ points can be written in terms of two discrete Fourier transforms of length $N/2$. Therefore, if $N$ is a power of 2, it is possible to recursively apply this decomposition.




bogotobogo.com site search:

Basic Concept

FFT_DFT_Diagram.png


FFT functions in Matlab

Here are the functions related to FFT and DFT. The cases actually using these functions are in other pages.

  1. The function $dft()$ computes the discrete Fourier transform. Define a vector $x$ and compute the DFT using the command:
    X = dft(x)
    
    The first element in $X$ corresponds to the value of $X(0)$.
  2. $idft()$ computes the inverse discrete Fourier transform. Define a vector $X$ and compute the IDFT using the command
    x = idft(X)
    
    The first element of the resulting vector $x$ is $x[0]$.
  3. For a more efficient but less obvious program, the discrete Fourier transform can be computed using the function $fft()$ which performs a Fast Fourier Transform of a sequence of numbers. To compute the FFT of a sequence $x[n]$ which is stored in the vector $x$, use the command
    X = fft(x)
    
    If we use this way, the $fft()$ is interchangeable with the command $dft()$. For more computational efficiency, the length of the vector $x$ should be equal to the power of 2, that is 64, 128, 512, etc. The vector $x$ can be padded with zeros to make it have an appropriate length. MATLAB does this automatically by using the following command where $N$ is defined to be an power of 2:
    X = fft(x,N);
    
    The longer the length of $x$, the finer the grid will be for the FFT. Due to a wrap around effect, only the first $N/2$ points of the FFT have any meaning.
  4. The $ifft()$ function computes the inverse Fourier transform:
    x = ifft(X);
    
  5. The FFT can be used to approximate the Fourier transform of a continuous-time signal. A continuous-time signal $x(t)$ is sampled with a period of $T$ seconds, then the DFT is computed for the sampled signal. The resulting amplitude must be scaled and the corresponding frequency determined. An M-file that approximates the Fourier Transform of a sampled continuous-time signal can be downloaded from contfft.m. Let a vector $x $be defined as the sampled continuous-time signal $x(t)$ and let $T$ be the sampling time.
    [X,w] = contfft(x,T);
    
    The outputs are the Fourier transform stored in the vector $X$ and the corresponding frequency vector $w$.







Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization

YouTubeMy YouTube channel

Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







Matlab Image and Video Processing



Vectors and Matrices

m-Files (Scripts)

For loop

Indexing and masking

Vectors and arrays with audio files

Manipulating Audio I

Manipulating Audio II

Introduction to FFT & DFT

Discrete Fourier Transform (DFT)



Digital Image Processing 2 - RGB image & indexed image

Digital Image Processing 3 - Grayscale image I

Digital Image Processing 4 - Grayscale image II (image data type and bit-plane)

Digital Image Processing 5 - Histogram equalization

Digital Image Processing 6 - Image Filter (Low pass filters)

Video Processing 1 - Object detection (tagging cars) by thresholding color

Video Processing 2 - Face Detection and CAMShift Tracking




Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







OpenCV 3 -

image & video processing



Installing on Ubuntu 13

Mat(rix) object (Image Container)

Creating Mat objects

The core : Image - load, convert, and save

Smoothing Filters A - Average, Gaussian

Smoothing Filters B - Median, Bilateral






OpenCV 3 image and video processing with Python



OpenCV 3 with Python

Image - OpenCV BGR : Matplotlib RGB

Basic image operations - pixel access

iPython - Signal Processing with NumPy

Signal Processing with NumPy I - FFT and DFT for sine, square waves, unitpulse, and random signal

Signal Processing with NumPy II - Image Fourier Transform : FFT & DFT

Inverse Fourier Transform of an Image with low pass filter: cv2.idft()

Image Histogram

Video Capture and Switching colorspaces - RGB / HSV

Adaptive Thresholding - Otsu's clustering-based image thresholding

Edge Detection - Sobel and Laplacian Kernels

Canny Edge Detection

Hough Transform - Circles

Watershed Algorithm : Marker-based Segmentation I

Watershed Algorithm : Marker-based Segmentation II

Image noise reduction : Non-local Means denoising algorithm

Image object detection : Face detection using Haar Cascade Classifiers

Image segmentation - Foreground extraction Grabcut algorithm based on graph cuts

Image Reconstruction - Inpainting (Interpolation) - Fast Marching Methods

Video : Mean shift object tracking

Machine Learning : Clustering - K-Means clustering I

Machine Learning : Clustering - K-Means clustering II

Machine Learning : Classification - k-nearest neighbors (k-NN) algorithm










Contact

BogoToBogo
contactus@bogotobogo.com

Follow Bogotobogo

About Us

contactus@bogotobogo.com

YouTubeMy YouTube channel
Pacific Ave, San Francisco, CA 94115

Pacific Ave, San Francisco, CA 94115

Copyright © 2024, bogotobogo
Design: Web Master