Image Segmentation
Image segmentation is the task of labeling the pixels of objects of interest in an image.
In this tutorial, we will see how to segment objects from a background. We use the coins
image from skimage.data
. This image shows several coins outlined against a darker background. The segmentation of the coins cannot be done directly from the histogram of grey values, because the background shares enough grey levels with the coins that a thresholding segmentation is not sufficient.
>>> import numpy as np >>> from skimage import data >>> coins = data.coins() >>> histo = np.histogram(coins, bins=np.arange(0, 256))
Simply thresholding the image leads either to missing significant parts of the coins, or to merging parts of the background with the coins. This is due to the inhomogeneous lighting of the image.
A first idea is to take advantage of the local contrast, that is, to use the gradients rather than the grey values.
Please login to continue.