mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 04:10:46 +08:00
@@ -11,7 +11,6 @@ position of corners.
|
||||
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
|
||||
@@ -19,7 +19,6 @@ values, and use the random walker for the segmentation.
|
||||
.. [1] *Random walks for image segmentation*, Leo Grady, IEEE Trans. Pattern
|
||||
Anal. Mach. Intell. 2006 Nov; 28(11):1768-83
|
||||
"""
|
||||
print __doc__
|
||||
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
|
||||
+11
-1
@@ -69,6 +69,7 @@ import os
|
||||
import shutil
|
||||
import token
|
||||
import tokenize
|
||||
import traceback
|
||||
|
||||
import numpy as np
|
||||
import matplotlib
|
||||
@@ -247,7 +248,16 @@ def write_gallery(gallery_index, src_dir, rst_dir, cfg, depth=0):
|
||||
gallery_index.write(TOCTREE_TEMPLATE % (sub_dir + '\n '.join(ex_names)))
|
||||
|
||||
for src_name in examples:
|
||||
write_example(src_name, src_dir, rst_dir, cfg)
|
||||
|
||||
try:
|
||||
write_example(src_name, src_dir, rst_dir, cfg)
|
||||
except Exception:
|
||||
print "Exception raised while running:"
|
||||
print "%s in %s" % (src_name, src_dir)
|
||||
print '~' * 60
|
||||
traceback.print_exc()
|
||||
print '~' * 60
|
||||
continue
|
||||
|
||||
link_name = sub_dir.pjoin(src_name)
|
||||
link_name = link_name.replace(os.path.sep, '_')
|
||||
|
||||
@@ -259,6 +259,8 @@ def map_histogram(hist, min_val, max_val, n_pixels):
|
||||
|
||||
It does so by cumulating the input histogram.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
hist : ndarray
|
||||
Clipped histogram.
|
||||
min_val : int
|
||||
@@ -301,12 +303,11 @@ def interpolate(image, xslice, yslice,
|
||||
out : ndarray
|
||||
Original image with the subregion replaced.
|
||||
|
||||
Note
|
||||
----
|
||||
This function calculates the new greylevel assignments of pixels
|
||||
within a submatrix of the image.
|
||||
This is done by a bilinear interpolation between four different
|
||||
mappings in order to eliminate boundary artifacts.
|
||||
Notes
|
||||
-----
|
||||
This function calculates the new greylevel assignments of pixels within
|
||||
a submatrix of the image. This is done by a bilinear interpolation between
|
||||
four different mappings in order to eliminate boundary artifacts.
|
||||
"""
|
||||
norm = xslice.size * yslice.size # Normalization factor
|
||||
# interpolation weight matrices
|
||||
|
||||
@@ -53,30 +53,35 @@ def daisy(img, step=4, radius=15, rings=3, histograms=8, orientations=8,
|
||||
the spatial smoothing of the center histogram and the last sigma value
|
||||
defines the spatial smoothing of the outermost ring. Specifying sigmas
|
||||
overrides the following parameter.
|
||||
``rings = len(sigmas)-1``
|
||||
|
||||
``rings = len(sigmas) - 1``
|
||||
|
||||
ring_radii : 1D array of int, optional
|
||||
Radius (in pixels) for each ring. Specifying ring_radii overrides the
|
||||
following two parameters.
|
||||
| ``rings = len(ring_radii)``
|
||||
| ``radius = ring_radii[-1]``
|
||||
|
||||
``rings = len(ring_radii)``
|
||||
``radius = ring_radii[-1]``
|
||||
|
||||
If both sigmas and ring_radii are given, they must satisfy the
|
||||
following predicate since no radius is needed for the center
|
||||
histogram.
|
||||
``len(ring_radii) == len(sigmas)+1``
|
||||
|
||||
``len(ring_radii) == len(sigmas) + 1``
|
||||
|
||||
visualize : bool, optional
|
||||
Generate a visualization of the DAISY descriptors
|
||||
|
||||
|
||||
Returns
|
||||
-------
|
||||
descs : array
|
||||
Grid of DAISY descriptors for the given image as an array
|
||||
dimensionality (P, Q, R) where
|
||||
| ``P = ceil((M-radius*2)/step)``
|
||||
| ``Q = ceil((N-radius*2)/step)``
|
||||
| ``R = (rings*histograms + 1)*orientations``
|
||||
|
||||
``P = ceil((M - radius*2) / step)``
|
||||
``Q = ceil((N - radius*2) / step)``
|
||||
``R = (rings * histograms + 1) * orientations``
|
||||
|
||||
descs_img : (M, N, 3) array (only if visualize==True)
|
||||
Visualization of the DAISY descriptors.
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ def corner_harris(image, method='k', k=0.05, eps=1e-6, sigma=1):
|
||||
..[2] http://en.wikipedia.org/wiki/Corner_detection
|
||||
|
||||
Examples
|
||||
-------
|
||||
--------
|
||||
>>> from skimage.feature import corner_harris, corner_peaks
|
||||
>>> square = np.zeros([10, 10])
|
||||
>>> square[2:8, 2:8] = 1
|
||||
@@ -210,7 +210,7 @@ def corner_shi_tomasi(image, sigma=1):
|
||||
..[2] http://en.wikipedia.org/wiki/Corner_detection
|
||||
|
||||
Examples
|
||||
-------
|
||||
--------
|
||||
>>> from skimage.feature import corner_shi_tomasi, corner_peaks
|
||||
>>> square = np.zeros([10, 10])
|
||||
>>> square[2:8, 2:8] = 1
|
||||
@@ -277,7 +277,7 @@ def corner_foerstner(image, sigma=1):
|
||||
..[2] http://en.wikipedia.org/wiki/Corner_detection
|
||||
|
||||
Examples
|
||||
-------
|
||||
--------
|
||||
>>> from skimage.feature import corner_foerstner, corner_peaks
|
||||
>>> square = np.zeros([10, 10])
|
||||
>>> square[2:8, 2:8] = 1
|
||||
|
||||
@@ -34,7 +34,7 @@ def corner_moravec(image, Py_ssize_t window_size=1):
|
||||
..[2] http://en.wikipedia.org/wiki/Corner_detection
|
||||
|
||||
Examples
|
||||
-------
|
||||
--------
|
||||
>>> from skimage.feature import moravec, peak_local_max
|
||||
>>> square = np.zeros([7, 7])
|
||||
>>> square[3, 3] = 1
|
||||
|
||||
@@ -50,9 +50,10 @@ def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
|
||||
Returns
|
||||
-------
|
||||
output : (N, 2) array or ndarray of bools
|
||||
If `indices = True` : (row, column) coordinates of peaks.
|
||||
If `indices = False` : Boolean array shaped like `image`,
|
||||
with peaks represented by True values.
|
||||
|
||||
* If `indices = True` : (row, column) coordinates of peaks.
|
||||
* If `indices = False` : Boolean array shaped like `image`, with peaks
|
||||
represented by True values.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
@@ -32,7 +32,7 @@ def _denoise_tv_chambolle_3d(im, weight=100, eps=2.e-4, n_iter_max=200):
|
||||
Rudin, Osher and Fatemi algorithm.
|
||||
|
||||
Examples
|
||||
---------
|
||||
--------
|
||||
>>> x, y, z = np.ogrid[0:40, 0:40, 0:40]
|
||||
>>> mask = (x - 22)**2 + (y - 20)**2 + (z - 17)**2 < 8**2
|
||||
>>> mask = mask.astype(np.float)
|
||||
@@ -123,7 +123,7 @@ def _denoise_tv_chambolle_2d(im, weight=50, eps=2.e-4, n_iter_max=200):
|
||||
Springer, 2004, 20, 89-97.
|
||||
|
||||
Examples
|
||||
---------
|
||||
--------
|
||||
>>> from skimage import color, data
|
||||
>>> lena = color.rgb2gray(data.lena())
|
||||
>>> lena += 0.5 * lena.std() * np.random.randn(*lena.shape)
|
||||
@@ -221,7 +221,7 @@ def denoise_tv_chambolle(im, weight=50, eps=2.e-4, n_iter_max=200,
|
||||
Springer, 2004, 20, 89-97.
|
||||
|
||||
Examples
|
||||
---------
|
||||
--------
|
||||
2D example on Lena image:
|
||||
|
||||
>>> from skimage import color, data
|
||||
|
||||
@@ -648,12 +648,12 @@ def noise_filter(image, selem, out=None, mask=None, shift_x=False,
|
||||
References
|
||||
----------
|
||||
.. [Hashimoto12] N. Hashimoto et al. Referenceless image quality evaluation
|
||||
for whole slide imaging. J Pathol Inform 2012;3:9.
|
||||
for whole slide imaging. J Pathol Inform 2012;3:9.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : uint8 array or uint16 array (same as input image)
|
||||
The image noise .
|
||||
The image noise.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@ from ..filter import rank_order
|
||||
|
||||
|
||||
def _make_graph_edges_3d(n_x, n_y, n_z):
|
||||
"""
|
||||
Returns a list of edges for a 3D image.
|
||||
"""Returns a list of edges for a 3D image.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -45,9 +44,12 @@ def _make_graph_edges_3d(n_x, n_y, n_z):
|
||||
Returns
|
||||
-------
|
||||
edges : (2, N) ndarray
|
||||
with the total number of edges N = n_x * n_y * (nz - 1) +
|
||||
n_x * (n_y - 1) * nz +
|
||||
(n_x - 1) * n_y * nz
|
||||
with the total number of edges::
|
||||
|
||||
N = n_x * n_y * (nz - 1) +
|
||||
n_x * (n_y - 1) * nz +
|
||||
(n_x - 1) * n_y * nz
|
||||
|
||||
Graph edges with each column describing a node-id pair.
|
||||
"""
|
||||
vertices = np.arange(n_x * n_y * n_z).reshape((n_x, n_y, n_z))
|
||||
@@ -200,6 +202,7 @@ def random_walker(data, labels, beta=130, mode='bf', tol=1.e-3, copy=True,
|
||||
mode : {'bf', 'cg_mg', 'cg'} (default: 'bf')
|
||||
Mode for solving the linear system in the random walker
|
||||
algorithm.
|
||||
|
||||
- 'bf' (brute force, default): an LU factorization of the Laplacian is
|
||||
computed. This is fast for small images (<1024x1024), but very slow
|
||||
(due to the memory cost) and memory-consuming for big images (in 3-D
|
||||
@@ -214,6 +217,7 @@ def random_walker(data, labels, beta=130, mode='bf', tol=1.e-3, copy=True,
|
||||
requires that the pyamg module (http://code.google.com/p/pyamg/) is
|
||||
installed. For images of size > 512x512, this is the recommended
|
||||
(fastest) mode.
|
||||
|
||||
tol : float
|
||||
tolerance to achieve when solving the linear system, in
|
||||
cg' and 'cg_mg' modes.
|
||||
@@ -237,12 +241,12 @@ def random_walker(data, labels, beta=130, mode='bf', tol=1.e-3, copy=True,
|
||||
Returns
|
||||
-------
|
||||
output : ndarray
|
||||
If `return_full_prob` is False, array of ints of same shape as `data`,
|
||||
in which each pixel has been labeled according to the marker that
|
||||
reached the pixel first by anisotropic diffusion.
|
||||
If `return_full_prob` is True, array of floats of shape
|
||||
`(nlabels, data.shape)`. `output[label_nb, i, j]` is the probability
|
||||
that label `label_nb` reaches the pixel `(i, j)` first.
|
||||
* If `return_full_prob` is False, array of ints of same shape as
|
||||
`data`, in which each pixel has been labeled according to the marker
|
||||
that reached the pixel first by anisotropic diffusion.
|
||||
* If `return_full_prob` is True, array of floats of shape
|
||||
`(nlabels, data.shape)`. `output[label_nb, i, j]` is the probability
|
||||
that label `label_nb` reaches the pixel `(i, j)` first.
|
||||
|
||||
See also
|
||||
--------
|
||||
|
||||
Reference in New Issue
Block a user