mirror of
https://github.com/wassname/scikit-image.git
synced 2026-09-12 12:50:49 +08:00
Build gallery with sphinx-gallery
Modified comments in some gallery examples for compatibility with sphinx-gallery parsing. Also modified some links in the narrative doc since image file names have changed.
This commit is contained in:
@@ -29,16 +29,13 @@ ax[0].imshow(image)
|
||||
ax[0].set_title('Original image')
|
||||
ax[0].axis('off')
|
||||
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
|
||||
Now we need to create the seed image, where the minima represent the starting
|
||||
points for erosion. To fill holes, we initialize the seed image to the maximum
|
||||
value of the original image. Along the borders, however, we use the original
|
||||
values of the image. These border pixels will be the starting points for the
|
||||
erosion process. We then limit the erosion by setting the mask to the values
|
||||
of the original image.
|
||||
"""
|
||||
######################################################################
|
||||
# Now we need to create the seed image, where the minima represent the
|
||||
# starting points for erosion. To fill holes, we initialize the seed image
|
||||
# to the maximum value of the original image. Along the borders, however, we
|
||||
# use the original values of the image. These border pixels will be the
|
||||
# starting points for the erosion process. We then limit the erosion by
|
||||
# setting the mask to the values of the original image.
|
||||
|
||||
import numpy as np
|
||||
from skimage.morphology import reconstruction
|
||||
@@ -52,28 +49,24 @@ filled = reconstruction(seed, mask, method='erosion')
|
||||
ax[1].imshow(filled)
|
||||
ax[1].set_title('after filling holes')
|
||||
ax[1].axis('off')
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
|
||||
As shown above, eroding inward from the edges removes holes, since (by
|
||||
definition) holes are surrounded by pixels of brighter value. Finally, we can
|
||||
isolate the dark regions by subtracting the reconstructed image from the
|
||||
original image.
|
||||
"""
|
||||
######################################################################
|
||||
# As shown above, eroding inward from the edges removes holes, since (by
|
||||
# definition) holes are surrounded by pixels of brighter value. Finally, we
|
||||
# can isolate the dark regions by subtracting the reconstructed image from
|
||||
# the original image.
|
||||
|
||||
ax[2].imshow(image-filled)
|
||||
ax[2].set_title('holes')
|
||||
ax[2].axis('off')
|
||||
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
|
||||
Alternatively, we can find bright spots in an image using morphological
|
||||
reconstruction by dilation. Dilation is the inverse of erosion and expands the
|
||||
*maximal* values of the seed image until it encounters a mask image. Since this
|
||||
is an inverse operation, we initialize the seed image to the minimum image
|
||||
intensity instead of the maximum. The remainder of the process is the same.
|
||||
"""
|
||||
######################################################################
|
||||
# Alternatively, we can find bright spots in an image using morphological
|
||||
# reconstruction by dilation. Dilation is the inverse of erosion and expands
|
||||
# the *maximal* values of the seed image until it encounters a mask image.
|
||||
# Since this is an inverse operation, we initialize the seed image to the
|
||||
# minimum image intensity instead of the maximum. The remainder of the
|
||||
# process is the same.
|
||||
|
||||
seed = np.copy(image)
|
||||
seed[1:-1, 1:-1] = image.min()
|
||||
@@ -83,7 +76,3 @@ ax[3].imshow(image-rec)
|
||||
ax[3].set_title('peaks')
|
||||
ax[3].axis('off')
|
||||
plt.show()
|
||||
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
"""
|
||||
|
||||
@@ -69,21 +69,18 @@ for ax, values, name in zip(axes, binary_patterns, titles):
|
||||
plot_lbp_model(ax, values)
|
||||
ax.set_title(name)
|
||||
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
|
||||
The figure above shows example results with black (or white) representing
|
||||
pixels that are less (or more) intense than the central pixel. When surrounding
|
||||
pixels are all black or all white, then that image region is flat (i.e.
|
||||
featureless). Groups of continuous black or white pixels are considered
|
||||
"uniform" patterns that can be interpreted as corners or edges. If pixels
|
||||
switch back-and-forth between black and white pixels, the pattern is considered
|
||||
"non-uniform".
|
||||
|
||||
When using LBP to detect texture, you measure a collection of LBPs over an
|
||||
image patch and look at the distribution of these LBPs. Lets apply LBP to
|
||||
a brick texture.
|
||||
"""
|
||||
######################################################################
|
||||
# The figure above shows example results with black (or white) representing
|
||||
# pixels that are less (or more) intense than the central pixel. When
|
||||
# surrounding pixels are all black or all white, then that image region is
|
||||
# flat (i.e. featureless). Groups of continuous black or white pixels are
|
||||
# considered "uniform" patterns that can be interpreted as corners or edges.
|
||||
# If pixels switch back-and-forth between black and white pixels, the pattern
|
||||
# is considered "non-uniform".
|
||||
#
|
||||
# When using LBP to detect texture, you measure a collection of LBPs over an
|
||||
# image patch and look at the distribution of these LBPs. Lets apply LBP to a
|
||||
# brick texture.
|
||||
|
||||
from skimage.transform import rotate
|
||||
from skimage.feature import local_binary_pattern
|
||||
@@ -145,16 +142,13 @@ for ax in ax_img:
|
||||
ax.axis('off')
|
||||
|
||||
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
|
||||
The above plot highlights flat, edge-like, and corner-like regions of the
|
||||
image.
|
||||
|
||||
The histogram of the LBP result is a good measure to classify textures. Here,
|
||||
we test the histogram distributions against each other using the
|
||||
Kullback-Leibler-Divergence.
|
||||
"""
|
||||
######################################################################
|
||||
# The above plot highlights flat, edge-like, and corner-like regions of the
|
||||
# image.
|
||||
#
|
||||
# The histogram of the LBP result is a good measure to classify textures.
|
||||
# Here, we test the histogram distributions against each other using the
|
||||
# Kullback-Leibler-Divergence.
|
||||
|
||||
# settings for LBP
|
||||
radius = 2
|
||||
@@ -222,8 +216,4 @@ ax3.imshow(wall)
|
||||
ax3.axis('off')
|
||||
hist(ax6, refs['wall'])
|
||||
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
"""
|
||||
|
||||
plt.show()
|
||||
|
||||
@@ -43,10 +43,10 @@ lbp_code = multiblock_lbp(int_img, 0, 0, 3, 3)
|
||||
|
||||
assert_equal(correct_answer, lbp_code)
|
||||
|
||||
"""
|
||||
Now let's apply the operator to a real image and see how the
|
||||
visualization works.
|
||||
"""
|
||||
######################################################################
|
||||
# Now let's apply the operator to a real image and see how the visualization
|
||||
# works.
|
||||
|
||||
from skimage import data
|
||||
from matplotlib import pyplot as plt
|
||||
from skimage.feature import draw_multiblock_lbp
|
||||
@@ -65,11 +65,9 @@ plt.imshow(img, interpolation='nearest')
|
||||
|
||||
plt.show()
|
||||
|
||||
"""
|
||||
.. image:: PLOT2RST.current_figure
|
||||
|
||||
On the above plot we see the result of computing a MB-LBP and visualization of
|
||||
the computed feature. The rectangles that have less intensities' sum than the
|
||||
central rectangle are marked in cyan. The ones that have higher intensity
|
||||
values are marked in white. The central rectangle is left untouched.
|
||||
"""
|
||||
######################################################################
|
||||
# On the above plot we see the result of computing a MB-LBP and visualization
|
||||
# of the computed feature. The rectangles that have less intensities' sum
|
||||
# than the central rectangle are marked in cyan. The ones that have higher
|
||||
# intensity values are marked in white. The central rectangle is left
|
||||
# untouched.
|
||||
|
||||
Reference in New Issue
Block a user