% Morphology
a = [1 1 1 0 0 0 1 1 1 0 0;
     1 1 1 1 1 1 1 1 1 0 0;
     1 1 1 1 1 1 0 1 1 0 0;
     0 1 1 1 1 1 1 1 1 0 1;
     0 0 0 0 1 1 1 1 0 0 1;
     0 0 0 0 1 1 1 1 0 0 0;
     0 0 0 0 0 1 1 1 0 0 1];

se = strel('square',5);
erodedImg = imerode(a,se);
imtool(a);
imtool(erodedImg);

dilatedImg = imdilate(a,se);
imtool(dilatedImg);



img = imread('../../Images/Matt.jpg');
img = rgb2gray(img);
img(find(img<140)) = 0;
img(find(img>=140)) = 255;
imtool(img);

se = strel('square',3);
erodedImg = imerode(img,se);
figure; imshow(erodedImg);
 
se = strel('square',5);
erodedImg = imerode(img,se);
figure; imshow(erodedImg);

dilatedImg = imdilate(img,se);
figure; imshow(dilatedImg);

closedImg = imclose(img, strel('square', 11));
figure; imshow(closedImg);

openedImg = imopen(img, strel('square', 11));
figure; imshow(openedImg);

