All Matlab source code is available for anyone interested. Assumes use of the image processing toolbox.