% Issac D. Gerg / Pushkar U. Durve
% CSE 485 - Digital Image Processing I 
% Project 1
% Group Number # 4
% This project considers the use of Boolean operations for manipulating and combining two gray level/binary images. 

% Number 1 -------------------------------------------------------------
% Part (a) - Compute A AND B

checker_filename = 'checker.gif';
castles_filename = 'castles.gif';

checker_image = imread(checker_filename);
castles_image = imread(castles_filename);

image_AND = (checker_image & castles_image);
imwrite(image_AND, 'image_AND.jpg', 'jpg');  

% Part (b) Compute A XOR B
image_XOR = XOR (checker_image, castles_image);
imwrite(image_XOR, 'image_XOR.jpg', 'jpg');  

% Part (c) Compute [NOT(A) XNOR NOT(B)]
image_NOT_A = ~checker_image;
image_NOT_B = ~castles_image;

image_XNOR = (image_NOT_A & image_NOT_B) | (~image_NOT_A & ~image_NOT_B);
imwrite(image_XNOR, 'image_XNOR.jpg', 'jpg');  

% Part (d) Compute E=max(C,D)
lenna_filename = 'lenna.gif';
lv40_filename = 'lv40.gif';

lenna_image = imread(lenna_filename);
lv40_image = imread(lv40_filename);

image_max = max(lenna_image, lv40_image);
imwrite(image_max, 'image_max.jpg', 'jpg'); 


% Part (e) Use imsubtract and imabsdiff functions
seq1_filename = 'seq1_frame_0001.gif';
seq2_filename = 'seq1_frame_0002.gif';

seq1_image = imread(seq1_filename);
seq2_image = imread(seq2_filename);

imsubtract_image = imsubtract(seq1_image,seq2_image);
imwrite(imsubtract_image, 'imsubtract_image.jpg', 'jpg'); 

imabsdiff_image = imabsdiff(seq1_image,seq2_image);
imwrite(imabsdiff_image, 'imabsdiff_image.jpg', 'jpg'); 


