function g = erode(input, filter)

[x1, y1] = size(input);
[x2, y2] = size(filter);

temp = sum(sum(filter>0));

input2=ones(x1+x2-1, y1+y2-1)*255;
input2((x2+1)/2:end-(x2-1)/2, (y2+1)/2:end-(y2-1)/2)=input;


% temp=3;

for x=1:(x1)
    for y=1:(y1)

        temp2=sum(sum(filter.*input2(x:(x+x2-1), y:(y+y2-1))));

        
        if temp2==temp.*255
            g(x, y)=255;
        else
            g(x,y)=0;
        end
    end
end



    
