% cleans the edges of the model image after it has been rotated.
function model = clean_model(model)

[m n] = size(model);

% cleans from left to right
 for i=1:m,
    nfound = 0;
    for j=1:n,
      if (model(i,j) < 95 & nfound == 0) model(i,j) = 0; end;
      if (model(i,j) >=95 & nfound == 0) nfound=1; end;
    end;
 end;
  % cleans from right to left
 for i=1:m,
   nfound = 0;
   for j=n:-1:1,
      if (model(i,j) < 80 & nfound == 0) model(i,j) = 0; end;
      if (model(i,j) >=80 & nfound == 0) nfound=1; end;
   end;
 end;