MATLAB and Octave Functions
for Computer Vision and Image Processing

Peter Kovesi

Centre for Exploration Targeting
School of Earth and Environment
The University of Western Australia

Index to Code Sections

The complete set of these functions is available as a zip file


To use these functions you will need MATLAB and the MATLAB Image Processing Toolbox.
You may also want to refer to the MATLAB documentation and the Image Processing Toolbox documentation


Alternatively you can use Octave which is a very good open source alternative to MATLAB. Almost all the functions on this page run under Octave. See my Notes on using Octave.

An advantage of using Octave is that you can run it on your Android device. (I can compute phase congruency on my mobile phone!) Get Corbin Champion's port of Octave at Google play here.

MATLAB/Octave compatibility of individual function is indicated as follows

  • Runs under MATLAB and Octave.
  • Only runs under MATLAB.
  • Not tested under Octave (yet).

I receive so many mail messages regarding this site that I have difficulty responding to them all. I will endeavor to respond to mail that directly concerns the use of individual functions. However, please note I do not have the time to provide an on-line vision problem solving service!

Please report any bugs and/or suggest enhancements to

Acknowledgement: Much of this site was developed while I was with the
School of Computer Science & Software Engineering
The University of Western Australia

I thank them for continuing to host this site.

Peter Kovesi

Perceptually Uniform Colour Maps

Many widely used colour maps have perceptual flat spots that can hide features as large as 10% of your total data range. MATLAB's 'hot' and 'hsv' colour maps suffer from this problem. Use these colour maps instead. For an overview of this work and the theory behind it please visit this page

Generation and correction of colour maps

Rendering of images with colour maps

Test images

Visualization of colour map paths and colour spaces

Functions for reading and writing colour maps in various formats

Colour conversion convenience functions.

Additional supporting functions that are required.

Interactive Image Blending

These functions provide a set of interactive tools for visualizing multiple images. Some videos of their use can be seen here.

The functions above also require: normalise.m, histtruncate.m, circle.m, circularstruct.m and namenpath.m.

Demo package: Download This contains all the functions above and some sample data sets. Within the expanded folder in MATLAB run blenddemo.m. A series of windows will open, each demonstrating a different blending interface. Click in any of them and play!


Phase Based Feature Detection and Phase Congruency


Spatial Feature Detection



Integral Images


Non-Maxima Suppression and Hysteresis Thresholding

Edge Linking and Line Segment Fitting



labeled edges

fitted line segments

Test Grating for Edge Detection

Test image

Canny edge image

Phase congruency

Colour coded for feature type

Image Denoising



Surface Normals to Surfaces

Surface Normals
Surface Reconstruction


Scalogram Calculation

Anisotropic diffusion


Grey Scale Transformation and Enhancement

Frequency Domain Transformations

Functions Supporting Projective Geometry

image of beach

rectified beach

Feature Matching

Model Fitting and Robust Estimation

Putative matches obtained
by matchbycorrelation.m
Inlying matches consistent
with fundamental matrix


Fingerprint Enhancement


Geoscientific Functions



Interesting Synthetic and Test Images

ASCII Image Generation

Homogeneous Transforms


Angle-Axis Descriptors

Image Display, Image Writing and Miscellaneous

Geometric shapes

String handling convenience functions