function [ bil ] = rangescalebil( bil )
%range-scales img pixels between zero and unity.
%Use a matrix of monochrome images as an input. The function reads the image
%matrix, subtracts the minimum value from all values, and divides all
%values by the new maximum value. The output is a matrix of single
%precision digits between zero and unity. This transformation is somewhat
%similar in output to a contrast stretch, but unidimensional in nature.
%
%NB the images are individually internally scaled rather than grossly scaled as a
%dataset.
%
%OUTPUTS: bil file with all images individually range scaled
global bil;
images=size(bil(:,:,3));
for n=1:images
a=bil(:,:,n);
nrows=size(a,1);
a=reshape(a,[],1);
a=im2single(a);
a=a-min(a);
a=a./max(a);
a=reshape(a,nrows,[]);
bil(:,:,n)=a;
end
end

