Some Simple Image Processing Tools for Matlab

This set of Matlab tools consists of some functions that I have found useful for basic image processing and blob analysis.

When working with binary objects (4-connected foreground regions), I have often found it useful to measure features from the boundary stored as a list of coordinates. In other words, sometimes it is better to work with a polygon defining the foreground-background boundary than to work with a black and white image of the object. The boundary of an object in a binary (black and white) image can be stored as a list of pixel corner coordinates. The function getboundarymex forms a list of these corner coordinates from a binary image containing an object.

boundary of an object

The toolbox also contains selectobjectmex for selecting regions by size. The command imOut=selectobjectmex(imIn,n) will return an image, imOut, containing only the nth largest object (in terms of number of pixels) of the original image imIn. This function is particularly useful if one wants to quickly threshold an image and then select the largest object without having to worry about smaller objects that are not of interest, e.g. imOut=selectobjectmex(im>0.5,1). (See example in screenshot below.)

selectobjectmex example

Also included is code for watershed segmentation by flooding from selected sources, fast calculation of object centroids etc.

The usage of each the function is described by typing help function at the MATLAB command prompt, where function is the name of the relevant function.

The M-file script kftoolsDemo shows an example of the usage of all of the functions in this toolbox.

Download (119 kilobytes, last modified 24 October 2002)

Tested on Windows: MATLAB Version (R11) on PCWIN (28 March 2001)
Tested on Linux: MATLAB Version (R12) on GLNX86 (28 August 2001)
Tested on Windows: MATLAB Version (R12) on PCWIN (28 August 2001)

Disclaimer: You may find this code useful for research purposes, but I do not claim that it is robust!