Does MATLAB use OpenCv CascadeClassifier? - matlab

I have a question about CascadeObjectDetector in MATLAB. In source code of CascadeObjectDetector in MATLAB I see:
pCascadeClassifier; % OpenCV pCascadeClassifier
Then I see:
%------------------------------------------------------------------
% Constructor
%------------------------------------------------------------------
function obj = CascadeObjectDetector(varargin)
obj.pCascadeClassifier = vision.internal.CascadeClassifier;
...
end
And in stepImpl:
bbox = double(obj.pCascadeClassifier.detectMultiScale(I, ...
double(obj.ScaleFactor), ...
uint32(obj.MergeThreshold), ...
uint32(obj.MinSize), ...
uint32(obj.MaxSize)));
Do you know, what is vision.internal.CascadeClassifier? Is it simply OpenCV CascadeClassifier? And where is source code of detectMultiScale function?

The thing is that matlab provides the following object detectors
template matching
blob analysis
viola-jones algorithm
More info here : http://www.mathworks.ch/products/computer-vision/description4.html
Now to talk about opencv. The opencv function cv.HaarDetectObjects() which is used for faces detection (and in general for object detection) uses the viola jones algorithm which inturn uses harr like features.
My personal opinion is that the implementations may be slightly different but they essentially have the same algorithm.
If you are still not convinced and would like to use opencv function from matlab, u can use MEX. So this way u can use the cv.HaarDetectObjects() from matlab. More details are available at : http://www.mathworks.ch/discovery/matlab-opencv.html

Related

Why is SIFT not available in Matlab?

SIFT is an important and useful algorithm in computer vision but it seems that it is not part of Matlab or any of its toolboxes.
Why ? Does Matlab offer something better or equivalent ?
MATLAB has SURF available as part of the Computer Vision Toolbox but not SIFT: http://www.mathworks.com/help/vision/ref/surfpoints-class.html. However, both algorithms are pretty much the same with some minor (but crucial) differences, such as using integral images and a fast Hessian detector. I won't go into those differences in any further detail, but you can certainly read up on the work here: http://www.vision.ee.ethz.ch/~surf/eccv06.pdf. As to the reason why MathWorks decided to use SURF instead of SIFT... it could be any reason really. AFAIK, there is no official reason why one was chosen over the other as they are both subject to being patented.
However, if you want to use SIFT within MATLAB, one suggestion I have is to use the VLFeat toolbox where a C and MATLAB implementation of the keypoint, detection and matching framework has been made available and is open source. It also has a variety of other nice computer vision algorithms implemented, but VLFeat is one of the libraries that I know of that manages to compute SIFT as accurately as the original patented algorithm.
If you're dead set on using SIFT, check VLFeat out! Specifically, check out the official VLFeat tutorial on SIFT using the MATLAB wrappers: http://www.vlfeat.org/overview/sift.html

Box Cox transformation for multivariate normality in MATLAB

Has anyone implemented a Box Cox approach in MATLAB to transform multivariate data? I've found an R package that does it, but nothing for MATLAB.
Thanks.
MATLAB do not have built in function to implement multivariate box-cox transformaion.
I have written one myself and it works.
Here is the code.
The input x is the obervation matix, where the rows denote the obervations
and the columns denote the variables.
Reference: Applied Multivariate Statistical Analysis 6th- Johnson R. & Wichern D. Chapter 4.8 Transformations to Near Normality
function lambda=boxcoxn(x)
[m,n]=size(x);
lambda_ini=zeros(n,1);
for ii=1:n
[temp,lambda_ini(ii,1)]=boxcox(x(:,ii));
end
fun=#(lambda)(log(det((cov(((x.^repmat(lambda',m,1)-1)./repmat(lambda',m,1))))))*m/2-(lambda-1)'*(sum(log(x)))');
lambda=fminsearch(fun,lambda_ini);
end
Just feel free to use it.
Googling "MATLAB Box Cox" tells me that:
Box-Cox transformations are available in Financial Toolbox
There is a freely available implementation on MATLAB Central File Exchange.

Creating a classifier in MATLAB to be used with classperf

I'm working on a new model and would like to use classperf to check the performance of my classifier. How do I make it use my classifier as opposed to one of the built-in ones? All the examples I found online use classifiers that are included in MATLAB. I want to use K-fold to test it.
It isn't clear form the MATLAB documentation how to do this, though you can edit functions like knnclassify or svmclassify to see how they were written, and try to emulate that functionality.
Alternatively, there's a free MATLAB pattern recognition toolbox that uses objects to represent classifiers:
http://www.mathworks.com/matlabcentral/linkexchange/links/2947-pattern-recognition-toolbox
And you can make a new classifier by sub-classing the base classifier object: prtClass.
Then you can do:
c = myClassifier;
yGuess = c.kfolds(dataSet,10); %10 fold X-val
(Full disclosure, I'm an author of the PRT toolbox)

how can I find this matlab function named "svmpredict.m"

I am studying image quilty , a algorithm named "divine" which is from paper "Blind Image Quality Assessment: From Natural Scene Statistics to Perceptual Quality" , this algorithm used
a toolbox matlabPyrTools (I have downloaded), and another function svmpredict.m, I cannot find it in its sourcecode(the soucecode page is http://live.ece.utexas.edu/research/quality/DIIVINE_release.zip) .
I would guess it's likely to be from LibSVM, a freely available package for support vector machines that includes a MATLAB wrapper.
svmpredict is NO official matlab function so use a search engine to look for it or ask the author of the toolbox where to find it, e.g. https://www.google.de/#hl=de&q=svmpredict%20matlab&fp=1&cad=b&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb

SIFT and SURF feature extraction Implementation using MATLAB

I am doing an ancient coins recognition system using matlab. What I have done so far is:
convert to grayscale
remove noise using Gaussian filter
contrast enhancement
edge detection using canny edge detector.
Now I want to extract feature for classification. Features I thought to select are roundness, area, colour, SIFT and SURF. My problem is how I can apply SIFT and SURF algorithms to my project. I couldn't find built-in functions for both.
You can find SIFT as a C implementation with MATLAB bindings at: http://www.vlfeat.org/index.html
For anyone else coming across this thread as I did, I noticed the implementation at http://www.vlfeat.org/index.html was far more than I required and also fairly hard to adjust to my code.
The following link; http://robwhess.github.io/opensift/, has an implementation of just the SIFT algorithm accompanied with an example executable, with the source code available (unlike http://www.cs.ubc.ca/~lowe/keypoints/ which only has the sift binary executable).
you can find a matlab implementation of SIFT features here: http://www.cs.ubc.ca/~lowe/keypoints/