In this example, we will try to delineate the contours of the coins using edge-based segmentation. To do this, the first step is to get the edges of features using the Canny edge detector, demonstrated by the following code block:
edges = canny(coins, sigma=2)fig, axes = pylab.subplots(figsize=(10, 6))axes.imshow(edges, cmap=pylab.cm.gray, interpolation='nearest')axes.set_title('Canny detector'), axes.axis('off'), pylab.show()
The next screenshot shows the output of the earlier code, the contours of the coins obtained using the Canny edge detector:
The next step is to fill these contours using the morphological function ...