function out = umple(copy, mask1);
% clear all
% clc
% se=strel('disk',2);
% 
 inversa=abs(1-mask1);
 inversa=1-inversa;
% 
% rez = imdilate(~inversa, se);
% 
% inversa = ~rez;
% 
%  out = inversa;
% 
% figure,imagesc(out),colormap(gray(256)),axis image, pixval;
% 
% oo = out.*copy;
% 
% aux = oo;

[m,n] = size(copy);

for i=2:m-2
    
    linie = copy(i,:);
    
    mm=1/3*ones(1,3);
    linie=conv(linie,mm);
    
    if linie ==0
        break
    end
    
    [maxtab,mintab]=peakdet1(linie,10);
    
    j=6:n-6;
    
    poz1=find(abs(copy(i,j)-copy(i,j-5))>50);
    
    linie1= inversa(i,:);
    if length(linie1) == 0
        continue
    end
    
    l = find(linie1 == 0);
    
%     poz1 = min(poz1);
    poz1 = min(l);
    poz2 = max(l);
    
%     if length(poz2) == 0
%         continue
%     end
    
    for k=poz1:poz2
        v = copy(i,k-6:k-1);
        copy(i,k) =round( mean(v));
    end
    
end
    
out=copy;
    
    
    
%     for j=poz:(poz+length(l))
%         i
%         j
%         
%         p=100; r=110;
%         v = oo(i,j-p:-1:j-r);
%         if prod(v)==0
%             aux(i,j)=mean(v(v>0));
%         else
%             aux(i,j)=mean(v);  
%         end
%         
%     end
%         
% end
% 
% out=aux;
% figure,imagesc(aux),colormap(gray(256)),axis image, pixval;