Theodoridis, Pattern Recognition 4e

,

Page 1

Pattern Recognition Matlab Manual
Aggelos Pikrakis, Sergios Theodoridis, Kostantinos Koutroumbas and Dionisis Cavouras February 2009

Copyright 2009, Elsevier Inc

Theodoridis, Pattern Recognition 4e,

Page 2

2

Contents
1 Preface 2 Clustering 2.1 BSAS.m . . . . . . . . . . 2.2 reassign.m . . . . . . . . . 2.3 GMDAS.m . . . . . . . . 2.4 gustkess.m . . . . . . . . . 2.5 k means.m . . . . . . . . . 2.6 possibi.m . . . . . . . . . . 2.7 k medoids.m . . . . . . . 2.8 spectral Ncut2.m . . . . 2.9 spectral Ncut gt2.m . . . 2.10 spectral Ratiocut2.m . . 2.11 spectral Ratiocut gt2.m 2.12 competitive.m . . . . . . 2.13 valley seeking.m . . . . . 2.14 distant init.m . . . . . . . 2.15 rand data init.m . . . . . 2.16 rand init.m . . . . . . . . 2.17 cost comput.m . . . . . . 2.18 dgk.m . . . . . . . . . . . . 2.19 dist.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 6 6 6 7 7 8 9 9 10 11 11 12 12 13 14 14 15 15 15 16 17 17 17 17 18 18 18 19 19 19 20 20 20 21 21 21 21 22 22 22

3 Feature Selection 3.1 simpleOutlierRemoval.m . . . . . . 3.2 normalizeStd.m . . . . . . . . . . . 3.3 normalizeMnmx.m . . . . . . . . . 3.4 normalizeSoftmax.m . . . . . . . . 3.5 ROC.m . . . . . . . . . . . . . . . . . 3.6 divergence.m . . . . . . . . . . . . . 3.7 divergenceBhata.m . . . . . . . . . 3.8 ScatterMatrices.m . . . . . . . . . . 3.9 ScalarFeatureSelectionRanking.m 3.10 SequentialBackwardSelection.m . 3.11 SequentialForwardSelection.m . . 3.12 exhaustiveSearch.m . . . . . . . . . 4 Image Features 4.1 generateCoOccMat.m . 4.2 CoOccMatFeatures.m . 4.3 CoOccASM.m . . . . . 4.4 CoOccContrast.m . . . 4.5 CoOccCOR.m . . . . . 4.6 CoOccVariance.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Copyright 2009, Elsevier Inc

Theodoridis, Pattern Recognition 4e,

Page 3

3

4.7 4.8 4.9 4.10 4.11 4.12 4.13 4.14 4.15 4.16 4.17 4.18 4.19 4.20 4.21 4.22 4.23 4.24 4.25 4.26 4.27 4.28 4.29

CoOccIDM.m . . . . . . . CoOccSUA.m . . . . . . . CoOccSUV.m . . . . . . . CoOccSUE.m . . . . . . . CoOccEntropy.m . . . . . CoOccDEN.m . . . . . . CoOccDVA.m . . . . . . . CoOccCIMI.m . . . . . . CoOccCIMII.m . . . . . . CoOccPXandPY .m . . . CoOccPXminusY.m . . . CoOccPxplusY.m . . . . ImageHist.m . . . . . . . HistMoments.m . . . . . HistCentralMoments.m LawMasks.m . . . . . . . RL 0 90.m . . . . . . . . . RL 45 135.m . . . . . . . SRE.m . . . . . . . . . . . LRE.m . . . . . . . . . . . GLNU.m . . . . . . . . . . RLNU.m . . . . . . . . . . RP.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

22 23 23 23 23 24 24 24 24 25 25 25 26 26 26 27 27 27 28 28 28 29 29 30 30 30 30 31 31 31 32 32 33 33 33 34 34 35 35 36 36 37 37

5 Audio Features 5.1 sfSpectralCentroid.m . 5.2 sfSpectralRolloff.m . . 5.3 sfFundAMDF.m . . . . 5.4 sfFundAutoCorr.m . . 5.5 sfFundCepstrum.m . . 5.6 sfFundFreqHist.m . . . 5.7 sfMFCCs.m . . . . . . . 5.8 computeMelBank.m . . 5.9 stEnergy.m . . . . . . . 5.10 stZeroCrossingRate.m 5.11 stSpectralCentroid.m . 5.12 stSpectralRolloff.m . . 5.13 stSpectralFlux.m . . . . 5.14 stFundAMDF.m . . . . 5.15 stMelCepstrum.m . . . 5.16 stFundFreqHist.m . . . 5.17 stFundAutoCorr.m . . 5.18 stFundCepstrum.m . . 5.19 stFourierTransform.m

Copyright 2009, Elsevier Inc

Theodoridis, Pattern Recognition 4e,

Page 4

4

6 Dynamic Time Warping 6.1 editDistance.m . . . . 6.2 DTWSakoe.m . . . . . 6.3 DTWSakoeEndp.m . 6.4 DTWItakura.m . . . 6.5 DTWItakuraEndp.m 6.6 BackTracking.m . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

38 38 38 39 39 40 41

Copyright 2009, Elsevier Inc

All the m-files have been developed by ourselves and we have not included (with very few exceptions) code that is already included in the available Matlab toolboxes. Pikrakis S.g. Koutroumbas D. etc. A. which are given here as well as those available in the matlab toolboxes. Cavouras Copyright 2009. Elsevier Inc . statistical toolbox and image processing toolbox. We have not covered all the algorirhms that are described in the book.. Page 5 5 1 Preface The Matlab m-files that are provided here are intended to satisfy pedagogical needs. e. Examples are the routines related to Support Vector Machines. Pattern Recognition 4e. Currently. Theodoridis K. a companion book is being developed including short descriptions of theory as well as a number of Matlab excercises. We have focused at the most popular methods as well as methods that can help the reader to get familiar with the basic concepts associated with the different methodologies. We would appreciate any comments from the readers and we are happy to try to accomodate them. This book will be based on routines. k-NN classifier.Theodoridis.

