I have a binary image [0,1]. I want to use Python to find the edge of the image. I have tried sobel method on the binary but it provides a bad result. I expect the output like the image
The best way is to apply a 1-pixel morphological erosion, then take the difference between the input image and the result. In pseudo-code:
edges = image - erosion(image)