Minor fixes and improvements: PEP8, appearance, etc.

Removed a clumsy workaround (about paths)

Fixed links to image files to fix sphinx warning.

Removed non-ascii character

Another non ascii character

And another non-ascii character... (to be squashed later on)

Corrected some typos in the docstrings of sphinx-gallery files

These corrections have also been submitted as a patch to the original
sphinx-gallery project (#121)

Corrected the appearance of two examples of the gallery

Tweaked CSS for larger images

Added sphinx-gallery's license and a README.txt about the origin of
this directory.

Edited gabor_from_astronaut example for nicer popup

PEP 8 + minor fixes

Removed commented lines of code
This commit is contained in:
emmanuelle
2016-06-06 17:30:44 +02:00
parent d998e7e534
commit 8b2dbd56e5
15 changed files with 101 additions and 72 deletions
+6 -6
View File
@@ -72,12 +72,12 @@ img_adapteq = exposure.equalize_adapthist(img, clip_limit=0.03)
# Display results
fig = plt.figure(figsize=(8, 5))
axes = np.zeros((2,4), dtype=np.object)
axes[0,0] = fig.add_subplot(2, 4, 1)
for i in range(1,4):
axes[0,i] = fig.add_subplot(2, 4, 1+i, sharex=axes[0,0], sharey=axes[0,0])
for i in range(0,4):
axes[1,i] = fig.add_subplot(2, 4, 5+i)
axes = np.zeros((2, 4), dtype=np.object)
axes[0, 0] = fig.add_subplot(2, 4, 1)
for i in range(1, 4):
axes[0, i] = fig.add_subplot(2, 4, 1+i, sharex=axes[0,0], sharey=axes[0,0])
for i in range(0, 4):
axes[1, i] = fig.add_subplot(2, 4, 5+i)
ax_img, ax_hist, ax_cdf = plot_img_and_hist(img, axes[:, 0])
ax_img.set_title('Low contrast image')
@@ -60,7 +60,6 @@ h = rescale_intensity(ihc_hed[:, :, 0], out_range=(0, 1))
d = rescale_intensity(ihc_hed[:, :, 2], out_range=(0, 1))
zdh = np.dstack((np.zeros_like(h), d, h))
#fig, ax = plt.subplots()
fig = plt.figure()
ax = plt.subplot(1, 1, 1, sharex=ax0, sharey=ax0, adjustable='box-forced')
ax.imshow(zdh)
@@ -3,7 +3,7 @@
Gabors / Primary Visual Cortex "Simple Cells" from an Image
============================================================
How to build a (bio-plausible) "sparse" dictionary (or 'codebook', or
How to build a (bio-plausible) *sparse* dictionary (or 'codebook', or
'filterbank') for e.g. image classification without any fancy math and
with just standard python scientific libraries?
@@ -3,11 +3,10 @@
Filling holes and finding peaks
===============================
In this example, we fill holes (i.e. isolated, dark spots) in an image using
morphological reconstruction by erosion. Erosion expands the minimal values of
the seed image until it encounters a mask image. Thus, the seed image and mask
image represent the maximum and minimum possible values of the reconstructed
image.
We fill holes (i.e. isolated, dark spots) in an image using morphological
reconstruction by erosion. Erosion expands the minimal values of the seed image
until it encounters a mask image. Thus, the seed image and mask image represent
the maximum and minimum possible values of the reconstructed image.
We start with an image containing both peaks and holes:
@@ -21,14 +20,6 @@ image = data.moon()
# Rescale image intensity so that we can see dim features.
image = rescale_intensity(image, in_range=(50, 200))
fig,ax = plt.subplots(2, 2, figsize=(5, 4), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'})
ax = ax.ravel()
ax[0].imshow(image)
ax[0].set_title('Original image')
ax[0].axis('off')
######################################################################
# 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
@@ -46,21 +37,12 @@ mask = image
filled = reconstruction(seed, mask, method='erosion')
ax[1].imshow(filled)
ax[1].set_title('after filling holes')
ax[1].axis('off')
######################################################################
# 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')
######################################################################
#
# 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.
@@ -72,7 +54,23 @@ seed = np.copy(image)
seed[1:-1, 1:-1] = image.min()
rec = reconstruction(seed, mask, method='dilation')
ax[3].imshow(image-rec)
fig, ax = plt.subplots(2, 2, figsize=(5, 4), sharex=True, sharey=True,
subplot_kw={'adjustable': 'box-forced'})
ax = ax.ravel()
ax[0].imshow(image, cmap='gray')
ax[0].set_title('Original image')
ax[0].axis('off')
ax[1].imshow(filled, cmap='gray')
ax[1].set_title('after filling holes')
ax[1].axis('off')
ax[2].imshow(image-filled, cmap='gray')
ax[2].set_title('holes')
ax[2].axis('off')
ax[3].imshow(image-rec, cmap='gray')
ax[3].set_title('peaks')
ax[3].axis('off')
plt.show()
@@ -12,19 +12,12 @@ neighborhood around a pixel.
In this document we outline the following basic morphological operations:
1. Erosion
2. Dilation
3. Opening
4. Closing
5. White Tophat
6. Black Tophat
7. Skeletonize
8. Convex Hull
@@ -46,6 +39,7 @@ ax.imshow(orig_phantom, cmap=plt.cm.gray)
######################################################################
# Let's also define a convenience function for plotting comparisons:
def plot_comparison(original, filtered, filter_name):
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4), sharex=True,
@@ -188,9 +182,9 @@ plot_comparison(phantom, b_tophat, 'black tophat')
#
# 1. Erosion <-> Dilation
#
# 2. Opening <-> Closing
# 2. Opening <-> Closing
#
# 3. White tophat <-> Black tophat
# 3. White tophat <-> Black tophat
#
#Skeletonize
#===========
@@ -467,7 +467,7 @@ for ax in ax.ravel():
######################################################################
#
# Feature extraction
# ===================
# ===================
#
# Local histograms can be exploited to compute local entropy, which is
# related to the local image complexity. Entropy is computed using base 2