powered by
This function counts the number of neighboring/touching pixels in a 2D binary image
A matrix of the same size as im containing the number of neighboring pixels
im
A boolean matrix representing a binary image
Whether to count diagonal elements as valid neighbors
Michael Hallquist
This is an internal function used by geom_outline to clean up outlines