function [train_list, test_list] = train_test_split(database, numTrains)
% split training and test images for Graz-02 dataset

train_list = cell(database.nclass,1);
test_list = cell(database.nclass,1);

for ii = 1 : database.imnum
    
    ipath = database.imgpath{ii};
    seps = strfind(ipath, '_');
    num = str2double(ipath(seps(end)+1:seps(end)+3));
    label = database.label(ii);
    if label~=0
        if mod(num,2)==1
            train_list{label} = [train_list{label}; ii];
        else
            test_list{label} = [test_list{label}; ii];
        end
    elseif num<=2*numTrains
        if mod(num,2)==1
            for cc = 1:database.nclass
                train_list{cc} = [train_list{cc}; ii];
            end
        else
            for cc = 1:database.nclass
                test_list{cc} = [test_list{cc}; ii];
            end
        end
    end
end
