function im=histnorm(im,bb,bbm)
% Normalize histogram so that peak above bbm is 1 and peak below bbm is 0
% Usage: histeq(img,bb,bbm);
% bb is the bin list and bbm is the separation point

% revision history:
% 06/07/10 Mark D. Shattuck <mds> histnorm.m  

[nn bb]=hist(im(:),bb);
[junk2 p1]=max(nn(1:bbm)); %#ok<*ASGLU>
[junk1 p2]=max(nn(bbm+1:end));
p2=p2+bbm;
im=(bb(p2)-im)/(bb(p2)-bb(p1));
end
	