% This MAY contain errors
% some edits have been made after class
I = imread('DesertSmall.jpg');
imshow(I)
shg
masked = I;
mask = I(:,:,3) > I(:,:,1)+I(:,:,2);
imshow(mask)
shg
mask = I(:,:,3) > (I(:,:,1)+I(:,:,2))/2;
imshow(mask)
shg
I = imread('ExamKey.jpg');
imshow(I)
shg
% ginput
% p = ans
% p = round(p)
p = [615        1085]
jrange = p(1)-10:p(1)+10
irange = p(2)-10:p(2)+10
imshow(I(irange,jrange,:))
shg
mask = I(:,:,2) > (I(:,:,1)+I(:,:,3))/2;
imshow(mask)
shg
% after class: use mask
I = imread('DesertSmall.jpg');
mask = I(:,:,3) > (I(:,:,1)+I(:,:,2))/2;
masked = I;
masked([~mask ~mask ~mask]) = 0; % repeat mask for red, green, and blue channels
imshow(masked)