| Description of sl2dpca_apply |
sl2dpca_apply
PURPOSE 
SL2DPCA_APPLY Applies 2D PCA onto a set of matrices to extract features
SYNOPSIS 
function Y = sl2dpca_apply(Mm, PL, PR, data, matsiz, n)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- slreadarray SLREADARRAY Reads an array from an array file
- raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:
SUBFUNCTIONS 
SOURCE CODE 
0001 function Y = sl2dpca_apply(Mm, PL, PR, data, matsiz, n)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 if nargin < 6
0030 raise_lackinput('sl2dpca_apply', 6);
0031 end
0032
0033 matsiz = matsiz(:)';
0034 if length(matsiz) ~= 2
0035 error('sltoolbox:invalidarg', ...
0036 'matsiz should be a 2-elem vector');
0037 end
0038
0039 if ~isequal(size(Mm), matsiz)
0040 error('sltoolbox:sizmismatch', ...
0041 'the sample size does not match the model');
0042 end
0043 d1 = matsiz(1);
0044 d2 = matsiz(2);
0045
0046 if size(PL, 1) ~= d1 || size(PR, 1) ~= d2
0047 error('sltoolbox:sizmismatch', ...
0048 'the size of projection matrices are illegal');
0049 end
0050
0051
0052
0053 if isnumeric(data)
0054
0055 if size(data, 3) ~= n
0056 error('sltoolbox:sizmismatch', ...
0057 'The number of samples is not as specified');
0058 end
0059
0060 Y = computeY(data, Mm, PL, PR);
0061
0062 elseif iscell(data)
0063
0064 Y = zeros(size(PL, 2), size(PR, 2), n);
0065
0066 nfiles = length(data);
0067 cf = 0;
0068 for i = 1 : nfiles
0069 curdata = slreadarray(data{i});
0070 curn = size(curdata, 3);
0071 Y(:,:,cf+1:cf+curn) = computeY(curdata, Mm, PL, PR);
0072 cf = cf + curn;
0073 end
0074
0075 else
0076 error('sltoolbox:invalidarg', ...
0077 'data should be a numeric array or a cell array of filenames');
0078
0079 end
0080
0081
0082
0083
0084 function Y = computeY(X, Mm, PL, PR)
0085
0086 n = size(X, 3);
0087 Y = zeros(size(PL, 2), size(PR, 2), n);
0088 PLT = PL';
0089
0090 for i = 1 : n
0091 Y(:,:,i) = PLT * (X(:,:,i) - Mm) * PR;
0092 end
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003
|
|