function varargout = inrange(pix1, pix2, lower, upper);
% [good, toolow] = inrange(pix1, pix2, lower, upper);
% Takes one component of the pix location (x or y) provided by edge
% detection and determines whether it is within the range for the object
% we're looking for.

diff=abs(pix1-pix2);

if (diff<=upper) & (diff>=lower)
   good=1;
else
   good=0;
end

if diff<lower
   toolow=1;
else
   toolow=0;
end

switch nargout
case 0
    % inrange(...)

    varargout{1} = good;
 
case 1
    % good = inrange(...)
    
    varargout{1} = good;
    
case 2
    % [good, toolow] = inrange(...)
    
    varargout{1} = good;
    varargout{2} = toolow;

end
