function [mask, a] = howTo()

%HowTo Demo for FruitFinder

img = imread('../../Images/Matt.jpg');

% zeros(d1, d2, d3, ..., dn) creates an n-dimensional matrix, 
% with dimensions d1, d2, ...
a = zeros(3, 4);

% size(matrix) returns the size of matrix
% size(matrix, d) returns the size of the dth dimension of the matrix
size(a);

% Finding pixels in a certain range in an image
% find returns the pixels in column order form.
a(1, 1) = 4;
a(2, 1) = 4;
a(3, 1) = 4;
% or a(1:3) = 1;
a

find(a == 1);

% Find pixels with high blue value in Matt image.
find(img(:,:,3) > 100);

mask = zeros(size(img, 1), size(img, 2));
mask(  find(img(:,:,3) > 200 ... 
& img(:,:,1) < 110 ...
& img(:,:,2) < 150 )) =1;

% Note the use of logical operators.
% & (and), | (or), ~ (not)

mask = zeros(size(img, 1), size(img, 2), 1);
mask(find(img(:,:,2) > 100 & img(:,:,1) < 100)) = 1;

% To put a long line of code on multiple lines, use ... for continuation
mask = zeros(size(img, 1), size(img, 2), 1);
mask(find(img(:,:,2) > 100 ... % note the ...
    & img(:,:,1) < 100 ...
    & img(:,:,3) < 100)) = 1;

% Other notes:
% if you are having a tough time diplaying images with values in 0-255, 
% make sure you use imshow(uint8(img))



%Decisions:
if (max(max(mask)) > 10) 
    fprintf('Max value of mask greater than 10');
elseif (max(max(mask)) > 5)
    fprintf('Max value of mask greater than 5');
else
    fprintf('Max value of mask less than 5');
end

% Loop from 1 to 10
for i  = 1:10
    fprintf('%d\n', i);
end

% count by 5s and summing
sum = 0;
for i  = 0:5:100
    sum = sum + i; % Note Matlab doesn't have += or ++ abbreviations
    fprintf('%d\n', i);
end

% Operating on a whole image at a time is ALWAYS faster than looping

% connected components in another script

