How do I implement a binary morphological image operation that counts for each pixel the number of non-zero 4-neighbors

50 Views Asked by At

I have a binary image in the form of a Numpy 2D integer array. I want to create another image with values 0-4 denoting how many of each pixel's 4-neighbors are 1-valued. I was hoping for something in Numpy or SciPy, but anything in Python will be welcomed.

0

There are 0 best solutions below