% addLocationbar - add a location bar at the bottom of an image % % Usage: locationbar=addLocationbar(im,current,range,barH,posW,bgColor,fgColor) % % Arguments: im - the image that location bar is to be added on % current - current position or index % range - the range, or max value if start with 1 % (Optional) % barH - height of the bar % posW - width of the current position pointer % bgColor - background color, 0-255 % fgColor - foreground color, 0-255 % % Return: imWithBar - the image with location bar % % Author: % Tzu Yen Wong % wongt AT csse DOT uwa DOT edu DOT au % Department of Computer Science & Software Engineering % The University of Western Australia % % Dec 2003 % June 2004 change email address to fight SPAM!!! function imWithBar=addLocationbar(im,current,range,barH,posW,bgColor,fgColor) if nargin<3, error('need at least 3 inputs'); end if size(range(:))==1, range(2)=1; end limitUp = max(range); limitDn = min(range); [imH,imW,numColor] = size(im); eval('barH;','barH=5;'); eval('posW;','posW=4;'); eval('bgColor;',... 'if numColor==3, bgColor=[0 0 255]; else, bgColor=190; end'); eval('fgColor;',... 'if numColor==3, fgColor=[255 0 0]; else, fgColor=255; end'); if currentlimitUp, warning(sprintf('current point "%d" is out of range [%d,%d]',... current,limitDn,limitUp)); imWithBar = im; if ndims(im)==2, % image is grayscale imWithBar((imH+1):(imH+barH)) = bgColor; elseif ndims(im)==3, % image is color for ii=3:-1:1, imWithBar((imH+1):(imH+barH),:,ii) = bgColor(ii); end end return end b = ceil(((current-(limitDn-1))/(limitUp-(limitDn-1)))*(imW-posW)); if ndims(im)==2, % image is grayscale locationbar(:,:) = uint8(ones(barH,imW)*255); locationbar(:,:) = bgColor; locationbar(:,b:b+posW-1) = fgColor; im((imH+1):(imH+barH),:) = locationbar; elseif ndims(im)==3, % image is color locationbar(:,:,3) = uint8(ones(barH,imW)*255); for ii=3:-1:1, locationbar(:,:,ii) = bgColor(ii); locationbar(:,b:b+posW-1,ii) = fgColor(ii); end im((imH+1):(imH+barH),:,:) = locationbar; end imWithBar = im;