clear;  %clear variables in the workspace
clc;   %clear the plotting window

tum(10,10)=0;  %initiate the tumor variable
tum(1,5)=1;    %define a noise feature 
tum(8,5)=1;    %define another noise featuer
tum(3,3)=1;    %define a benign tumor (two-in-row))
tum(3,4)=1;    
tum(7,9)=1;    %define a begin tumor (two-in-column)
tum(8,9)=1;
tum(6,2)=1;   %define a malignant tumor (left bend)
tum(6,3)=1;   
tum(7,2)=1;
tum(4,7)=1;   %define another malignant tumor (right bend)
tum(4,8)=1;   
tum(5,8)=1;


mycolormap=[1,1,1;0,0,0]   %define a color map
colormap(mycolormap)       %call my color map
imagesc(tum)               %show the image of the 2-D data
axis square                %square axis
grid on                    %show data grid

%count how many positive pixels in the image (2-D array)
count_pos=0;
for i=[1:10]
    for j=[1:10]
       if (tum(i,j) == 1) 
           count_pos=count_pos+1;
       end
    end
end

disp('Number of Positive Pixels=')
count_pos

%count how many two-in-row
count_two_row=0;
for i=[1:10]
    for j=[1:9]
       if (tum(i,j) == 1 && tum(i+1,j)==1) 
           count_two_row=count_two_row+1;
       end
    end
end

disp('Number of two-in-row=')
count_two_row


%count how many two-in-column
count_two_col=0;
for i=[1:9]
    for j=[1:10]
       if (tum(i,j) == 1 && tum(i,j+1)==1) 
           count_two_col=count_two_col+1;
       end
    end
end

disp('Number of two-in-col=')
count_two_col


%count how many left bend
count_left_bend=0;
for i=[1:9]
    for j=[1:9]
       if (tum(i,j) == 1 && tum(i,j+1)==1 && tum(i+1,j)==1) 
           count_left_bend=count_left_bend+1;
       end
    end
end

disp('Number of left_bend=')
count_left_bend


%count how many right bend
count_right_bend=0;
for i=[1:9]
    for j=[1:9]
       if (tum(i,j) == 1 && tum(i,j+1)==1 && tum(i+1,j+1)==1) 
           count_right_bend=count_right_bend+1;
       end
    end
end

disp('Number of right_bend=')
count_right_bend

%find the number of malignant tumors
count_malig=count_left_bend + count_right_bend;
disp('Number of malignant tumors=')
count_malig

%find the number of benign tumors
count_benign=count_two_row + count_two_col - count_malig*2;
disp('Number of benign tumors=')
count_benign









