% This DOES contain errors
I = imread('DesertSmall.jpg');
red = I(:,:,1);
red = red(:);
green = I(:,:,2);
green = green(:);
blue = I(:,:,3);
blue = blue(:);
plot3(red,green,blue,'.');
xlabel('red');
ylabel('green');
zlabel('blue')
shg
I = imread('ExamKey.jpg');
red = I(:,:,1);
red = red(:);
green = I(:,:,2);
green = green(:);
blue = I(:,:,3);
blue = blue(:);
plot3(red,green,blue,'.');
xlabel('red');
ylabel('green');
zlabel('blue')
shg
flattened = [red, green, blue];
sky = flattened(flattened(red > 125),:);
plot3(sky(:,1),sky(:,2),sky(:,3),'r.');
shg
hold on
hold off
plot3(red,green,blue,'.');
hold on
plot3(sky(:,1),sky(:,2),sky(:,3),'r.');
shg
I = imread('DesertSmall.jpg');
red = I(:,:,1);
red = red(:);
green = I(:,:,2);
green = green(:);
blue = I(:,:,3);
blue = blue(:);
plot3(red,green,blue,'.');
xlabel('red');
ylabel('green');
zlabel('blue')
shg
figure(2)
flattened = [red, green, blue];
sky = flattened(flattened(red > 125),:);
plot3(sky(:,1),sky(:,2),sky(:,3),'r.');
shg
sky = flattened(red > 125,:);
plot3(sky(:,1),sky(:,2),sky(:,3),'r.');
shg
flattened = [1 5;
2 4;
3 5;
1 7];
flattened
flattened(:,1)>1
flattened(flattened(:,1)>1,:)
flattened = [red, green, blue];
plot3(flattened(:,1),flattened(:,2),flattened(:,3),'r.');
shg
black = zeros(size(I,1),size(I,2),1);
black(I(:,:,1)>128) = 1;
imshow(black)
shg
black(I(:,:,2)>128) = 1;
shg
black(I(:,:,3)>128) = 1;
shg
clear
% start here
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
[i,j] = ans
p = ans
p = round(p)
jrange = p(1)-10:p(1)+10
irange = p(2)-10:p(2)+10
imshow(irange,jrange)
imshow(I(irange,jrange))
shg
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,:) = 0;
imshow(masked)
masked([~mask ~mask ~mask]) = 0;
shg
imshow(masked)
masked = I;
masked([~mask ~mask ~mask]) = 0;
imshow(I)
imshow(masked)