mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-16 11:21:25 +08:00
Merge branch 'pr/531'
This commit is contained in:
@@ -14,6 +14,7 @@ __all__ = ['histogram', 'cumulative_distribution', 'equalize',
|
||||
def histogram(image, nbins=256):
|
||||
"""Return histogram of image.
|
||||
|
||||
|
||||
Unlike `numpy.histogram`, this function returns the centers of bins and
|
||||
does not rebin integer arrays. For integer arrays, each integer value has
|
||||
its own bin, which improves speed and intensity-resolution.
|
||||
@@ -32,6 +33,14 @@ def histogram(image, nbins=256):
|
||||
The values of the histogram.
|
||||
bin_centers : array
|
||||
The values at the center of the bins.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> hist = histogram(data.camera())
|
||||
>>> import matplotlib.pyplot as plt
|
||||
>>> plt.plot(hist[1], hist[0]) # doctest: +ELLIPSIS
|
||||
[...]
|
||||
"""
|
||||
|
||||
# For integer types, histogramming with bincount is more efficient.
|
||||
|
||||
@@ -42,6 +42,13 @@ def median_filter(image, radius=2, mask=None, percent=50):
|
||||
not overlap the mask, the filtered result is underfined, but
|
||||
in practice, it will be the lowest value in the valid area.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> a = np.ones((5, 5))
|
||||
>>> a[2, 2] = 10 # introduce outlier
|
||||
>>> b = median_filter(a)
|
||||
>>> b[2, 2] # the median filter is good at removing outliers
|
||||
1.0
|
||||
'''
|
||||
|
||||
if image.ndim != 2:
|
||||
|
||||
@@ -95,6 +95,17 @@ def find_contours(array, level,
|
||||
Resolution 3D Surface Construction Algorithm. Computer Graphics
|
||||
(SIGGRAPH 87 Proceedings) 21(4) July 1987, p. 163-170).
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> a = np.zeros((3, 3))
|
||||
>>> a[0, 0] = 1
|
||||
>>> a
|
||||
array([[ 1., 0., 0.],
|
||||
[ 0., 0., 0.],
|
||||
[ 0., 0., 0.]])
|
||||
>>> find_contours(a, 0.5)
|
||||
[array([[ 0. , 0.5],
|
||||
[ 0.5, 0. ]])]
|
||||
"""
|
||||
array = np.asarray(array, dtype=np.double)
|
||||
if array.ndim != 2:
|
||||
|
||||
@@ -60,13 +60,15 @@ def reconstruction(seed, mask, method='dilation', selem=None, offset=None):
|
||||
>>> import numpy as np
|
||||
>>> from skimage.morphology import reconstruction
|
||||
|
||||
First, we create a sinusoidal mask image w/ peaks at middle and ends.
|
||||
First, we create a sinusoidal mask image with peaks at middle and ends.
|
||||
|
||||
>>> x = np.linspace(0, 4 * np.pi)
|
||||
>>> y_mask = np.cos(x)
|
||||
|
||||
Then, we create a seed image initialized to the minimum mask value (for
|
||||
reconstruction by dilation, min-intensity values don't spread) and add
|
||||
"seeds" to the left and right peak, but at a fraction of peak value (1).
|
||||
|
||||
>>> y_seed = y_mask.min() * np.ones_like(x)
|
||||
>>> y_seed[0] = 0.5
|
||||
>>> y_seed[-1] = 0
|
||||
|
||||
Reference in New Issue
Block a user