R, 117 63 59 bytes
function(m)sum(colSums(as.matrix(dist(which(m==8,T)))<2)<2)
dist
computes distances (default is Euclidean) among rows of a matrix. which
with second argument TRUE
returns the coordinates where the predicate is true.
Coordinates are neighbours if the distance between them is not more than the square root of 2, but the inner <2
is good enough because the possible distance jumps from sqrt(2)
ro 2
.