% ==================================================================================================
% Module:   setdifference.m
%
% Usage:    Compute set difference of 2 binary images.
%
% Purpose: 
%     Performs the set difference of 2 binary images.
%
%     
% Input Variables:
%     A      input image (binary data)
%     B      input image (binary data)
%     
% Returned Results:
%     The (set of A) - (the set of B)
%
% Restrictions/Notes:
%     This function is geared for binary images. Input images must be of
%     the same dimensions.
%
% See Also:
% 
% References:
% 
% Author:       Isaac Gerg
% Date:         2/1/04
% Revisions:    none
% ==================================================================================================

function O = setdifference(A,B);

% x and y are switched in MATLAB and so are width and height.
awidth = size(A,1);
aheight = size(A,2); 
bwidth = size(B,1);
bheight = size(B,2); 

if awidth~=bwidth & aheight~=bheight
    disp('Image diminstions not equal!');
    return;
end

O = zeros(awidth, aheight);

for x = 1:awidth,
    for y = 1:aheight,
        O(x,y) = xor(A(x,y), B(x,y));
    end
end