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

which are given here as well as those available in the matlab toolboxes. Theodoridis K. Koutroumbas D. statistical toolbox and image processing toolbox. Pikrakis S. Pattern Recognition 4e. We would appreciate any comments from the readers and we are happy to try to accomodate them. Currently. e. This book will be based on routines. 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.Theodoridis. Examples are the routines related to Support Vector Machines. etc. A. Elsevier Inc . k-NN classifier. 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 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.g. a companion book is being developed including short descriptions of theory as well as a number of Matlab excercises.. Cavouras Copyright 2009.

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

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

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

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

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

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

Copyright 2009.m.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. produced by an l × N dimensional matrix X. the j-th column of which corresponds to the j-th smallest eigenvalue of L. However. the representatives are moved towards regions that are “dense” in data vectors. all representatives move towards X(:.e.i) than the rest representatives.12 competitive.init proc) • Description: This function implements the competitive leaky learning algorithm. the representatives are initialized by the algorithm. Page 12 12 2.i). (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”. the closest representative moves much closer to X(:. i-th data vector X(:.Theodoridis. Pattern Recognition 4e. each column of which corresponds to a data vector. The algorithm determines a k × N dimensional matrix V. • 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.11 spectral Ratiocut gt2. • Input: – X : an l × N dimensional matrix each row of which is a data vector. Then.w ini.eta vec.m • Syntax : [bel]=spectral Ratiocut gt2(X. the learning rate for the one that lies closer to X(:. the data vectors X(:. Finally. • Input: – X : an l × N dimensional matrix containing the data points. – e: the parameter that defines the size of the neighborhood around each vector. It is an iterative algorithm where the representatives are updated after the presentation of each data vector X(:. In this way. Specifically. IMPORTANT NOTE: In this implementation.max epoch. – k : the number of clusters.i) is mapped to the i-th row vector V(i.sed.k) • Description: This function performs spectral clustering based on the N × N dimensional unnormalized graph Laplacian L.e thres.i)’s are clustered based on the clustering produced by the k-means algorithm that is applied on V(i. If it is empty.:) of V. – 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). As a consequence.i). Elsevier Inc .:)’s.m • Syntax : [w.bel. The algorithm minimizes the so-called Ratiocut criterion.epoch]=competitive(X. The number of clusters.i) (winner) is much higher than the learning rate for the rest representatives (losers). The number of representatives is assumed to be known. k. 2. is again assumed to be known (it may be greater or equal to 2). – w ini : an l × m dimensional matrix containing the initial estimates of the representatives.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful