Matlab hints

Links

Link to the course book website: Digital Image Processing

Some tutorials:

  • Matlab tutorials
  • Matlab demos
  • Matlab Image Processing Toolbox demos
  • Introduction to image processing in Matlab
  • Matlab help
  • Matlab Image Processing Toolbox help
  • Matlab documentation examples


    A short list of Matlab functions

    Function / token Purpose
    % Comment
    ; Stops echoing to screen
    clc Clear screen
    clear Clears allocated variables
    whos shows information about allocated variables
    close Closes the latest open plots or figure
    close(x) Closes the plot or figure #x
    close all Closes all open plots & figures
    figure creates a new figure (graph window)
    figure(x) creates a new figure (graph window) and assigns it id #x
    unit8(x) explicitly casts x to the uint8 type
    double(x) explicitly casts x to the double type
    [m n] = size(x) retrieves the matrix / image dimensions of x
    zeros(m,n) creates a matrix if dimension m x n filled with zeros
    ones(m,n) creates a matrix if dimension m x n filled with ones
    imread(filename) reads an image from disc
    imwrite(x,filename) writes image x to disc
    help x displays matlabs help for function x
    ind2gray converts an index based image to grayscale
    rgb2gray converts an RGB image to grayscale
    subplot(m,n,nr) creates a subplot in a figure
    conv2(x,y) 2D convolution of x & y
    medfilt2(x) 2D median filtering of x
    hist(x) computes the histogram of x
    histeq computes the histogram equalization of x
    imcrop(x,[]) crops an image to specified dimensions
    x = [... ; ... ; ...]; create matrix x
    m(y,x) access element x,y in matrix m
    for a : b for-loop, loops from a to b
    for a : stepSize : b for-loop, loops from a to b with specified step size
    end end loop
    fft2 computes the 2D Fourier transform using FFT (also pads image)
    ifft2 computes the inverse 2D Fourier transform using FFT (does not crop the resulting image)
    fftshift shifts the Fourier spectrum
    abs(x) returns the absolute value of a x (can be used for Fourier spectras)
    angle(x) computes the phase angle of x