function SENS(intensity,delta)
% SENS Sensitivity experiment
%   SENS(I,D) displays a background image of uniform intensity with a
%   small foreground object of another intensity. The background intensity
%   I should be a value between 0 and 100 (0 is pure black, 100 is pure
%   white). The foreground intensity is specified as a percentage delta D
%   from the background intensity. D should also be between 0 and 100.
%
%   The actual foreground and background graylevels are displayed as 'fg'
%   and 'bg', respectively.
%
% Examples:
%
%   Background at 25% of full intensity, foreground is same as background
%   SENS(25,0)
%
%   Background at 75% of full intensity, foreground 14% higher than background
%   SENS(75,14)
%
%   Background at 50% of full intensity, foreground 5% lower than background
%   SENS(50,-5)
%
%
% ECE480/PH437: Introduction to Image Processing

% Calculate the background and foreground intensities when scaled to the
% range 0 to 255
bg = 255 * (intensity/100)
fg = 255 * ( (intensity/100) * (1 + delta/100) )

% Check results to make sure they are not out of range
if (bg < 0 | bg > 255)
    disp('Warning: Background value is out of range');
end

if (fg < 0 | fg > 255)
    disp('Warning: Foreground value is out of range');
end


% Define the size of the background image and the foreground region
n = 512;
f = 30;

% Create the background image
x = bg * ones(n);

% Create the foreground region in the center of the background
x( (n/2)-(f/2) : (n/2)+(f/2), (n/2)-(f/2) : (n/2)+(f/2) ) = fg;

% Display the image
imshow(uint8(x));