function lm = localmax_logical(mat,n)

diffmat = [mat(1,:)*0; sign(diff(mat))]; % !!!! attention rethink the 0!!!!!
convolver = -[ones(n,1);-ones(n,1)];
lm = conv2(diffmat,convolver,'same') == 2 * n;