MATLAB and Octave Functions
for Computer Vision and Image Processing

Peter Kovesi


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.

These days I am working almost entirely in Julia. This is a very exciting language that is certainly worth a look. At this stage the language is still young and the image processing and computer vision packages are still developing, but they are progressing rapidly. Julia may well become the dominant language for scientific programming.

Collections of functions that I have ported to Julia are indicated in the code sections below.

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

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. They may also have points of locally high colour contrast leading to the perception of false features in your data when there are none. MATLAB's 'hot', 'jet', and 'hsv' colour maps suffer from these problems. Use the perceptually uniform colorcet maps instead! For an overview of this work and the theory behind it please visit this page.

Generation and correction of colour maps

If you want to experiment with the generation of your own perceptually uniform colour maps...

Rendering of images with colour maps

Ternary Images

Test images

Visualization of colour map paths and colour spaces

Functions for reading and writing colour maps in various formats

Colour blindness simulation and visualization.

Colour space conversions.

Additional supporting functions that are required.

Julia Code

Python Colour Maps

R Colour Maps


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


    For those working in Julia the package ImageProjectiveGeometry.jl implements most of the functions above.


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

    For those working in Julia the package ImageProjectiveGeometry.jl implements most of the functions above.

Feature Matching

Model Fitting and Robust Estimation

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


    For those working in Julia the package ImageProjectiveGeometry.jl implements most of the functions above.

Fingerprint Enhancement


Geoscientific and Geophysical Functions



Interesting Synthetic and Test Images

ASCII Image Generation

Homogeneous Transforms


Angle-Axis Descriptors

    For those working in Julia the package ImageProjectiveGeometry.jl implements most of the functions above.

Image Display, Image Writing and Miscellaneous

Geometric shapes

String handling convenience functions