function [ rangescale ] = rangescale( img )
%range-scales img pixels between zero and unity.
%Use a single monochrome image 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.
%
%OUTPUTS: range scaled image
global rangescale;
a=img;
nrows=size(a,1);
a=reshape(a,[],1);
a=im2single(a);
a=a-min(a);
a=a./max(a);
a=reshape(a,nrows,[]);
rangescale=a;
end

