【暂存】Gist特征计算(MSR-Action3D)

list=dir('MSR-Action3D\a01\*.jpg');
G=[];
n=0;
for k=1:3:length(list)
    % Load image
    img1=imread(strcat('MSR-Action3D\a01\',list(k).name));
    img2=imread(strcat('MSR-Action3D\a01\',list(k+1).name));
    img3=imread(strcat('MSR-Action3D\a01\',list(k+2).name));
    n=n+1;
    % Parameters:
    clear param
    param.imageSize = [256 256]; % it works also with non-square images
    param.orientationsPerScale = [8 8 8 8];
    param.numberBlocks = 4;
    param.fc_prefilt = 4;
    % Computing gist requires 1) prefilter image, 2) filter image and collect
    % output energies
    [gist1, param] = LMgist(img1, '', param);
    [gist2, param] = LMgist(img2, '', param);
    [gist3, param] = LMgist(img3, '', param);
    gist=[gist1 gist2 gist3];
    G(:,n)=gist';
end

----------------------------------------------------2018.4.15--------------------------------------------------------------------

Glist=[];%特征列表
Tlist=[];%标签列表
maindir ='MSR-Action3D';
subdir =  dir(maindir);   %先确定子文件夹
for i = 1:length(subdir)
    if(isequal(subdir(i).name, '.') || ...
            isequal(subdir(i).name, '..') || ...
            ~subdir(i).isdir)   % 如果不是目录跳过
        continue;
    end
    subdirpath = fullfile(maindir, subdir( i ).name, '*.jpg');
    list = dir(subdirpath);   % 在这个子文件夹下找后缀为jpg的文件
    G=[];
    T=[];
    n=0;
    for k=1:3:length(list)
        % Load image
        img1=imread(fullfile( maindir, subdir(i).name,list(k).name));
        img2=imread(fullfile( maindir, subdir(i).name,list(k+1).name));
        img3=imread(fullfile( maindir, subdir(i).name,list(k+2).name));
        n=n+1;
        % Parameters:
        clear param
        param.imageSize = [256 256]; % it works also with non-square images
        param.orientationsPerScale = [8 8 8 8];
        param.numberBlocks = 4;
        param.fc_prefilt = 4;
        % Computing gist requires 1) prefilter image, 2) filter image and collect
        % output energies
        [gist1, param] = LMgist(img1, '', param);
        [gist2, param] = LMgist(img2, '', param);
        [gist3, param] = LMgist(img3, '', param);
        gist=[gist1 gist2 gist3];
        G(n,:)=gist;
        T(n,:)=i-2;
    end
    Glist=[Glist;G];
    Tlist=[Tlist;T];
end


% load('Glist.mat');
% load('Tlist.mat');


% Sparse_Train_Features = sparse(Glist);
% Sparse_Test_Features = sparse(Test_Images_Features);
% Sparse_Train_Label = sparse(Tlist);
% Sparse_Test_Label = sparse(GT_Test_Images);
% 
% libsvmwrite('train.txt', Sparse_Train_Label, Sparse_Train_Features);
% libsvmwrite('test.txt', Sparse_Test_Label, Sparse_Test_Features);

---------------------------------------------------------2018.4.19---------------------------------------------------------------


Glist=[];%特征列表
Tlist=[];%标签列表
maindir = 'MSR-Action3D\';
% AS1=['a02', 'a03', 'a05', 'a06', 'a10', 'a13', 'a18', 'a20'];
% T1=[02,03,05,06,10,13,18,20];
% AS1=['a01', 'a04', 'a07', 'a08', 'a09', 'a11', 'a14', 'a12'];
% T1=[01,04,07,08,09,11,14,12];
AS1=[ 'a06', 'a14', 'a15', 'a16', 'a17', 'a18', 'a19', 'a20'];
T1=[06,14,15,16,17,18,19,20];
NumAct = 8;          % number of actions in each subset
for i=1:NumAct
    action=AS1((i-1)*3+1:i*3);
    subdir=strcat(maindir,action,'\');
    subdirpath = fullfile(subdir, '*.jpg');
    list = dir(subdirpath);
    G=[];
    T=[];
    n=0;
    for k=1:3:length(list)
        % Load image
        img1=imread(fullfile(subdir,list(k).name));
        img2=imread(fullfile(subdir,list(k+1).name));
        img3=imread(fullfile(subdir,list(k+2).name));
        n=n+1;
        % Parameters:
        clear param
        param.imageSize = [256 256]; % it works also with non-square images
        param.orientationsPerScale = [8 8 8 8];
        param.numberBlocks = 4;
        param.fc_prefilt = 4;
        % Computing gist requires 1) prefilter image, 2) filter image and collect
        % output energies
        [gist1, param] = LMgist(img1, '', param);
        [gist2, param] = LMgist(img2, '', param);
        [gist3, param] = LMgist(img3, '', param);
        gist=[gist1 gist2 gist3];
        G(n,:)=gist;
        T(n,:)=T1(i);
    end
      Glist=[Glist;G];
      Tlist=[Tlist;T];   
end

你可能感兴趣的:(毕业设计)