forked from areslp/matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,612 changed files
with
97,161 additions
and
7,328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
% Normalized Cut Segmentation Code % | ||
% % | ||
% Timothee Cour (INRIA), Stella Yu (Berkeley), Jianbo Shi (UPENN) % | ||
% % | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
||
License | ||
This software is made publicly for research use only. It may be modified and redistributed under the terms of the GNU General Public License. | ||
|
||
Citation | ||
Please cite the following if you plan to use the code in your own work: | ||
* Normalized Cuts and Image Segmentation, Jianbo Shi and Jitendra Malik, IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI) 2000 | ||
* Normalized Cut Segmentation Code, Timothee Cour, Stella Yu, Jianbo Shi. Copyright 2004 University of Pennsylvania, Computer and Information Science Department. | ||
|
||
Tested on matlab R2009b. | ||
|
||
Installation Notes : | ||
|
||
1) After you unzipped the files to mydir, | ||
put the Current Directory in Matlab to mydir | ||
|
||
2) In the matlab command prompt, | ||
type compileDir_simple to compile the mex files (ignore the error on the C++ non-mex file; needs to be done once) | ||
|
||
3) You can now try any of the functions | ||
|
||
type demoNcutImage to see a demo of image segmentation | ||
type demoNcutClustering to see a demo of point cloud clustering | ||
|
||
|
||
Other top level functions: | ||
|
||
NcutImage.m: given image "I", segment it into "nbSegments" segments | ||
[SegLabel,NcutDiscrete,NcutEigenvectors,NcutEigenvalues,W]= NcutImage(I,nbSegments); | ||
|
||
ICgraph.m: compute Intervening Contour based pixel similarity matrix W | ||
W = ICgraph(I); | ||
|
||
ncutW.m: Given a similarity graph "W", computes Ncut clustering on the graph into "nbSegments" groups; | ||
[NcutDiscrete,NcutEigenvectors,NcutEigenvalues] = ncutW(W,nbSegments); | ||
|
||
|
||
Release notes: | ||
|
||
2010, January 22: release of all c++ source mex files compatible with matlab R2009b | ||
2006, May 04: release version 8: fixed incompatibility issues with new matlab | ||
2004, June 18: release version 7: initial release | ||
|
||
Maintained by Timothee Cour, timothee dot cour at gmail dot com | ||
|
||
January 22, 2010. |
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
LANBPRO Lanczos bidiagonalization with partial reorthogonalization. | ||
|
||
LANBPRO computes the Lanczos bidiagonalization of a real | ||
matrix using the with partial reorthogonalization. | ||
|
||
[U_k,B_k,V_k,R,ierr,work] = LANBPRO(A,K,R0,OPTIONS,U_old,B_old,V_old) | ||
[U_k,B_k,V_k,R,ierr,work] = LANBPRO('Afun','Atransfun',M,N,K,R0, ... | ||
OPTIONS,U_old,B_old,V_old) | ||
|
||
Computes K steps of the Lanczos bidiagonalization algorithm with partial | ||
reorthogonalization (BPRO) with M-by-1 starting vector R0, producing a | ||
lower bidiagonal K-by-K matrix B_k, an N-by-K matrix V_k, an M-by-K | ||
matrix U_k and a M-by-1 vector such that | ||
A*V_k = U_k*B_k + R | ||
Partial reorthogonalization is used to keep the columns of V_K and U_k | ||
semiorthogonal: | ||
MAX(DIAG((EYE(K) - V_K'*V_K))) <= OPTIONS.delta | ||
and | ||
MAX(DIAG((EYE(K) - U_K'*U_K))) <= OPTIONS.delta. | ||
|
||
B_k = LANBPRO(...) returns the bidiagonal matrix only. | ||
|
||
The first input argument is either a real matrix, or a string | ||
containing the name of an M-file which applies a linear operator | ||
to the columns of a given matrix. In the latter case, the second | ||
input must be the name of an M-file which applies the transpose of | ||
the same linear operator to the columns of a given matrix, | ||
and the third and fourth arguments must be M and N, the dimensions | ||
of then problem. | ||
|
||
The OPTIONS structure is used to control the reorthogonalization: | ||
OPTIONS.delta: Desired level of orthogonality | ||
(default = sqrt(eps/K)). | ||
OPTIONS.eta : Level of orthogonality after reorthogonalization | ||
(default = eps^(3/4)/sqrt(K)). | ||
OPTIONS.cgs : Flag for switching between different reorthogonalization | ||
algorithms: | ||
0 = iterated modified Gram-Schmidt (default) | ||
1 = iterated classical Gram-Schmidt | ||
OPTIONS.elr : If OPTIONS.elr = 1 (default) then extended local | ||
reorthogonalization is enforced. | ||
OPTIONS.onesided | ||
: If OPTIONS.onesided = 0 (default) then both the left | ||
(U) and right (V) Lanczos vectors are kept | ||
semiorthogonal. | ||
OPTIONS.onesided = 1 then only the columns of U are | ||
are reorthogonalized. | ||
OPTIONS.onesided = -1 then only the columns of V are | ||
are reorthogonalized. | ||
OPTIONS.waitbar | ||
: The progress of the algorithm is display graphically. | ||
|
||
If both R0, U_old, B_old, and V_old are provided, they must | ||
contain a partial Lanczos bidiagonalization of A on the form | ||
|
||
A V_old = U_old B_old + R0 . | ||
|
||
In this case the factorization is extended to dimension K x K by | ||
continuing the Lanczos bidiagonalization algorithm with R0 as a | ||
starting vector. | ||
|
||
The output array work contains information about the work used in | ||
reorthogonalizing the u- and v-vectors. | ||
work = [ RU PU ] | ||
[ RV PV ] | ||
where | ||
RU = Number of reorthogonalizations of U. | ||
PU = Number of inner products used in reorthogonalizing U. | ||
RV = Number of reorthogonalizations of V. | ||
PV = Number of inner products used in reorthogonalizing V. | ||
|
||
References: | ||
R.M. Larsen, Ph.D. Thesis, Aarhus University, 1998. | ||
|
||
G. H. Golub & C. F. Van Loan, "Matrix Computations", | ||
3. Ed., Johns Hopkins, 1996. Section 9.3.4. | ||
|
||
B. N. Parlett, ``The Symmetric Eigenvalue Problem'', | ||
Prentice-Hall, Englewood Cliffs, NJ, 1980. | ||
|
||
H. D. Simon, ``The Lanczos algorithm with partial reorthogonalization'', | ||
Math. Comp. 42 (1984), no. 165, 115--142. | ||
|
||
|
||
Rasmus Munk Larsen, DAIMI, 1998. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
LANEIG Compute a few eigenvalues and eigenvectors. | ||
LANEIG solves the eigenvalue problem A*v=lambda*v, when A is | ||
real and symmetric using the Lanczos algorithm with partial | ||
reorthogonalization (PRO). | ||
|
||
[V,D] = LANEIG(A) | ||
[V,D] = LANEIG('Afun',N) | ||
|
||
The first input argument is either a real symmetric matrix, or a | ||
string containing the name of an M-file which applies a linear | ||
operator to the columns of a given matrix. In the latter case, | ||
the second input argument must be N, the order of the problem. | ||
|
||
The full calling sequence is | ||
|
||
[V,D,ERR] = LANEIG(A,K,SIGMA,OPTIONS) | ||
[V,D,ERR] = LANEIG('Afun',N,K,SIGMA,OPTIONS) | ||
|
||
On exit ERR contains the computed error bounds. K is the number of | ||
eigenvalues desired and SIGMA is numerical shift or a two letter string | ||
which specifies which part of the spectrum should be computed: | ||
|
||
SIGMA Specified eigenvalues | ||
|
||
'AL' Algebraically Largest | ||
'AS' Algebraically Smallest | ||
'LM' Largest Magnitude (default) | ||
'SM' Smallest Magnitude (does not work when A is an m-file) | ||
'BE' Both Ends. Computes k/2 eigenvalues | ||
from each end of the spectrum (one more | ||
from the high end if k is odd.) | ||
|
||
The OPTIONS structure specifies certain parameters in the algorithm. | ||
|
||
Field name Parameter Default | ||
|
||
OPTIONS.tol Convergence tolerance 16*eps | ||
OPTIONS.lanmax Dimension of the Lanczos basis. | ||
OPTIONS.v0 Starting vector for the Lanczos rand(n,1)-0.5 | ||
iteration. | ||
OPTIONS.delta Level of orthogonality among the sqrt(eps/K) | ||
Lanczos vectors. | ||
OPTIONS.eta Level of orthogonality after 10*eps^(3/4) | ||
reorthogonalization. | ||
OPTIONS.cgs reorthogonalization method used 0 | ||
'0' : iterated modified Gram-Schmidt | ||
'1' : iterated classical Gram-Schmidt | ||
OPTIONS.elr If equal to 1 then extended local 1 | ||
reorthogonalization is enforced. | ||
|
||
See also LANPRO, EIGS, EIG. | ||
|
||
References: | ||
R.M. Larsen, Ph.D. Thesis, Aarhus University, 1998. | ||
|
||
B. N. Parlett, ``The Symmetric Eigenvalue Problem'', | ||
Prentice-Hall, Englewood Cliffs, NJ, 1980. | ||
|
||
H. D. Simon, ``The Lanczos algorithm with partial reorthogonalization'', | ||
Math. Comp. 42 (1984), no. 165, 115--142. | ||
|
||
Rasmus Munk Larsen, DAIMI, 1998 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
LANPRO Lanczos tridiagonalization with partial reorthogonalization | ||
LANPRO computes the Lanczos tridiagonalization of a real symmetric | ||
matrix using the symmetric Lanczos algorithm with partial | ||
reorthogonalization. | ||
|
||
[Q_K,T_K,R,ANORM,IERR,WORK] = LANPRO(A,K,R0,OPTIONS,Q_old,T_old) | ||
[Q_K,T_K,R,ANORM,IERR,WORK] = LANPRO('Afun',N,K,R0,OPTIONS,Q_old,T_old) | ||
|
||
Computes K steps of the Lanczos algorithm with starting vector R0, | ||
and returns the K x K tridiagonal T_K, the N x K matrix Q_K | ||
with semiorthonormal columns and the residual vector R such that | ||
|
||
A*Q_K = Q_K*T_K + R . | ||
|
||
Partial reorthogonalization is used to keep the columns of Q_K | ||
semiorthogonal: | ||
MAX(DIAG((eye(k) - Q_K'*Q_K))) <= OPTIONS.delta. | ||
|
||
|
||
The first input argument is either a real symmetric matrix, a struct with | ||
components A.L and A.U or a string containing the name of an M-file which | ||
applies a linear operator to the columns of a given matrix. In the latter | ||
case, the second input argument must be N, the order of the problem. | ||
|
||
If A is a struct with components A.L and A.U, such that | ||
L*U = (A - sigma*I), a shift-and-invert Lanczos iteration is performed | ||
|
||
The OPTIONS structure is used to control the reorthogonalization: | ||
OPTIONS.delta: Desired level of orthogonality | ||
(default = sqrt(eps/K)). | ||
OPTIONS.eta : Level of orthogonality after reorthogonalization | ||
(default = eps^(3/4)/sqrt(K)). | ||
OPTIONS.cgs : Flag for switching between different reorthogonalization | ||
algorithms: | ||
0 = iterated modified Gram-Schmidt (default) | ||
1 = iterated classical Gram-Schmidt | ||
OPTIONS.elr : If OPTIONS.elr = 1 (default) then extended local | ||
reorthogonalization is enforced. | ||
OPTIONS.Y : The lanczos vectors are reorthogonalized against | ||
the columns of the matrix OPTIONS.Y. | ||
|
||
If both R0, Q_old and T_old are provided, they must contain | ||
a partial Lanczos tridiagonalization of A on the form | ||
|
||
A Q_old = Q_old T_old + R0 . | ||
|
||
In this case the factorization is extended to dimension K x K by | ||
continuing the Lanczos algorithm with R0 as starting vector. | ||
|
||
On exit ANORM contains an approximation to ||A||_2. | ||
IERR = 0 : K steps were performed succesfully. | ||
IERR > 0 : K steps were performed succesfully, but the algorithm | ||
switched to full reorthogonalization after IERR steps. | ||
IERR < 0 : Iteration was terminated after -IERR steps because an | ||
invariant subspace was found, and 3 deflation attempts | ||
were unsuccessful. | ||
On exit WORK(1) contains the number of reorthogonalizations performed, and | ||
WORK(2) contains the number of inner products performed in the | ||
reorthogonalizations. | ||
|
||
See also LANEIG, REORTH, COMPUTE_INT | ||
|
||
References: | ||
R.M. Larsen, Ph.D. Thesis, Aarhus University, 1998. | ||
|
||
G. H. Golub & C. F. Van Loan, "Matrix Computations", | ||
3. Ed., Johns Hopkins, 1996. Chapter 9. | ||
|
||
B. N. Parlett, ``The Symmetric Eigenvalue Problem'', | ||
Prentice-Hall, Englewood Cliffs, NJ, 1980. | ||
|
||
H. D. Simon, ``The Lanczos algorithm with partial reorthogonalization'', | ||
Math. Comp. 42 (1984), no. 165, 115--142. | ||
|
||
Rasmus Munk Larsen, DAIMI, 1998 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
LANSVD Compute a few singular values and singular vectors. | ||
LANSVD computes singular triplets (u,v,sigma) such that | ||
A*u = sigma*v and A'*v = sigma*u. Only a few singular values | ||
and singular vectors are computed using the Lanczos | ||
bidiagonalization algorithm with partial reorthogonalization (BPRO). | ||
|
||
S = LANSVD(A) | ||
S = LANSVD('Afun','Atransfun',M,N) | ||
|
||
The first input argument is either a matrix or a | ||
string containing the name of an M-file which applies a linear | ||
operator to the columns of a given matrix. In the latter case, | ||
the second input must be the name of an M-file which applies the | ||
transpose of the same operator to the columns of a given matrix, | ||
and the third and fourth arguments must be M and N, the dimensions | ||
of the problem. | ||
|
||
[U,S,V] = LANSVD(A,K,'L',...) computes the K largest singular values. | ||
|
||
[U,S,V] = LANSVD(A,K,'S',...) computes the K smallest singular values. | ||
|
||
The full calling sequence is | ||
|
||
[U,S,V] = LANSVD(A,K,SIGMA,OPTIONS) | ||
[U,S,V] = LANSVD('Afun','Atransfun',M,N,K,SIGMA,OPTIONS) | ||
|
||
where K is the number of singular values desired and | ||
SIGMA is 'L' or 'S'. | ||
|
||
The OPTIONS structure specifies certain parameters in the algorithm. | ||
Field name Parameter Default | ||
|
||
OPTIONS.tol Convergence tolerance 16*eps | ||
OPTIONS.lanmax Dimension of the Lanczos basis. | ||
OPTIONS.p0 Starting vector for the Lanczos rand(n,1)-0.5 | ||
iteration. | ||
OPTIONS.delta Level of orthogonality among the sqrt(eps/K) | ||
Lanczos vectors. | ||
OPTIONS.eta Level of orthogonality after 10*eps^(3/4) | ||
reorthogonalization. | ||
OPTIONS.cgs reorthogonalization method used 0 | ||
'0' : iterated modified Gram-Schmidt | ||
'1' : iterated classical Gram-Schmidt | ||
OPTIONS.elr If equal to 1 then extended local 1 | ||
reorthogonalization is enforced. | ||
|
||
See also LANBPRO, SVDS, SVD | ||
|
||
References: | ||
R.M. Larsen, Ph.D. Thesis, Aarhus University, 1998. | ||
|
||
B. N. Parlett, ``The Symmetric Eigenvalue Problem'', | ||
Prentice-Hall, Englewood Cliffs, NJ, 1980. | ||
|
||
H. D. Simon, ``The Lanczos algorithm with partial reorthogonalization'', | ||
Math. Comp. 42 (1984), no. 165, 115--142. | ||
|
||
Rasmus Munk Larsen, DAIMI, 1998 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.