PRT Blog

MATLAB Pattern Recognition Open Free and Easy

PRT Logo

Pattern Recognition in MATLAB

The Pattern Recognition Toolbox for MATLAB® provides an easy to use and robust interface to dozens of pattern classification tools making cross-validation, data exploration, and classifier development rapid and simple. The PRT gives you the power to apply sophisticated data analysis techniques to your problem. If you have data and need to make predictions based on your data, the PRT can help you do more in less time.

Visualize Your Data

The PRT’s prtDataSet objects make using and visualizing your data a breeze. The multiple built in techniques for data visualization will help you interactively understand your data and develop the insights to help you make breakthroughs.

Streamline Your Processing

The PRT provides a wide array of inter-connectable pattern recognition approaches. Every PRT action can be connected to any other PRT actions to enable you to build the powerful processing pipelines to solve the problems you need to solve with a single tool.

Get Answers

Built in cross-validation techniques ensure that your performance estimates are robust, and are indicative of expected operating performance, and built in support for decision making takes the guesswork out of setting optimal thresholds to make binary or M-ary decisions based on your data.




Latest Post


prtClusterMeanShift

Hi everyone, Today we’ll talk about a new clustering algorithm in the PRT - Mean-Shift clustering. Mean shift clustering is widely used in image processing, and has a few nice properties - for example, it’s not necessary to specify ahead of time how many clusters you need. Instead you specify a clustering bandwidth. We’ll show some examples below. If you want a good introduction to mean-shift clustering, see the wiki page.

Note, unlike most of our other objects, prtClusterMeanShift requires the bio-informatics toolbox,

Contents

prtClusterMeanShift

As you might expect, we start by generating some data, and a prtClusterMeanShift object:

ds = prtDataGenUnimodal;
ms = prtClusterMeanShift;

We can train, run, and plot the mean-shift algorithm just like anything else

ms = ms.train(ds);
plot(ms);

Bandwidth

In the above figure, the mean-shift algorithm correctly identified two clusters. We can mess with the Gaussian bandwidth parameter (sigma) to see how this affects how many clusters mean-shift finds:

sigmaVec = [.1 .3 .6 1 2 5];
for ind = 1:length(sigmaVec)

ms = prtClusterMeanShift;
ms.sigma = sigmaVec(ind);
ms = ms.train(ds);

subplot(2,3,ind);
plot(ms);
prtPlotUtilFreezeColors
title(sprintf(<span class="string">'sigma = %.2d'</span>,sigmaVec(ind)));

end

Note how changing the sigma value can drastically alter the number of clusters that mean-shift finds. Careful tuning of that parameter may be necessary for your particular application.

Application to Images

We mentioned before that you can use mean shift in image processing – here’s a quick and dirty example applying mean shift to the famous “cameraman” photo:

I = imread(‘cameraman.tif’);
I = imresize(I,0.25);
I = double(I);
[II,JJ] = meshgrid(1:size(I,2),1:size(I,1));

ij = bsxfun(@minus,cat(2,II(:),JJ(:)),size(I));

ds = prtDataSetClass(cat(2,I(:)-128,ij)); ms = train(prtClusterMeanShift(‘sigma’,200),ds); out = run(ms, ds); [~,out] = max(out.X,[],2);

figure(‘position’,[479 447 1033 366]); subplot(1,2,1) imagesc(I) colormap(gray(256)) prtPlotUtilFreezeColors; title(‘Cameraman.tif’,‘FontSize’,16);

subplot(1,2,2); imagesc(reshape(out,size(I))); colormap(prtPlotUtilClassColors(ms.nClusters)) prtPlotUtilFreezeColors; title(‘Cameraman.tif – Mean Shift’,‘FontSize’,16);

Determining Stopping

Determining convergence in a mean shift scenario can actually be pretty subtle, the code we provide is based on

http://dl.acm.org/citation.cfm?id=1143864 Fast Nonparametric Clustering with Gaussian Blurring Mean-Shift Miguel A. Carreira-Perpinan ICML 2006

Conclusion

That’s all for now. If you have the bio-informatics toolbox, have fun with prtClusterMeanShift. If you don’t, we need to find or write a replacement for graphconncomp to de-couple MeanShift from bioinformatics. One day, hopefully.