% Daniel Edens Fall 2017

imdata = imread('MITRE.png');

MITRE_Image = zeros(132,50);
k = 1;
white = 0;
curr = 0;
prev = 0;

for i=1:132
    for j=1:320
        curr = imdata(i,j,3);
        if curr==0
            MITRE_Image(i,k) = MITRE_Image(i,k) + 1;
            
        end
        if curr~=0
            MITRE_Image(i,k) = MITRE_Image(i,k) + 1;
            
        end
        if prev==0 && curr~=0 || prev~=0 && curr==0
            k = k+1;
        end
        prev = curr;
    end
    
    k=1;
    
end


%make a textfile with PIC XC32 source code in it.
fname='MITRE.h';
fid = fopen(fname,'w');
%static constant means to store it in flash
fprintf(fid,'static const unsigned char MITRE[]={\r');
for i=1:132
    for j=1:50
    fprintf(fid,' %5d,\r',MITRE_Image(i,j));
    end
end
fprintf(fid,' %5d};\r',109);
fclose(fid);