q. – m: the matrix whose columns contain the l-dimensional (mean) representatives of the clusters.order) • Description: This function performs a single pass on the data set and re-assigns the data vectors to their closest clusters taking into account their distance from the cluster representatives. It may be applied on the clustering produced by BSAS in order to obtain more compact clusters. – theta: the dissimilarity threshold. each column of which corresponds to an l-dimensional data vector. • Input: – X : an l × N dimensional matrix. 2.2 reassign. .1 Clustering BSAS. a new cluster is formed with the current vector being its representative.m • Syntax : [bel. . m]=BSAS(X. each column of which contains the l-dimensional (mean) representative of each cluster. – order : an N-dimensional vector containing a permutation of the integers 1. 2. Page 6 6 2 2. – order : an N-dimensional vector containing a permutation of the integers 1. . The i-th element of this vector specifies the order of presentation of the i-th vector to the algorithm. Pattern Recognition 4e. each column of which corresponds to an l-dimensional data vector. The results of the algorithm are influenced by the order of the presentation of the data. – m: a matrix. Otherwise. • Output: – bel : an N-dimensional vector whose i-th element indicates the cluster where the i-th data vector has been assinged.m • Syntax : [bel]=reassign(X. . It performs a single pass on the data. – q: the maximum allowable number of clusters. N . If the currently considered vector lies at a significant distance (greater than a given dissimilarity threshold) from the clusters formed so far. Elsevier Inc . N . .Theodoridis.m. • Input: – X : an l × N dimensional matrix. . . the considered vector is assigned to its closest cluster. Copyright 2009.theta.order) • Description: This function implements the BSAS (Basic Sequential Algorithmic Scheme) algorithm. . 2. The i-th element of this vector specifies the order of presentation of the i-th vector to the algorithm. • Output: – bel : an N-dimensional vector whose i-th element indicates the cluster where the i-th data vector has been assinged.

– iter : the number of iterations performed by the algorithm.j).j) and S(:. Page 7 7 2. – mv : an l × m dimensional matrix.j) and a covariance matrix S(:.:. • Input: – X : an l × N dimensional matrix. Once more.cp. The distance of a point X(:.e. Elsevier Inc .m • Syntax : [u. the algorithm terminates when the sum of the absolute differences of “mv”s “mc”s and a priori probabilities between two successive iterations is smaller than “e”.maxiter.mc. where each cluster is characterized by a normal distribution. – maxiter : The maximum number of iterations the algorithm is allowed to run.c.mv.:.q. – diffvec: a vector whose i-th cooordinate contains the difference between the sum of the absolute differences of “mv”s “mc”s and a priori probabilities between the i-th and the (i − 1)-th iteration.Theodoridis.e) • Description: This function implements the Gustafson-Kessel algorithm. Once more. The aim is to estimate the means and the covariance matrices of the distributions characterizing each cluster. The algorithm aims at grouping points that lie around a line (hyperplane in general) to the same cluster via iterative adjustment of the cluster parameters (centers and covariances).c.u.j). an algorithm of fuzzy nature that is able to unravel planar clusters.diffvec]=GMDAS(X. the number of clusters m is assumed to be known.iter. – cp: an N × m dimensional matrix whose (i. c(:. each column of which contains an initial estimate of the mean corresponding to the i-th cluster. The j-th cluster is represented by a center c(:. which terminates when no significant change in the values of the previous parameters is encountered between two successive iterations.i) from the j-th cluster is a weighted form of the Mahalanobis distance and is a function of X(:.3 GMDAS.m • Syntax : [ap. – sed : The seed used for the initialization of the random generator function “rand”.4 gustkess. is a prerequisite for the algorithm.iter]=gustkess(X. the number of clusters. as well as the a priori probabilities of the clusters. – mc: an l × l × m dimensional matrix whose i-th l × l two-dimensional “slice” is an initial estimate of the covariance matrix corresponding to the i-th cluster. Specifically. – mv : the l × m dimensional matrix each column of which contains the final estimate of the mean corresponding to the i-th cluster.S.i).S. m. This is carried out in an iterative manner. Pattern Recognition 4e. – e: The threshold that controls the termination of the algorithm. Copyright 2009.mc.mv. 2. each column of which corresponds to an l-dimensional data vector. • Output: – ap: an m-dimensional vector whose i-th coordinate contains the a priori probability of the i-th cluster.sed) • Description: This function implements the GMDAS (Generalized Mixture Decomposition Algorithmic Scheme) algorithm. – mc: an l × l × m dimensional matrix whose i-th l × l two-dimensional “slice” is the final estimate of the covariance matrix corresponding to the i-th cluster. j) element contains the probability of the fact that the i-th vector belongs to the j-th cluster.

so that a suitable cost function is minimized. The algorithm starts with an initial estimation of the cluster representatives and iteratively tries to move them into regions that are “dense” in data vectors. The algorithm terminates when the values of the cluster representatives remain unaltered between two successive iterations.bel]=k means(X. – e: the parameter used in the termination criterion of the algorithm. – w : a matrix. j) element is an initial estimate of the “grade of membership” of the i-th data vector to the j-th cluster (all elements of u are in the interval [0. whose columns contain the final estimates of the representatives of the clusters. Elsevier Inc . – S : an l × l × m dimensional matrix whose j-th l × l two-dimensional “slice” is an initial estimate of the covariance for the j-th cluster. whose columns contain the l-dimensional (mean) representatives of the clusters. – NOTE : This function calls dgk. (the algorithm terminates when the summation of the absolute differences of u’s between two successive iterations is less than e). This is achieved by performing (usually) a few passes on the data set. • Input: – X : an l × N dimensional matrix. which requires as input the number of clusters underlying the data set. whose i-th element indicates the cluster where the i-th data vector has been assinged. – q: the fuzzifier parameter. – S : an l × l × m dimensional matrix whose j-th l × l two-dimensional “slice” is a final estimate of the covariance for the j-th cluster.m function for the computation of the distance of a point from a cluster. each column of which corresponds to an l-dimensional data vector. – c: an l × m dimensional matrix whose j-th column is an initial estimate of the center for the j-th cluster. 1] and the entries of each row sum up to unity).5 k means. – c: an l × m dimensional matrix with the final estimates of the centers of the clusters. – bel : an N-dimensional vector. – u: an N ×m dimensional matrix whose (i. • Output: – u: an N × m dimensional matrix with the final estimates of the grade of memberships of each vector to each cluster. Page 8 8 • Input: – X : an l × N dimensional matrix each column of which corresponds to a data vector. Copyright 2009.m • Syntax : [w. • Output: – w : a matrix. 2. Pattern Recognition 4e.Theodoridis.w) • Description: This function implements the k-means algorithm.

m.w]=possibi(X.m • Syntax : [bel. now. – init proc: an integer taking values “1”..w.m.“3” corresponding to distant init.7 k medoids. j) element denotes the possibility that the i-th data vector belongs to the j-th cluster. “2” or “3” with . When this is not equal to 0 the original cost function is considered. which is used as the seed for the random generator function “rand”.m and distant init. – NOTE : This function calls rand init. the represenatives are constrained to be vectors Copyright 2009.a]=k medoids(X.“2” corresponding to rand data init. . after the convergence of the algorithm. Once more. Specifically. each column of which corresponds to a data vector.m. Elsevier Inc .m.e. each column of which corresponds to a cluster representative. – w : an l × m dimensional matrix.m (this procedure chooses the m vectors of X that are “most distant” from each other. Pattern Recognition 4e.eta.6 possibi. the algorithm terminates when the sum of the absolute differences of the representatives between two successive iterations is smaller than e thres.Theodoridis. – e thres: The threshold controlling the termination of the algorithm. However. • Input: – X : an l × N dimensional matrix. – sed : a scalar integer.q. However. so that a suitable cost function is minimized.cost.sed. – eta: an m-dimensional array of the eta parameters of the clusters.m initialization procedure (this procedure chooses randomly m vectors from the smallest hyperrectangular that contains all the vectors of X and its sides are parallel to the axes). while if it is 0 the alternative one is considered.m (this procedure chooses randomly m vectors among the vectors of X) and . It terminates when no significant difference in the values of the representatives is encountered between two successive iterations. The algorithm moves iteratively the cluster representatives to regions that are “dense” in data.“1” corresponding to the rand init. when the squared Euclidean distance is adopted. whose (i. i. • Output: – U : an N ×m dimensional matrix. – q: the q parameter of the algorithm. so that a suitable cost function is minimized.init proc. the number of clusters is a priori required. The aim of this algorihm is the same as with k-means. This is a more computationally demanding procedure). rand data init. – m: the number of clusters.m • Syntax : [U.sed) • Description: This function implements the k-medoids algorithm.e thres) • Description: Implements the possibilistic algorithm. when it is overestimated. the algorithm has the ability to return a solution where more than one representatives coincide. to move iteratively the cluster representatives to regions that are “dense” in data. Page 9 9 2. 2. after the convergence of the algorithm.

Finally. after the convergence of the algorithm. – a: an m-dimensional vector containing the indices of the data vectors that are used as representatives. – m: the number of clusters. Elsevier Inc . This division specifies the clustering of the vectors in the original data set X. Copyright 2009. Pattern Recognition 4e. whose i-th element contains the cluster in which the i-th data vector is assigned. • Output: – bel : an N-dimensional vector whose i-th element contains the index of the cluster to which the i-th data vector is assigned. – e: the parameter that defines the size of the neighborhood around each vector. – sed : a scalar integer. – w : an l × m dimensional matrix. each column of which corresponds to a cluster representative.m to compute the cost accosiated with a specific partition. The algorithm determines the N dimensional eigenvector that corresponds to the 2nd smallest eigenvalue of L1.m • Syntax : [bel]=spectral Ncut2(X. – NOTE : This function calls cost comput.8 spectral Ncut2. A new N dimensional vector y is produced by multiplying the above eigenvector with a suitable matrix D. The algorithm terminates when no change in the representatives is encountered between two successive iterations. – sigma2 : the parameter that controls the width of the Gaussian kernel (here only the case where all the kernels have the same sigma2 parameter is considered). 2. – cost: a scalar which is the summation of the distances of each data vector from each closest representative. each column of which corresponds to an l-dimensional data vector. each column of which corresponds to a data vector. produced by an l × N dimensional matrix X.e. computed after the convergence of the algorithm. The algorithm minimizes the so-called Ncut criterion. after the convergence of the algorithm. the elements of y are divided into two groups according to whether they are greater or less than the median value of y. Page 10 10 of the data set.Theodoridis. • Input: – X : an l × N dimensional matrix each row of which is a data vector. • Output: – bel : an N-dimensional vector. • Input: – X : an l × N dimensional matrix.sigma2) • Description: This function performs spectral clustering based on the N × N dimensional normalized graph Laplacian L1. which is used as the seed for the random generator function “rand”. The number of clusters in this case is fixed to 2.

The algorithm determines the N-dimensional eigenvector y that corresponds to the 2nd smallest eigenvalue of L.m • Syntax : [bel]=spectral Ncut gt2(X. • Input: – X : an l × N dimensional matrix each row of which is a data vector.e. • Output: – bel : an N-dimensional vector whose i-th element contains the index of the cluster to which the i-th data vector is assigned. Matrix V is produced by multiplying U with a suitable matrix. The algorithm minimizes the so-called Ncut criterion. produced by an l × N dimensional matrix X. The elements of y are divided into two groups according to whether they are greater or less than the median value of y.sigma2. – e: the parameter that defines the size of the neighborhood around each vector. each column of which corresponds to a data vector. each column of which corresponds to a data vector. The number of clusters.m • Syntax : [bel]=spectral Ratiocut2(X. Page 11 11 2.i)’s are clustered based on the clustering produced by the k-means algorithm that is applied on U(i. • Output: – bel : an N-dimensional vector whose i-th element contains the index of the cluster to which the i-th data vector is assigned.Theodoridis. 2. The algorithm minimizes the so-called Ratiocut criterion. – sigma2 : the parameter that controls the width of the Gaussian kernel (here only the case where all the kernels have the same sigma2 parameter is considered).e. Copyright 2009. produced by an l × N dimensional matrix X. Finally. – sigma2 : the parameter that controls the width of the Gaussian kernel (here only the case where all the kernels have the same sigma2 parameter is considered). the j-th column of which corresponds to the j-th smallest eigenvalue of L1. • Input: – X : an l × N dimensional matrix each row of which is a data vector.9 spectral Ncut gt2. – k : the number of clusters. the data vectors X(:. The number of clusters in this case is fixed to 2. Pattern Recognition 4e.k) • Description: This function performs spectral clustering based on the N × N dimensional normalized graph Laplacian L1. Elsevier Inc . – e: the parameter that defines the size of the neighborhood around each vector. is again assumed to be known (it may be greater than or equal to 2).sigma2) • Description: This function performs spectral clustering based on the N × N dimensional unnormalized graph Laplacian L.:)’s.i) is mapped to the i-th row vector U(i. Then.10 spectral Ratiocut2. k. The algorithm determines a k × N dimensional matrix U. This division specifies the clustering of the vectors in the original data set X.:) of U. the i-th data vector X(:.

12 competitive. Elsevier Inc . Pattern Recognition 4e. the data vectors X(:. – e: the parameter that defines the size of the neighborhood around each vector.sigma2. The basic competitive learning scheme (where only the closer representative moves towards the current vector) can be viewed as a special case of the leaky learning algortihm when the learning rate for the losers is set equal to 0.sed.i) is mapped to the i-th row vector V(i. the representatives are moved towards regions that are “dense” in data vectors.i). all representatives move towards X(:. In this way. Finally. produced by an l × N dimensional matrix X. the learning rate for the one that lies closer to X(:. the closest representative moves much closer to X(:.i)’s are clustered based on the clustering produced by the k-means algorithm that is applied on V(i. – k : the number of clusters. The algorithm determines a k × N dimensional matrix V.max epoch.i) (winner) is much higher than the learning rate for the rest representatives (losers). each column of which corresponds to a data vector. • Output: – bel : an N-dimensional vector whose i-th element contains the index of the cluster to which the i-th data vector is assigned. (a) the vectors are presented in random order within each epoch and (b) the termination condition of the algorithm is “The clustering remains unaltered during two successive epochs”.k) • Description: This function performs spectral clustering based on the N × N dimensional unnormalized graph Laplacian L. i-th data vector X(:.epoch]=competitive(X.:)’s.11 spectral Ratiocut gt2. The number of representatives is assumed to be known.i). The number of clusters.m.e. However. 2. IMPORTANT NOTE: In this implementation. The algorithm minimizes the so-called Ratiocut criterion.w ini. Page 12 12 2.init proc) • Description: This function implements the competitive leaky learning algorithm.eta vec. the representatives are initialized by the algorithm. • Input: – X : an l × N dimensional matrix each row of which is a data vector. It is an iterative algorithm where the representatives are updated after the presentation of each data vector X(:. – sigma2 : This parameter controls the width of the Gaussian kernel (here only the case where all the kernels have the same sigma2 parameter is considered). Then.bel. – w ini : an l × m dimensional matrix containing the initial estimates of the representatives.e thres.m • Syntax : [w. the j-th column of which corresponds to the j-th smallest eigenvalue of L. • Input: – X : an l × N dimensional matrix containing the data points.Theodoridis. If it is empty.:) of V.i) than the rest representatives.m • Syntax : [bel]=spectral Ratiocut gt2(X. As a consequence. Specifically. Copyright 2009. k. is again assumed to be known (it may be greater or equal to 2).

m 2. while its second component is the learning rate for all the rest representatives.iter]=valley seeking(X. Page 13 13 – m: the number of representatives. – eta vec: a 2-dimensional parameter vector whose first component is the learning rate for the winning representative.“3” corresponding to distant init. The algorithm terminates when no point is reassigned to a different cluster between two successive iterations.m and distant init. “2” or “3” with . Elsevier Inc .“1” corresponding to rand init.i) is assigned to the cluster that has more vectors among the neighbors of X(:. rand data init. – a: a parameter that specifies the size of the neighborhood. – max epoch: The maximum number of epochs. – epoch: The number of epochs required for convergence. its closest neighbors are considered and X(:. This is utilized only when w ini is empty. – NOTE : This function calls rand init. This is a more computationally demanding procedure).i). – sed : a seed for the rand function of MATLAB.bel ini. at each iteration and for each data vector X(:.“2” corresponding to rand data init. – bel : an N dimensional vector.m (this procedure chooses the m vectors of X that are “most distant” from each other. Pattern Recognition 4e.max iter) • Description: This function implements the valley seeking algorithm.13 valley seeking.i).m (this procedure chooses randomly m vectors among the vectors of X) and .m initialization procedure (this procedure chooses randomly m vectors from the smallest hyperrectangular that contains all the vectors of X and its sides are parallel to the axes). – init proc: an integer taking values “1”. .m • Syntax : [bel. Copyright 2009. – bel ini : an N-dimensional vector whose i-th coordinate contains the index of the cluster where the i-th vector is initially assigned. whose i-th element contains the index of – the closest to X( : . – e thres: The parameter used in the termination condition (in this version of the algorithm its value is of no importance).Theodoridis. • Output: – w : an l × m dimensional matrix containing the initial estimates of the representatives.i) representative. This algorithm starts with an initial clustering of the data vectors and iteratively adjusts it in order to identify the regions that are “dense” in data (which correspond to the physically formed clusters).a.m. • Input: – X : an l × N dimensional data matrix whose rows corresponds to the data vectors. This choice is activated only if the user does not provide the initial conditions. Specifically. – max iter : a parameter that specifies the maximum allowable number of iterations.

whose columns are the data vectors. – NOTES : . whose columns are the data vectors. 2. .m. whose columns are the randomly selected vectors of X. Copyright 2009. • Input: – X : an l × N dimensional matrix. in order to identify the true number of clusters. – m: the number of vectors to be chosen. • Input: – X : an l × N dimensional matrix. . Specifically. Then. whose columns are the selected “most distant” vectors.m • Syntax : [w]=distant init(X. 2. the valley seeking algorithm can take over. It can be used after. which has the same structure with bel ini described before. e. 2.m that computes the squared Euclidean distance between two vectors.g.. Page 14 14 • Output: – bel : an N-dimensional vector.Theodoridis.sed) • Description: This function chooses the m “most distant” from each other vectors among the N vectors contained in a data set X. using this as initial condition.The algorithm is extremely sensitive to parameter settings (a and bel ini). – sed : the seed for the random number generator. • Output: – w : an l × m dimensional matrix.m • Syntax : [w]=rand data init(X. – sed : the seed for the random number generator (in this case it does not affect the results of the algorihm). Elsevier Inc .m. the mean vector of the N data vectors of a set X is computed and the vector of X that lies furthest from the mean is assigned first to the set w contaning the “most distant” points. • Output: – w : an l × m dimensional matrix. .This function calls dist.15 rand data init. – m: the number of vectors to be chosen. . (b) the point with the maximum of the above N-i+1 computed minimum distances joins w as its i-th element. The i-th element of w is selected via the follwoing steps: (a) the minimum distance of each of the N-i+1 points of X-W from the i-1 vectors in W is computed. Pattern Recognition 4e. m}. . – iter : the number of iterations performed until convergence is achieved. a sequential algorithm.sed) • Description: This function chooses randomly m among the N vectors contained in a data set X of vectors.14 distant init.It is assumed that the cluster indices are in the set {1. .

cost]=cost comput(X. – w : an l × m dimensional matrix. each column of which corresponds to a cluster representative.i) to the cluster whose repersentative lies closest to X(:. the summation of the distances of each data vector from each closest representative and (b) it assigns each vector X(:. 2. – sed : the seed for the random number generator. • Output: – w : an l × m dimensional matrix. – cost: a scalar which is the summation of the distances of each data vector from each closest representative. whose i-th element contains the cluster where the i-th data vector is assigned.c.sed) • Description: This function chooses randomly m vectors from the smallest hyperrectangular whose edges are prallel to the axes and contains all the vectors of a given data set X. Page 15 15 2.w) • Description: This is an auxiliary function and it is called by the k medoids function.m • Syntax : [bel.m • Syntax : [w]=rand init(X.16 rand init. • Output: – bel : an N dimensional vector. whose columns are the randomly selected vectors. • Input: – X : an l × N dimensional matrix. • Input: Copyright 2009.S) • Description: This function determines the distance used in the G-K algorithm between a point x and a cluster characterized by center c and covariance S.e. 2.Theodoridis. Its aim is twofold: (a) it computes the value of the cost function employed by the k-medoids algorithm. Elsevier Inc .m • Syntax : [z]=dgk(x. Pattern Recognition 4e.m.i). • Input: – X : an l × N dimensional matrix. each column of which corresponds to an l-dimensional data vector. – m: the number of vectors to be chosen. i. – NOTE : This function calls the function dist that computes the squared Euclidean distance between two vectors.17 cost comput.18 dgk. whose columns are the data vectors.

• Output: – z : the distance between the point and the cluster as it is defined in the framework of the GustafsonKessel algorithm. – c: the center of the cluster at hand. Page 16 16 – x : a l-dimensional column vector. • Output: – z : the squared Euclidean distance between the vectors x and y.Theodoridis. – NOTE : It is called from the cost comput. Elsevier Inc . 2. Pattern Recognition 4e. – S : the covariance of the cluster at hand. • Input: – x.m function.y) • Description: Computes the squared Euclidean distance between two column vectors of equal length.m • Syntax : [z]=dist(x. y: two column vectors of equal length. Copyright 2009.19 dist.

Theodoridis. – Index : indices of the outliers in the input dat matrix. Elsevier Inc . – class2n: row vector of normalized data for class2.class2n]=normalizeStd(class1. • Output: – class1n: row vector of normalized data for class1.. • Input: – class1 : row vector of data for class1.Index. 3. – datOut: reduced data set after outliers have been removed.3 normalizeMnmx. Copyright 2009. – class2 : row vector of data for class2.1 Feature Selection simpleOutlierRemoval. Page 17 17 3 3. Pattern Recognition 4e. • Output: – outls: outliers that have been detected. – par2 : desired maximum value.ttimes) • Description: Detects and removes outliers from a normally distributed dataset by means of a thresholding technique.2 normalizeStd.c2]=normalizeMnmx(class1. 3.m • Syntax : [c1. • Input: – class1 : row vector of data for class1.class2.dat]=simpleOutlierRemoval(dat.m • Syntax : [outls. • Input: – dat: holds the normally distributed data.class2) • Description: Data normalization to zero mean and standard deviation 1. – ttimes: sets the outlier threshold.g. – class2 : row vector of data for class2. The threshold depends on the median and std values of the dataset.par1.par2) • Description: A linear technique for data normalization that limits the feature values in the range [par1 par2] (e.m • Syntax : [class1n. – par1 : desired minimum value. [-1 1]). by proper scaling.

Each element is -1 or 1.g. Values away from the mean are squashed exponentially. 3. one pattern per column.Theodoridis. – class2 : row vector of data for class2. – c2 : normalized data for class2. r=0. – c2 : data of the second class. Page 18 18 • Output: – c1 : normalized data for class1.4 normalizeSoftmax. • Input: – x : row vector of data for both classes. Pattern Recognition 4e. 3.r) • Description: Softmax normalization.y) • Description: Plots the ROC curve and computes the area under the curve. • Output: – D: value of divergence. – c2 : normalized data for class2.5).class2. • Output: – c1 : normalized data for class1. – r : factor r affects the range of values that corresponds to the linear section (e. Elsevier Inc . This is basically a squashing function limiting data in the range [0 1]. 3. Copyright 2009. • Input: – c1 : data of the first class.c2) • Description: Computes the divergence between two classes..m • Syntax : [auc]=ROC(x.6 divergence. – y: row vector with data labels. one pattern per column. The range of values that corresponds to the linear section depends on the standard deviation and the input parameter r.m • Syntax : [c1.m • Syntax : [D]=divergence(c1. • Input: – class1 : row vector of data for class1. • Output: – auc: area under ROC curve.c2]=normalizeSoftmax(class1.5 ROC.

Copyright 2009. Pattern Recognition 4e.8 ScatterMatrices. Elsevier Inc . • Output: – T : Feature ranking matrix. • Input: – class1 : data of the first class. ’ROC’. one pattern per column.m • Syntax : [T]=ScalarFeatureSelectionRanking(c1.Theodoridis. • Output: – D: Bhattacharyya distance.c2) • Description: Computes the Bhattacharyya distance between two classes. Possible parameter values are ’t-test’. • Input: – c1 : data of the first class. – sepMeasure: class separability criterion.9 ScalarFeatureSelectionRanking. one pattern per column. ’divergence’.sepMeasure) • Description: Features are treated individually and are ranked according to the adopted separability criterion (given in sepMeasure). one pattern per column. • Output: – J : distance measure (J3 ) which is computed from the within-class and mixture scatter matrices. one pattern per column.class2) • Description: Computes the distance measure (J3 ) between two classes with scattered (non-Gaussian) feature samples.7 divergenceBhata. ’Bhata’.m • Syntax : [J]=ScatterMatrices(class1. – c2 : matrix of data for the second class. Page 19 19 3. – c2 : data of the second class. 3.c2. The first column contains class separability costs and the second column the respective feature ids. 3. – class2 : data of the second class. • Input: – c1 : matrix of data for the first class. ’Fisher’. one pattern per column. one pattern per column.m • Syntax : [D]=divergenceBhata(c1.

Copyright 2009. ’ScatterMatrices’. Elsevier Inc .class2) • Description: Feature vector selection by means of the Sequential Forward Selection technique. Page 20 20 3.11 SequentialForwardSelection.12 exhaustiveSearch. Uses function ScatterMatrices for the class separability measure.class2. one pattern per column. – c2 : matrix of data for the second class. one pattern per column. • Input: – c1 : matrix of data for the first class.JMaxOverall]=SequentialForwardSelection(class1.class2) • Description: Feature vector selection by means of the Sequential Backward Selection technique. • Input: – class1 : data of the first class. – c2 : matrix of data for the second class. 3. Row vector of feature ids. • Output: – clbest: best feature combination.m • Syntax : [cLbestOverall. – JMaxOverall : Class separabilty cost derived from the scatter-matrices measure.10 SequentialBackwardSelection. 3. – JMaxOverall : Class separabilty cost derived from the scatter-matrices measure. one pattern per column. Row vector of feature ids. • Output: – cLbestOverall : Selected feature subset.m • Syntax : [cLbest.JMaxOverall]=SequentialBackwardSelection(class1. ’divergenceBhata’.Theodoridis.Jmax]=exhaustiveSearch(class1. • Input: – c1 : matrix of data for the first class. one pattern per column. one pattern per column. – Jmax : value of the adopted cost function for the best feature combination. Row vector of feature ids.CostFunction) • Description: Exhaustive search for the best feature combination depending on the adopted class separability measure (given in CostFunction). • Output: – cLbestOverall : Selected feature subset. one pattern per column. – CostFunction: Possible choices are ’divergence’.m • Syntax : [cLbestOverall. Pattern Recognition 4e. – class2 : data of the second class. Uses function ScatterMatrices to compute the class separability measure.

m • Syntax : [features]=CoOccMatFeatures(CoMat) • Description: Computes a total of 13 image features. 50 and 135 degrees. • Output: – ASM : the value of the Angular Second Moment.e. Calls 13 functions.2 CoOccMatFeatures. • Input: – M : the co-occurrence matrix. These 13 functions are described in the sequel.P 135]=generateCoOccMat(dat. 0. i. – Ng: reduce the number of gray levels to Ng as a preprocessing step. Copyright 2009. • Output: – P 0.Ng) • Description: Generates four co-occurrence matrices corresponding to the directions. 45.P 45. 4. one per feature.m because it implements a two-way scan for each direction. • Input: – dat: gray-level image (matrix). 4.Theodoridis. for the horizontal direction data are scanned both from left-to-right and from right-to-left. – NOTE : This function differs from Matlab’s graycomatrix. given a co-occurrence matrix. • Output: – features: a feature vector of 13 features..P 90. Pattern Recognition 4e. Page 21 21 4 4. Elsevier Inc .m • Syntax : [P 0. given a co-occurrence matrix. P 45. P 135 : the four co-occurrence matrices.1 Image Features generateCoOccMat. • Input: – coMat: the co-occurrence matrix.m • Syntax : [ASM]=CoOccASM(M) • Description: Computes the Angular Second Moment.P 90. This feature is a measure of the smoothness of the image.3 CoOccASM.

• Output: – variance: the value of Variance. • Input: – M : the co-occurrence matrix. Elsevier Inc . 4.e.Theodoridis. 4.4 CoOccContrast. Pattern Recognition 4e. This feature is a measure of the gray-level linear dependencies of an image.7 CoOccIDM. • Input: – M : the co-occurrence matrix.m • Syntax : [CON]=CoOccContrast(M) • Description: Computes the Contrast.m • Syntax : [COR]=CoOccCOR(M) • Description: Computes the Correlation. • Output: – CON : the value of contrast.5 CoOccCOR. Copyright 2009.m • Syntax : [variance]=CoOccVariance(M) • Description: Computes the Variance of a co-occurrence matrix. Page 22 22 4. • Output: – INV : the value of the Inverse Difference moment. i. a measure of local gray-level variations. This is a measure of the image contrast. 4.6 CoOccVariance.. • Input: – M : the co-occurrence matrix.m • Syntax : [INV]=CoOccIDM(M) • Description: Computes the Inverse Difference Moment of a co-occurrence matrix. • Input: – M : the co-occurrence matrix. • Output: – COR: the value of Correlation. given a co-occurrence matrix. given a co-occurrence matrix.

8 CoOccSUA. • Output: – SUE : the value of Sum Entropy. • Output: – SUA: the value of the Sum (Difference) Average.m • Syntax : [entropy]=CoOccEntropy(M) • Description: Computes the Entropy of a co-occurrence matrix.11 CoOccEntropy. • Input: – M : the co-occurrence matrix.m • Syntax : [SUV]=CoOccSUV(M) • Description: Computes the Sum Variance of a co-occurrence matrix. • Input: – M : the co-occurrence matrix.m • Syntax : [SUA]=CoOccSUA(M) • Description: Computes the Sum (Difference) Average of a co-occurrence matrix. 4.Theodoridis. 4.m • Syntax : [SUE]=CoOccSUE(M) • Description: Computes the Sum Entropy of a co-occurrence matrix. • Output: – entropy: the value of Entropy. Elsevier Inc .9 CoOccSUV. • Output: – SUV : the value of Sum Variance. Entropy is a measure of randomness and takes low values for smooth images. • Input: – M : the co-occurrence matrix. • Input: – M : the co-occurrence matrix. 4. Copyright 2009.10 CoOccSUE. Pattern Recognition 4e. Page 23 23 4.

m • Syntax : [DEN]=CoOccDEN(M) • Description: Computes the Difference Entropy. Page 24 24 4. given a co-occurrence matrix.Theodoridis. given a co-occurrence matrix. • Output: – DVA: the value of Difference Variance. 4. • Output: – CIMII : the value of the Information Measure II. Elsevier Inc . given a co-occurrence matrix. • Input: – M : the co-occurrence matrix.m • Syntax : [CIMI]=CoOccCIMI(M) • Description: Computes the Information Measure I. • Output: – CIMI : the value of the Information Measure I. Copyright 2009. 4.15 CoOccCIMII. • Input: – M : the co-occurrence matrix.m • Syntax : [CIMII]=CoOccCIMII(M) • Description: Computes the Information Measure II.12 CoOccDEN. Pattern Recognition 4e. 4.14 CoOccCIMI. given a co-occurrence matrix.13 CoOccDVA. • Output: – DEN : the value of Difference Entropy. • Input: – M : the co-occurrence matrix.m • Syntax : [DVA]=CoOccDVA(M) • Description: Computes the Difference Variance. • Input: – M : the co-occurrence matrix.

m • Syntax : [Px plus y]=CoOccPxplusY(M) • Description: It is used by other feature generation functions. 4. 4. Elsevier Inc .17 CoOccPXminusY. • Input: – M : the co-occurrence matrix. • Output: – Px plus y: vector formed by the sums of the diagonals of M at the direction of 45 degrees. Pattern Recognition 4e. • Input: – M : the co-occurrence matrix. Copyright 2009. • Input: – M : the co-occurrence matrix. py) • Description: It is used by other feature generation functions.py]=CoOccPXandPY (M.18 CoOccPxplusY. It generates probability matrices by scanning the diagonals of the co-occurrence matrix at 135 degrees.Theodoridis. – py: vector formed by sums of columns of co-occurrence matrix.16 CoOccPXandPY . Page 25 25 4. It generates probability matrices by scanning the diagonals of the co-occurrence matrix at 45 degrees. • Output: – px : vector formed by sums of rows of co-occurrence matrix. • Output: – Px minus y: vector formed by the sums of the diagonals of M at the direction of 135 degrees.m • Syntax : [px. It computes the marginal probability matrices by summing the rows (px) and columns (py) of the co-occurrence matrix.m • Syntax : [Px minus y]=CoOccPXminusY(M) • Description: It is used by other feature generation functions. px.

m • Syntax : [feat]=HistCentralMoments(dat. • Input: – dat: graylevel image (matrix).19 ImageHist. Pattern Recognition 4e. – Ng: desired number of gray levels. 4.Ng) • Description: Generates the histogram of a graylevel image for Ng levels of gray.21 HistCentralMoments.mom) • Description: Computes the moment of order mom from the histogram of a gray-level image. Page 26 26 4. • Output: – feat: the value of moment of order mom. Elsevier Inc . – mom: order of moment (integer ≥1). Copyright 2009.m • Syntax : [feat]=HistMoments(dat.Theodoridis.c mom) • Description: Computes the central moment of order c mom from the histogram of a gray-level image. – c mom: order of moment (integer ≥1). • Output: – feat: the value of moment of order c mom. 4. • Input: – dat: graylevel image (matrix). • Output: – h: histogram of the image (vector Ngx1). • Input: – A: gray-level image (matrix).m • Syntax : [h]=ImageHist(A.20 HistMoments.

– degrees: direction in degrees (45 or 135). Page 27 27 4.degrees) • Description: Generates the Run Length matrix from a gray-level image given the number of runs.N runs. Copyright 2009. 4.m • Syntax : [A]=LawMasks(kernelLength) • Description: Generates the Law Masks [Laws 80] given the kernel length (3 or 5). • Input: – m: gray-level image (matrix). Pattern Recognition 4e. • Input: – m: gray-level image (matrix) – N runs: number of runs. • Output: – Q: the resulting run length matrix.Ng.m • Syntax : [Q]=RL 45 135(m.m • Syntax : [Q]=RL 0 90(m. – degrees: direction in degrees (0 or 90). depending on the adopted kernel length. the levels of gray and the direction (45 or 135 degrees). • Input: – kernelLength: length of kernels (3 or 5).23 RL 0 90.Theodoridis.N runs.Ng.22 LawMasks. Elsevier Inc .degrees) • Description: Generates the Run Length matrix from a gray-level image given the number of runs. – N runs: number of runs. the levels of gray and the direction (0 or 90 degrees). 4.24 RL 45 135. • Output: – Q: the resulting run length matrix. • Output: – A: Cell array with 9 or 16 masks (matrices).

• Input: – M : the Run Length matrix. Elsevier Inc . • Output: – SRuEm: the value of Short-Run Emphasis. 4.27 GLNU. this feature takes small values. When runs are uniformly distributed among the gray levels. 4.Theodoridis. Copyright 2009.m • Syntax : [LRunEmph]=LRE(M) • Description: Computes the Long-Run Emphasis (LRE) from a Run Length matrix. • Output: – LRunEmph: the value of Long-Run Emphasis.m • Syntax : [GLNonUn]=GLNU(M) • Description: Computes the Gray-level Nonuniformity (GLNU) from a Run Length matrix. This feature is expected to be large for smoother images.25 SRE.26 LRE. • Input: – M : the Run Length matrix. • Output: – GLNonUn: the value of Gray-Level Nonuniformity. Page 28 28 4.m • Syntax : [SRuEm]=SRE(M) • Description: Computes the Short-Run Emphasis (SRE) from a Run Length matrix. • Input: – M : the Run Length matrix. Pattern Recognition 4e. This feature emphasizes small run lengths and it is thus expected to be large for coarser images.

28 RLNU. This feature takes low values for smooth images. Page 29 29 4. • Output: – RuPe: the value of Run Percentage. this feature is a measure of run length nonuniformity. • Input: – M : the Run Length matrix. Copyright 2009. Elsevier Inc .29 RP.m • Syntax : [RuPe]= RP(M) • Description: Computes the Run Percentage (RP) from a Run Length matrix.Theodoridis. • Output: – RLNonUn: the value of Run Length Nonuniformity. In a similar way to gray-level nonuniformity. Pattern Recognition 4e.m • Syntax : [RLNonUn]=RLNU(M) • Description: Computes the Run Length Nonuniformity (RLN) from a Run Length matrix. • Input: – M : the Run Length matrix. 4.

– Fs: sampling frequency (Hz).m • Syntax : [Fr]=sfFundAMDF(x.3 sfFundAMDF. – RolloffThresh: rolloff threshold. • Input: – x : signal frame (sequence of samples). Page 30 30 5 5.Fs) • Description: Computes the Spectral Centroid of a single frame. • Input: – x : signal frame (sequence of samples).m • Syntax : [Sc]=sfSpectralCentroid(x.Theodoridis. • Output: – Sr : rolloff frequency (Hz). – Fs: sampling frequency (Hz). • Input: – x : signal frame (sequence of samples). 5. Pattern Recognition 4e.2 sfSpectralRolloff.RolloffThresh) • Description: Computes the Spectral Rolloff frequency of a single frame given a rolloff threshold.Tmin. Copyright 2009. • Output: – Fr : fundamental frequency (Hz). 5. – Fs: sampling frequency (Hz).1 Audio Features sfSpectralCentroid.Fs. Elsevier Inc . • Output: – Sc: spectral centroid (Hz). 0≤RolloffThresh≤1.Fs.m • Syntax : [Sr]=sfSpectralRolloff(x. – Tmax : maximum period length (in samples). – Tmin: minimum period length (in samples).Tmax) • Description: Computes the fundamental frequency of a single frame using the Average Magnitude Difference Function for periodicity detection [Rabi 78].

Fs. • Input: – x : signal frame (sequence of samples). – Tmax : maximum period length (in samples). – Fs: sampling frequency (Hz). • Input: – x : signal frame (sequence of samples).Tmax) • Description: Computes the fundamental frequency of a single frame using the cepstrum coefficients [Rabi 78].m • Syntax : [Fr]=sfFundCepstrum(x. Elsevier Inc . – Tmin: minimum period length (in samples). Copyright 2009. – Tmin: minimum period length (in samples). – Tmax : maximum period length (in samples). Requires function rceps of Matlab’s Signal Processing Toolbox.Tmin. 5.6 sfFundFreqHist. Pattern Recognition 4e. – Fs: sampling frequency (Hz). The frequency histogram is generated by taking into account only the spectral peaks (local maxima). Page 31 31 5.4 sfFundAutoCorr.5 sfFundCepstrum. • Input: – x : signal frame (sequence of samples). • Output: – Fr : fundamental frequency (Hz).m • Syntax : [Fund.F2.Fs. – F1 : minimum funamental frequency (Hz).NumOfPeaks) • Description: Computes the fundamental frequency of a single frame using Schroeder’s frequency histogram [Schr 68]. 5.m • Syntax : [Fr]=sfFundAutoCorr(x.Theodoridis. • Output: – Fr : fundamental frequency (Hz).Fs.Tmin.Tmax) • Description: Computes the fundamental frequency of a single frame using the autocorrelation function for periodicity detection [Rabi 78].FinalHist]=sfFundFreqHist(x.F1. – Fs: sampling frequency (Hz).

– melStep: distance between successive centers of the filter-bank (mel units). the center frequency and frequency range for each filter in the filter-bank need to be computed. The length of Y is equal to the length of the frame. Elsevier Inc . Prior to using this function. • Output: – Fund : fundamental frequency (Hz). – Y : output of the filter bank after insertion of zeros has taken place.8 computeMelBank. The i-th row contains three values for the i-th filter of the filter-bank. This can be achieved by first calling function computeMelBank and pass its output to the bins variable of this m-file. lowest frequency. – Fs: sampling frequency (Hz). 5. – bins: Mel filter-bank (see computeMelBank for details). center frequency and rightmost frequency. – FinalHist: frequency histogram.7 sfMFCCs.e. • Output: – cMel : the MFCCs. 5.Theodoridis. – NumOfPeaks: number of spectral peaks to be taken into account. • Output: – bins: filter-bank matrix. – Fs: sampling frequency (Hz).. assuming triangular non-overlapping filters.bins) • Description: Computes the Mel-frequency cepstrum coefficients (MFCCs) from a single frame of data. Page 32 32 – F2 : maximum fundamental frequency (Hz). Pattern Recognition 4e.m • Syntax : [bins]=computeMelBank(N.Fs. • Input: – N : number of FFT coefficients. assuming a filter-bank of triangular non-overlapping filters.Fs.melStep) • Description: Computes the frequency centers and frequency limits of the filters of a Mel filter-bank.Y]=sfMFCCs(x. The number of MFCCs is equal to the length of the frame. • Input: – x : signal frame (sequence of samples). This function computes the frequencies of the FFT of a N-point frame and then shifts the frequency centers of the filter-bank to the closest FFT frequency. i. Copyright 2009.m • Syntax : [cMel.

• Input: – x : signal (sequence of samples).11 stSpectralCentroid. – winstep: step of the moving window (number of samples).Fs. – T : time equivalent of the first sample of each window. • Output: – Zcr : zero-crossing rate sequence of values. – Fs: sampling frequency (Hz).m • Syntax : [Zcr.Theodoridis.T]=stEnergy(x.T]=stSpectralCentroid(x.winstep) • Description: Computes the short-term energy envelop.m • Syntax : [E.10 stZeroCrossingRate. • Input: – x : signal (sequence of samples).Fs.T]=stZeroCrossingRate(x. Page 33 33 5. – winstep: step of the moving window (number of samples).winstep) • Description: Computes the short-term zero-crossing rate. – Fs: sampling frequency (Hz). Pattern Recognition 4e.9 stEnergy. – winlength: length of the moving window (number of samples).Fs. – T : time equivalent of the first sample of each window. • Output: – E : sequence of short-term energy values.winstep. – Fs: sampling frequency (Hz). Copyright 2009. – winlength: length of the moving window (number of samples).windowMultiplier) • Description: Computes the short-term spectral centroid by calling the MovingWindow function.m • Syntax : [Sc. • Input: – x : signal (sequence of samples). – winstep: step of the moving window (number of samples). 5. Elsevier Inc .winlength.winlength. 5. – winlength: length of the moving window (number of samples).winlength.

– winstep: step of the moving window (number of samples). – Fs: sampling frequency (Hz).Fs.winstep..m • Syntax : [Sf.. Pattern Recognition 4e.windowMultiplier. i. – Fs: sampling frequency (Hz). 5.13 stSpectralFlux. • Output: – Sr : sequence of spectral rolloff values.winstep.windowMultiplier) • Description: Computes the short-term spectral flux. • Output: – Sc: sequence of spectral centtroids. any valid Matlab window multiplier (or [] for rectangular window). etc.m • Syntax : [Sr.e. etc. • Output: – Sf : sequence of spectral flux values.RolloffThresh) • Description: Computes the short-term spectral rolloff feature by calling the MovingWindow function. any valid Matlab window multiplier (or [] for rectangular window). Page 34 34 – windowMultiplier : use ’hamming’. i.12 stSpectralRolloff.T]=stSpectralRolloff(x. ’hanning’. any valid Matlab window multiplier (or [] for rectangular window).Theodoridis.T]=stSpectralFlux(x.winlength.winlength. – winlength: length of the moving window (number of samples). – T : time equivalent of the first sample of each window. – T : time equivalent of the first sample of each window.. Copyright 2009..Fs.. – winstep: step of the moving window (number of samples). 5. Elsevier Inc . i. – winlength: length of the moving window (number of samples). • Input: – x : signal (sequence of samples).e. ’hanning’.. • Input: – x : signal (sequence of samples). – windowMultiplier : use ’hamming’. – T : time equivalent of the first sample of each window. – windowMultiplier : use ’hamming’. ’hanning’.e. etc.

Theodoridis.T]=stFundAMDF(x. – winlength: length of the moving window (number of samples). – windowMultiplier : use ’hamming’. • Input: – x : signal (sequence of samples).winlength.windowMultiplier. – windowMultiplier : use ’hamming’. • Output: – MelCepsMat: matrix of Mel-cepstrum coefficients. Page 35 35 5. i. any valid Matlab window multiplier (or [] for rectangular window). It calls computeMelBank to compute the center frequencies and frequency range of each filter in the mel filter-bank.windowMultiplier. – T : time equivalent of the first sample of each window. Pattern Recognition 4e.Fs.T]=stMelCepstrum(x. Copyright 2009.winstep. – Fs: sampling frequency (Hz). ’hanning’.15 stMelCepstrum. – Tmin: minimum period length (in samples). etc.e. – melStep: distance between the center frequencies of successive filters in the Mel filter-bank (mel units). one column per frame.e. – winstep: step of the moving window (number of samples).m • Syntax : [Fr. ’hanning’.Fs.Tmin.. Elsevier Inc .melStep) • Description: This function computes the short-term Mel Cepstrum. – winstep: step of the moving window (number of samples).winstep.Tmax) • Description: Fundamental Frequency Tracking using the Average Magnitude Difference Function [Rabi 78]..winlength. – winlength: length of the moving window (number of samples). – Tmax : maximum period length (in samples).14 stFundAMDF.. – Fs: sampling frequency (Hz). i. any valid Matlab window multiplier (or [] for rectangular window). – T : time equivalent of the first sample of each window.. 5.m • Syntax : [MelCepsMat. etc. • Input: – x : signal (sequence of samples). • Output: – Fr : sequence of fundamental frequencies (Hz).

T]=stFundFreqHist(x. Elsevier Inc . – F1 : minimum funamental frequency (Hz). 5.Tmin. – T : time equivalent of the first sample of each window. • Input: – x : signal (sequence of samples).Tmax) • Description: Autocorrelation-based Fundamental Frequency Tracking [Rabi 78].. ’hanning’.T]=stFundAutoCorr(x. – NumOfPeaks: number of spectral peaks to take into account for the histogram generation. This function calls MovingWindow. • Output: – FundFreqs: sequence of fundamental frequencies (Hz).winstep.NumOfPeaks) • Description: Fundamental Frequency Tracking based on Schroeder’s Histogram method [Schr 68]. – windowMultiplier : use ’hamming’. ’hanning’. – Fs: sampling frequency (Hz). etc. – windowMultiplier : use ’hamming’.F2. – Tmin: minimum period length (in samples)..Fs. Pattern Recognition 4e. i.Fs.17 stFundAutoCorr.winstep.. – F2 : maximum fundamental frequency (Hz).windowMultiplier.Theodoridis. • Output: – Fr : sequence of fundamental frequencies (Hz).. i.e. etc. – T : time equivalent of the first sample of each window.winlength. – Fs: sampling frequency (Hz). Copyright 2009. • Input: – x : signal (sequence of samples). – winlength: length of the moving window (number of samples).winlength.m • Syntax : [FundFreqs.windowMultiplier. – Tmax : maximum period length (in samples). any valid Matlab window multiplier (or [] for rectangular window).m • Syntax : [Fr.e.16 stFundFreqHist. – winstep: step of the moving window (number of samples). – winlength: length of the moving window (number of samples). – winstep: step of the moving window (number of samples). Page 36 36 5. any valid Matlab window multiplier (or [] for rectangular window).F1.

– winstep: step of the moving window (number of samples).Tmax) • Description: Cepstrum-based Fundamental Frequency Tracking [Rabi 78].Theodoridis.winlength. – GenPlot (optional): if set to 1. 5. etc. Page 37 37 5.windowMultiplier.Fs. Pattern Recognition 4e. – winstep: step of the moving window (number of samples). – windowMultiplier : use ’hamming’. • Input: – x : signal (sequence of samples).Tmin. – Fs: sampling frequency (Hz).19 stFourierTransform.. any valid Matlab window multiplier (or [] for rectangular window). • Output: – StftMat: matrix of Short Time Fourier Transform coefficients (one column per frame). – winlength: length of the moving window (number of samples).Fs. Copyright 2009.18 stFundCepstrum. – T : time equivalent of the first sample of each window. ’hanning’.m • Syntax : [Fr.windowMultiplier. – winlength: length of the moving window (number of samples).Freqs. – windowMultiplier : use ’hamming’.GenPlot) • Description: Short-time Fourier Transform of a signal..winstep.e. any valid Matlab window multiplier (or [] for rectangular window).m • Syntax : [StftMat. a plot spectrogram is generated. • Input: – x : signal (sequence of samples). – T : time equivalent of the first sample of each window. ’hanning’.winlength. i. – Fs: sampling frequency (Hz). – Freqs: multiples of Fs/winlength (vector of frequencies)...winstep. Elsevier Inc . i.e. – Tmin: minimum period length (in samples). – Tmax : maximum period length (in samples).T]=stFundCepstrum(x.T]=stFourierTransform(x. • Output: – Fr : sequence of fundamental frequencies (Hz). etc.

The real part of Pred(i. j). Its size is m × I. Elsevier Inc . Page 38 38 6 6.2 DTWSakoe. The first argument is the prototype. • Output: – editCost: the matching cost. No end-point contstraints have been adopted. j) is the row index of the predecessor of node (i. it is divided with the length of the best path.1 Dynamic Time Warping editDistance.m • Syntax : [editCost.Theodoridis. 6. – BestPath: backtracking path. Its size is I × J. i. • Output: – MatchingCost: matching cost. Copyright 2009.testStr) • Description: Computes the edit (Levenstein) distance between two strings. – Pred : matrix of node predecessors. i) is the row index of the predecessor of node (j.m to extract the best path.e. The function employs the SakoeChiba local constraints on a cost grid. which is placed on the vertical axis of the matching grid..test) • Description: Computes the Dynamic Time Warping cost between two feature sequences. where the real part stands for the row index and the imaginary part stands for the column index of the node.Pred]=editDistance(refStr. – D: cost grid. The matching cost is normalized. j) and the imaginary part of Pred(i. Its size is m × J. This function calls BackTracking. j) is the column index of the predecessor of node (i. – Pred : matrix of node predecessors.BestPath. where m is the number of features and I the number of feature vectors. • Input: – ref : reference sequence. – testStr : string to compare with prototype. Pattern Recognition 4e.m • Syntax : [MatchingCost. where the first argument is the reference string (prototype). a plot of the best path is generated.D.Pred]=DTWSakoe(ref. where the Euclidean distance has been used as the distance metric. – test: test sequence. i) is the column index of the predecessor of node (j. Each node of the best path is represented as a complex number. i) and the imaginary part of Pred(j. – genPlot: if set to 1. The prototype is placed on the horizontal axis of the matching grid. The real part of Pred(j. i). where m is the number of features and J the number of feature vectors. • Input: – refStr : reference string.

e. j) is the column index of the predecessor of node (i. This function calls BackTracking. The function employs the standard Itakura local constraints on a cost grid. – genPlot: if set to 1. where m is the number of features and I the number of feature vectors. • Output: – MatchingCost: matching cost.Theodoridis.Pred]=DTWItakura(ref.3 DTWSakoeEndp. Its size is I × J. This is the number of frames that can be omitted from the end of the test sequence. j). End-points contstraints are permitted for the test sequence.Pred]=DTWSakoeEndp(ref. where the real part stands for the row index and the imaginary part stands for the column index of the node.omitRight) • Description: Computes the Dynamic Time Warping cost between two feature sequences. a plot of the best path is generated. i. where l is the number of features and J the number of feature vectors. This is the number of frames that can be omitted from the beginning of the test sequence. – BestPath: backtracking path. This function calls BackTracking. The first argument is the prototype which is placed on the vertical axis of the matching grid. which is placed on the vertical axis of the matching grid.D. The function employs the SakoeChiba local constraints on a type N cost grid.BestPath.test..4 DTWItakura. Its size is m × I. The matching cost is normalized. Each node of the best path is represented as a complex number. – D: cost grid. Elsevier Inc . where the Euclidean distance has been used as the distance metric.BestPath. Copyright 2009. Page 39 39 6. • Input: – ref : reference sequence Its size is m × I. 6. where the Euclidean distance has been used as the distance metric.m • Syntax : [MatchingCost. Its size is m × J. is divided with the length of the best path. – test: test sequence. – omitLeft: left endpoint constraint for the test sequence. – Pred : matrix of node predecessors. The first argument is the prototype.omitLeft. No end-points contstraints have been adopted.m to extract the best path.m to extract the best path.test) • Description: Computes the Dynamic Time Warping cost between two feature sequences. • Input: – ref : reference sequence. Pattern Recognition 4e. j) is the row index and the imaginary part of Pred(i. – omitRight: right endpoint constraint for the test sequence.D. where m is the number of features and I the number of feature vectors.m • Syntax : [MatchingCost. The real part of Pred(i.

where m is the number of features and I the number of feature vectors. j).m • Syntax : [MatchingCost. This is the number of frames that can be omitted from the end of the test sequence. j). where the real part stands for the row index and the imaginary part stands for the column index of the node. where the Euclidean distance has been used as the distance metric. Each node of the best path is represented as a complex number.e. – genPlot: if set to 1. • Output: – MatchingCost: matching cost. Elsevier Inc . The matching cost is normalized. The function employs the standard Itakura local constraints on a cost grid..e. • Output: – MatchingCost: matching cost. j) is the row index and the imaginary part of Pred(i. – Pred : matrix of node predecessors. i.omitLeft. is divided with the length of the best path. a plot of the best path is generated.D. The size is m × J. – omitLeft: left endpoint constraint for the test sequence. The real part of Pred(i. Its size is I × J. This function calls function BackTracking.omitRight) • Description: Computes the Dynamic Time Warping cost between two feature sequences. The real part of Pred(i. – omitRight: right endpoint constraint for the test sequence. Its size is m × I. – test: test sequence. – D: cost grid. This is the number of frames that can be omitted from the beginning of the test sequence. • Input: – ref : reference sequence. 6. Its size is m × J.5 DTWItakuraEndp. – BestPath: backtracking path. where the real part stands for the row index and the imaginary part stands for the column index of the node. Each node of the best path is represented as a complex number.Pred]=DTWItakuraEndp(ref.test. where m is the number of features and J the number of feature vectors. which is placed on the vertical axis of the matching grid. j) is the row index and the imaginary part of Pred(i. it is divided by the length of the best path. a plot of the best path is generated. – D: cost grid.BestPath. Its size is I × J. – Pred : matrix of node predecessors. j) is the column index of the predecessor of node (i. i. – BestPath: backtracking path. Pattern Recognition 4e. End-points contstraints are permitted for the test sequence.m to extract the best path. where m is the number of features and J the number of feature vectors. j) is the column index of the predecessor of node (i. Page 40 40 – test: test sequence.. Copyright 2009. The matching cost is normalized.Theodoridis. The first argument is the prototype. – genPlot: if set to 1.

Theodoridis. Pattern Recognition 4e. j). Page 41 41 6.. – genPlot: if set to 1. j) is the row index of the predecessor of node (i. • Output: – BestPath: backtracking path.startNodel). a plot of the best path is generated. The imaginary part of Pred(i. Copyright 2009. – startNodel : column index of node from which backtracking starts. Each node is represented as a complex number where the real part stands for the row index of the node and the imaginary part stands for the column index of the node. The best path can be optionally plotted. j).startNodek. j) is the column index of the predecessor of node (i. The real part of Pred(i. • Input: – Pred : matrix of node predecessors.e.6 BackTracking.m • Syntax : [BestPath]=BackTracking(Pred.startNodel) • Description: Performs backtracking on a matrix of node predecessors and returns the extracted best path starting from node (startNodek. Elsevier Inc . – startNodek : row index of node from which backtracking starts. vector of nodes. i.

“Period histogram and product spectrum: New methods for fundamental frequency measurement. Pattern Recognition 4e. 1968. Texture image segmentation. Thesis. Ph. Page 42 42 References [Theo 09] S. Laws. 1978.Theodoridis. 2009. Elsevier Inc . Theodoridis. R. 4th edition. Schroeder. Rabiner. [Rabi 78] L. [Laws 80] K.I.R. Copyright 2009. 43(4). University of Southern California. 829-834. 1980.W Schafer. Digital Processing of Speech Signals. Vol.D.R. Prentice Hall. pp. [Schr 68] M. K. Pattern Recognition. Academic Press. Koutroumbas.” Journal of Acoustical Society of America.

Sign up to vote on this title
UsefulNot useful