www.pudn.com > snippets(1).rar > learn_pca_representation.m, change:2009-10-12,size:1064b


function [M_trafo, pca, sframes] = learn_pca_representation(filelist, Globals, ftype)
%
% learn a representation of the optic flow field from training sequences

  flow_flag = strcmp(ftype,'flow');

  % prepare data structure
  num = length(filelist);
  train_data = cell(num,1);

  % read from file, Gabor responses have been precomputed...
  for u = 1:num

    % read already pooled data from files
    name = filelist{u};
    if flow_flag
      load(name,'flow');
    else
      load(name,'form');
      flow = form;
      clear form;
    end

    train_data{u} = flow;
  
  end

  % learn and apply PCA
  [ndir,nvel,nscale] = size(train_data{1});
  [sx,sy,sframes] = size(train_data{1}{1,1,1});

  ht = nscale*ndir*nvel*sx*sy*Globals.concat_frames;
  step = sframes-Globals.concat_frames+1;
  wt = num*step;
  fprintf('PCA (%dx%d)..',ht,wt);
  M = zeros(ht,wt,'single');

  for u = 1:num
    ed = step*u;
    st = ed-step+1;
    M(:,st:ed) = frame2vec(train_data{u},Globals.concat_frames,'single');
  end

  [M_trafo, pca] = learn_pca(M, Globals, flow_flag);