function [T1,N] = CA_A5(T1,white, black) 
%CA_A5 colors remaining tagged articulation cells, which are part of backbone with backbone color

N=0;
global cmap;
green = length(cmap);


for lines=2:size(T1,1)-1
    for columns=2:size(T1,2)-1
        if (T1(lines, columns) == white) % if white
            if (lines ~= 1 && lines ~=size(T1,1)-1  && columns ~= 1 && columns ~= size(T1,2)-1 ) %not on boundaries
                %ako bijela celija ima dva green susjeda mjenja stanje u green  
                if((T1(lines,columns+1) == green && T1(lines,columns-1) == green) || (T1(lines,columns+1) == green && T1(lines-1,columns) == green) || ...
                    (T1(lines,columns+1) == green && T1(lines+1,columns) == green) || (T1(lines,columns-1) == green && T1(lines-1,columns) == green) || ...
                    (T1(lines,columns-1) == green && T1(lines+1,columns) == green) || (T1(lines-1,columns) == green && T1(lines+1,columns) == green)) 
                    T1(lines, columns)= green;  
                %ako bijela celija ima jednog green susjeda i jednog bijelog susjeda koji ima green susjeda mjenja stanje u green   
                elseif ((T1(lines,columns+1) == green && ((T1(lines,columns-1) == white && T1(lines,columns-2) == green) || ...
                    (T1(lines-1,columns) == white && T1(lines-2,columns) == green) || (T1(lines+1,columns) == white && T1(lines+2,columns) == green))) || ... 
                    (T1(lines,columns-1) == green && ((T1(lines,columns+1) == white && T1(lines,columns+2) == green) || ...
                    (T1(lines-1,columns) == white && T1(lines-2,columns) == green) || (T1(lines+1,columns) == white || T1(lines+2,columns) == green))) || ...
                    (T1(lines+1,columns) == green && ((T1(lines,columns+1) == white && T1(lines,columns+2) == green) || ...
                    (T1(lines-1,columns) == white && T1(lines-2,columns) == green) || (T1(lines,columns-1) == white || T1(lines,columns-2) == green))) || ...
                    (T1(lines-1,columns) == green && ((T1(lines,columns+1) == white && T1(lines,columns+2) == green) || ...
                    (T1(lines+1,columns) == white && T1(lines+2,columns) == green) || (T1(lines+1,columns) == white || T1(lines+2,columns) == green))))
                    T1(lines, columns)= green; 
                end
            end
        end
        N=N+1;
    end
end
