spe2envicamille.m 878 Bytes
function spe2envicamille(filemask, outfile,wavenumberfilename)

    filelist = dir(filemask);

    %get a list of date numbers
    datenums = cell2mat({filelist.datenum});

    %sort the file order based on acquisition time
    [~, id] = sort(datenums);

    %get the number of files
    Y = length(id);                 %size of the image along Y

    %load the first file to determine the spectral and X-axis size
    temp = readspe(filelist(1).name);
    X = size(temp, 1);              %size of the image along X
    B = size(temp, 2);              %number of bands in the image

    %create the cube
    I = zeros(X, Y, B);

    %for each line
    for y = 1:Y

        %read a SPE file
        img = readspe(filelist(id(y)).name);

        I(:, y, :) = permute(img, [1 3 2]);
    end
 
    enviSaveRawcamille(single(I), outfile, [outfile '.hdr'],wavenumberfilename);