I have a binary image that contains many lines. I want to detect any pixel that has 2 neighboring pixels and in some cases 3 or 1 neighboring pixel (considering all possible 8-connectivity directions).
In other words, go to each pixel and check how many neighbors it has by checking the 8-connectivity. If it has 2 neighbors then select this pixel and finally will have a binary image that contains these pixels.
Any idea how to do that?