function new_CI = L_classifier(m, L, inputCI, image, blocksize)
CI = inputCI;

update = 0;

% Goes through the L-list created and see whether adjacent blocks of unclassified blocks have been updated
% L stores information about the adjacent blocks of unclassified blocks in columns 3, 4, 5 and 6.

while (size(L,1) ~= 0 & m > 0)
   
   % Run through all the elements in L-list
   for g = 1:size(L,1)
  
   m = 0;

   current_row  = L(g, 1); 
   current_col  = L(g, 2);
   
   top = L(g,3);
   bottom = L(g,4);
   left = L(g,5);
   right = L(g,6);
   
   % If updated, set the updated status in the L-list and set update = 1
   
   if (top ~= -1)
   if (CI(current_row-1, current_col,2) ~= top)
      L(g,3) = CI(current_row-1, current_col,2);
   	update = 1;   
   end
	end

   if (bottom ~= -1)
   if (CI(current_row+1, current_col,2) ~= bottom)
      L(g,4) = CI(current_row+1, current_col,2);
   	update = 1;   
   end
	end

   if (left ~= -1)
   if (CI(current_row, current_col-1,2) ~= left)
      L(g,5) = CI(current_row, current_col-1,2);
   	update = 1;   
   end
	end

   if (right ~= -1)
   if (CI(current_row, current_col+1,2) ~= right)
      L(g,6) = CI(current_row, current_col+1,2);
   	update = 1;   
   end
   end
end

h = 1;

% See if any blocks updated

 while (h <= size(L,1) & update == 1)
   current_row  = L(h, 1);
   current_col  = L(h, 2);
   
   % try to classify this block again
   classify_result = microclassifier(CI, current_row, current_col,image, blocksize);
   
   if (classify_result ~= 4)
      
      % Set the CI values for classified block
      
      [mn, std_dev] = meanSD(current_row, current_col, blocksize, image);
      [b1, b2] = bivalue2(image(current_row:current_row+blocksize-1, current_col:current_col+blocksize-1));
      CI(current_row, current_col,2) = classify_result;
      CI(current_row, current_col, 3) = mn;
      CI(current_row, current_col, 4) = std_dev;
      CI(current_row, current_col, 5) = b1;
      CI(current_row, current_col, 6) = b2;

      
		% If classified, remove from L-list

      if (h ~= length(L))
         L = [L(1:h-1,:); L(h+1:size(L,1),:)];
      else
         L = L(1:(size(L,1)-1),:);
      end
      
      m = m + 1;
   
   end
   h = h + 1;
end

end

new_CI = CI;			      