function   nim=scaleIm(im,lval,hval)

im=double(im);

lval1=min(im(:));
hval1=max(im(:));
delta1=hval1-lval1;
delta2=hval-lval;

nim=delta2.*(im-lval1)./delta1+lval;