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

Pattern Recognition 4e. Pikrakis S. Koutroumbas D. etc. This book will be based on routines. Examples are the routines related to Support Vector Machines. Elsevier Inc . which are given here as well as those available in the matlab toolboxes. Cavouras Copyright 2009. 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.Theodoridis. We would appreciate any comments from the readers and we are happy to try to accomodate them. 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.g. statistical toolbox and image processing toolbox. Currently. Theodoridis K. Page 5 5 1 Preface The Matlab m-files that are provided here are intended to satisfy pedagogical needs. e. We have not covered all the algorirhms that are described in the book. A. a companion book is being developed including short descriptions of theory as well as a number of Matlab excercises.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Sign up to vote on this title
UsefulNot useful