function [ out ] = imloc( b,k,t )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here

[m,n]=size(b);
b=double(b);
out=zeros(m,n);
for mm=2:m-1
    for nn=2:n-1
        s=0;
        for i=1:3
            for j=1:3
                if (i~=2 || j~=2)
                    u=(b(mm,nn)-b(mm+(i-2),nn+(j-2))-t(i,j))>=0;

                    s=s+(k(i,j)*u);
                end
            end
        end
        out(mm,nn)=s;
    end
end
        

out=uint8(out);



end

