
Machine Vision
Toolbox
for MATLAB
Release 4
Peter Corke

2
Release 4.3
Release date March 2018
Licence LGPL
Toolbox home page http://www.petercorke.com/robot
Discussion group http://groups.google.com.au/group/robotics-tool-box
Copyright
c
2017 Peter Corke
peter.i.corke@gmail.com
http://www.petercorke.com

Preface
This, the fourth major release of the Toolbox, repre-
senting nearly twenty years of continuous development.
This version corresponds to the second edition of the
book “Robotics, Vision & Control, second edition” pub-
lished in 2017.
The Machine Vision Toolbox (MVTB) provides many
functions that are useful in machine vision and vision-
based control. It is a somewhat eclectic collection
reflecting my personal interest in areas of photome-
try, photogrammetry, colorimetry. It includes over 100
functions spanning operations such as image file read-
ing and writing, acquisition, display, filtering, blob,
point and line feature extraction, mathematical mor-
phology, homographies, visual Jacobians, camera calibration and color space conver-
sion. The Toolbox, combined with MATLAB and a modern PC is a useful and conve-
nient environment for investigation of machine vision algorithms. For modest image
sizes the processing rate can be sufficiently “real-time” to allow for closed-loop control.
An image is usually treated as a rectangular array of pixel values – the natural datatype
for MATLAB– representing intensity or perhaps range. Many image operations such as
thresholding, filtering and statistics can be achieved with existing MATLAB functions.
The Toolbox extends this core functionality with M-files that implement functions and
classes, and mex-files for some compute intensive operations. This toolbox predates
all of the relevant Mathwork’s Toolboxes including Image Processing Toolbox
R
(IPT)
and Computer Vision System Toolbox
R
(CVST). MVTB is less complete than these
products but is open-source.
The code is written in a straightforward manner which allows for easy understanding,
perhaps at the expense of computational efficiency. If you feel strongly about computa-
tional efficiency then you can always rewrite the function to be more efficient, compile
the M-file using the MATLAB compiler, or create a MEX version.
The bulk of this manual is auto-generated from the comments in the MATLAB code
itself. For elaboration on the underlying principles, extensive illustrations and worked
examples please consult “Robotics, Vision & Control, second edition” which provides
a detailed discussion (720 pages, nearly 500 figures and over 1000 code examples) of
how to use the Toolbox functions to solve many types of problems in robotics.
Machine Vision Toolbox 4.3 for MATLAB3 Copyright
c
Peter Corke 2017

Contents
Preface ..................................... 2
Functions by category ............................. 5
1 Introduction 6
1.1 Changes in MVTB 4 .......................... 6
1.1.1 Incompatible changes ...................... 6
1.1.2 New features .......................... 6
1.1.3 Enhancements ......................... 7
1.2 How to obtain the Toolbox ....................... 7
1.2.1 From .mltbx file ........................ 7
1.2.2 From .zip file .......................... 7
1.2.3 MEX files and IPT substitution ................ 8
1.2.4 MATLAB Online
TM
...................... 8
1.2.5 Simulink
R
........................... 9
1.2.6 Documentation ......................... 9
1.3 Compatible MATLAB versions ..................... 9
1.4 Use in teaching ............................. 9
1.5 Use in research ............................. 10
1.6 Support ................................. 10
1.7 Related software ............................ 11
1.7.1 Image Processing Toolbox ................... 11
1.7.2 Computer Vision System Toolbox ............... 11
1.7.3 Octave ............................. 11
1.7.4 Robotics Toolbox ........................ 11
1.8 Acknowledgements ........................... 11
2 Functions and classes 12
about ...................................... 12
anaglyph .................................... 12
apriltags .................................... 13
AxisWebCamera ............................... 14
BagOfWords ................................. 16
blackbody ................................... 20
bresenham ................................... 20
camcald .................................... 25
Camera .................................... 25
CatadioptricCamera .............................. 32
ccdresponse .................................. 34
Machine Vision Toolbox 4.3 for MATLAB4 Copyright
c
Peter Corke 2017

CONTENTS CONTENTS
ccxyz ..................................... 35
CentralCamera ................................ 35
chi2inv_rtb .................................. 47
cie_primaries ................................. 48
closest ..................................... 48
cmfrgb ..................................... 48
cmfxyz ..................................... 49
col2im ..................................... 50
colnorm .................................... 50
colordistance ................................. 51
colorize .................................... 51
colorkmeans .................................. 52
colorname ................................... 53
colorseg .................................... 54
distance .................................... 54
dtransform ................................... 55
e2h ....................................... 55
EarthView ................................... 56
edgelist .................................... 59
epidist ..................................... 60
epiline ..................................... 60
FeatureMatch ................................. 61
filt1d ...................................... 66
FishEyeCamera ................................ 67
fmatrix ..................................... 69
h2e ....................................... 70
hist2d ..................................... 70
hitormiss .................................... 71
homline .................................... 72
homography .................................. 72
homtrans .................................... 73
homwarp ................................... 74
Hough ..................................... 74
humoments .................................. 78
ianimate .................................... 78
ibbox ..................................... 79
iblobs ..................................... 80
icanny ..................................... 81
iclose ..................................... 82
icolor ..................................... 83
iconcat ..................................... 84
iconv ...................................... 85
iconvolve ................................... 85
icorner ..................................... 86
icp ....................................... 88
idecimate ................................... 89
idilate ..................................... 90
idisp ...................................... 91
idisplabel ................................... 93
idouble .................................... 93
Machine Vision Toolbox 4.3 for MATLAB5 Copyright
c
Peter Corke 2017