enviLoadRaw.m 775 Bytes
%loads an ENVI file without any manipulation (changing orientation)
% enviLoadRaw(filename, headername)
function M = enviLoadRaw(filename, headername)

    %if a header isn't provided, assume it's just the filename
        % with '.hdr' added to the end
    if nargin == 1
        headername = [filename '.hdr'];
    end

    h = enviLoadHeader(headername);
    
    if strcmp(h.interleave, 'bsq')
        X = h.samples;
        Y = h.lines;
        Z = h.bands;
    elseif strcmp(h.interleave, 'bil')
        X = h.samples;
        Y = h.bands;
        Z = h.lines;
    else
        X = h.bands;
        Y = h.samples;
        Z = h.lines;
    end
    
    fid = fopen(filename);
    M = fread(fid, [X, Y*Z], '*float32');
    M = reshape(M, [X, Y, Z]);
    
    fclose(fid);