mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-12 13:43:46 +08:00
Minor changes in wording.
This commit is contained in:
@@ -9,8 +9,8 @@ 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. Simply thresholding the image
|
||||
leads either to missing significant parts of the coins, or to getting parts
|
||||
of the background together with the coins.
|
||||
leads either to missing significant parts of the coins, or to merging parts
|
||||
of the background with the coins.
|
||||
|
||||
We first try an edge-based segmentation. We use the Canny detector to
|
||||
delineate the contours of the coins. These contours are filled using
|
||||
|
||||
@@ -23,7 +23,7 @@ thresholding segmentation is not sufficient.
|
||||
>>> histo = np.histogram(coins, bins=np.arange(0, 256))
|
||||
|
||||
Simply thresholding the image leads either to missing significant parts
|
||||
of the coins, or to getting parts of the background together with the
|
||||
of the coins, or to merging parts of the background with the
|
||||
coins. This is due to the inhomogeneous lighting of the image.
|
||||
|
||||
.. image:: ../../_images/plot_coins_segmentation_2.png
|
||||
@@ -36,7 +36,7 @@ use the gradients rather than the grey values.
|
||||
Edge-based segmentation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Let us first try to detect edges than enclose the coins. For edge
|
||||
Let us first try to detect edges that enclose the coins. For edge
|
||||
detection, we use the `Canny detector
|
||||
<http://en.wikipedia.org/wiki/Canny_edge_detector>`_ of ``skimage.filter.canny``
|
||||
|
||||
@@ -49,7 +49,7 @@ As the background is very smooth, almost all edges are found at the
|
||||
boundary of the coins, or inside the coins.
|
||||
Now that we have contours that delineate the outer boundary of the coins,
|
||||
we fill the inner part of the coins using the
|
||||
``ndimage.binary_fill_holes`` function, that uses mathematical morphology
|
||||
``ndimage.binary_fill_holes`` function, which uses mathematical morphology
|
||||
to fill the holes.
|
||||
|
||||
::
|
||||
@@ -63,7 +63,7 @@ to fill the holes.
|
||||
|
||||
Most coins are well segmented out of the background. Small objects from
|
||||
the background can be easily removed using the ``ndimage.label``
|
||||
function, and removing objects smaller than a small threshold.
|
||||
function to remove objects smaller than a small threshold.
|
||||
|
||||
::
|
||||
|
||||
@@ -80,15 +80,15 @@ the filling function did not fill the inner part of the coin.
|
||||
|
||||
Therefore, this segmentation method is not very robust: if we miss a
|
||||
single pixel of the contour of the object, we will not be able to fill
|
||||
it. Of course, we could try first to dilate the contours in order to
|
||||
it. Of course, we could try to dilate the contours in order to
|
||||
close them. However, it is preferable to try a more robust method.
|
||||
|
||||
Region-based segmentation
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Let us first determine markers of the coins and the background. These
|
||||
markers are pixels that we can label unambiguously with one of the
|
||||
phases. Here, the markers are found at the two extreme parts of the
|
||||
markers are pixels that we can label unambiguously as either object or
|
||||
background. Here, the markers are found at the two extreme parts of the
|
||||
histogram of grey values:
|
||||
|
||||
::
|
||||
@@ -100,19 +100,19 @@ histogram of grey values:
|
||||
We will use these markers in a watershed segmentation. The name watershed
|
||||
comes from an analogy with hydrology. The `watershed transform
|
||||
<http://en.wikipedia.org/wiki/Watershed_%28image_processing%29>`_ floods
|
||||
an image of elevation from markers, in order to determine the catchment
|
||||
an image of elevation starting from markers, in order to determine the catchment
|
||||
basins of these markers. Watershed lines separate these catchment basins,
|
||||
and correspond to the segmentation that is looked for.
|
||||
and correspond to the desired segmentation.
|
||||
|
||||
The choice of the elevation map is critical for a good segmentation.
|
||||
The choice of the elevation map is critical for good segmentation.
|
||||
Here, the amplitude of the gradient provides a good elevation map. We
|
||||
use the Sobel operator for computing the amplitude of the gradient::
|
||||
|
||||
>>> from skimage.filter import sobel
|
||||
>>> elevation_map = sobel(coins)
|
||||
|
||||
From the 3-D surface plot shown below, we see that high barriers separate
|
||||
well the coins from the background.
|
||||
From the 3-D surface plot shown below, we see that high barriers effectively
|
||||
separate the coins from the background.
|
||||
|
||||
.. image:: elevation_map.jpg
|
||||
:align: center
|
||||
|
||||
Reference in New Issue
Block a user