mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 23:11:53 +08:00
Merge pull request #274 from ahojnnes/doc-update
DOC: Overall cleanups.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
"""
|
||||
====================
|
||||
Approximate Polygons
|
||||
====================
|
||||
===================================
|
||||
Approximatea and subdivide polygons
|
||||
===================================
|
||||
|
||||
This example shows how to approximate polygonal chains with the Douglas-Peucker
|
||||
algorithm.
|
||||
This example shows how to approximate (Douglas-Peucker algorithm) and subdivide
|
||||
(B-Splines) polygonal chains.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -29,8 +29,9 @@ def load(f):
|
||||
|
||||
|
||||
def camera():
|
||||
"""Gray-level "camera" image, often used for segmentation
|
||||
and denoising examples.
|
||||
"""Gray-level "camera" image.
|
||||
|
||||
Often used for segmentation and denoising examples.
|
||||
|
||||
"""
|
||||
return load("camera.png")
|
||||
@@ -49,7 +50,7 @@ def lena():
|
||||
|
||||
|
||||
def text():
|
||||
""" Gray-level "text" image used for corner detection.
|
||||
"""Gray-level "text" image used for corner detection.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
+10
-7
@@ -65,6 +65,7 @@ def line(int y, int x, int y2, int x2):
|
||||
|
||||
return rr, cc
|
||||
|
||||
|
||||
@cython.boundscheck(False)
|
||||
@cython.wraparound(False)
|
||||
@cython.nonecheck(False)
|
||||
@@ -74,9 +75,9 @@ def polygon(y, x, shape=None):
|
||||
Parameters
|
||||
----------
|
||||
y : (N,) ndarray
|
||||
y coordinates of vertices of polygon
|
||||
Y-coordinates of vertices of polygon.
|
||||
x : (N,) ndarray
|
||||
x coordinates of vertices of polygon
|
||||
X-coordinates of vertices of polygon.
|
||||
shape : tuple, optional
|
||||
image shape which is used to determine maximum extents of output pixel
|
||||
coordinates. This is useful for polygons which exceed the image size.
|
||||
@@ -121,6 +122,7 @@ def polygon(y, x, shape=None):
|
||||
|
||||
return np.array(rr), np.array(cc)
|
||||
|
||||
|
||||
@cython.boundscheck(False)
|
||||
@cython.wraparound(False)
|
||||
@cython.nonecheck(False)
|
||||
@@ -131,9 +133,9 @@ def ellipse(double cy, double cx, double b, double a, shape=None):
|
||||
Parameters
|
||||
----------
|
||||
cy, cx : double
|
||||
centre coordinate of ellipse
|
||||
Centre coordinate of ellipse.
|
||||
b, a: double
|
||||
minor and major semi-axes. (x/a)**2 + (y/b)**2 = 1
|
||||
Minor and major semi-axes. ``(x/a)**2 + (y/b)**2 = 1``.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -166,20 +168,21 @@ def ellipse(double cy, double cx, double b, double a, shape=None):
|
||||
|
||||
return np.array(rr), np.array(cc)
|
||||
|
||||
|
||||
def circle(double cy, double cx, double radius, shape=None):
|
||||
"""Generate coordinates of pixels within circle.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
cy, cx : double
|
||||
centre coordinate of circle
|
||||
Centre coordinate of circle.
|
||||
radius: double
|
||||
radius of circle
|
||||
Radius of circle.
|
||||
|
||||
Returns
|
||||
-------
|
||||
rr, cc : ndarray of int
|
||||
Pixel coordinates of ellipse.
|
||||
Pixel coordinates of circle.
|
||||
May be used to directly index into an array, e.g.
|
||||
``img[rr, cc] = 1``.
|
||||
"""
|
||||
|
||||
@@ -135,30 +135,36 @@ def rescale_intensity(image, in_range=None, out_range=None):
|
||||
Examples
|
||||
--------
|
||||
By default, intensities are stretched to the limits allowed by the dtype:
|
||||
|
||||
>>> image = np.array([51, 102, 153], dtype=np.uint8)
|
||||
>>> rescale_intensity(image)
|
||||
array([ 0, 127, 255], dtype=uint8)
|
||||
|
||||
It's easy to accidentally convert an image dtype from uint8 to float:
|
||||
|
||||
>>> 1.0 * image
|
||||
array([ 51., 102., 153.])
|
||||
|
||||
Use `rescale_intensity` to rescale to the proper range for float dtypes:
|
||||
|
||||
>>> image_float = 1.0 * image
|
||||
>>> rescale_intensity(image_float)
|
||||
array([ 0. , 0.5, 1. ])
|
||||
|
||||
To maintain the low contrast of the original, use the `in_range` parameter:
|
||||
|
||||
>>> rescale_intensity(image_float, in_range=(0, 255))
|
||||
array([ 0.2, 0.4, 0.6])
|
||||
|
||||
If the min/max value of `in_range` is more/less than the min/max image
|
||||
intensity, then the intensity levels are clipped:
|
||||
|
||||
>>> rescale_intensity(image_float, in_range=(0, 102))
|
||||
array([ 0.5, 1. , 1. ])
|
||||
|
||||
If you have an image with signed integers but want to rescale the image to
|
||||
just the positive range, use the `out_range` parameter:
|
||||
|
||||
>>> image = np.array([-10, 0, 10], dtype=np.int8)
|
||||
>>> rescale_intensity(image, out_range=(0, 127))
|
||||
array([ 0, 63, 127], dtype=int8)
|
||||
|
||||
@@ -95,7 +95,8 @@ def _local_binary_pattern(np.ndarray[double, ndim=2] image,
|
||||
R : float
|
||||
Radius of circle (spatial resolution of the operator).
|
||||
method : {'D', 'R', 'U', 'V'}
|
||||
Method to determine the pattern::
|
||||
Method to determine the pattern.
|
||||
|
||||
* 'D': 'default'
|
||||
* 'R': 'ror'
|
||||
* 'U': 'uniform'
|
||||
|
||||
@@ -15,21 +15,16 @@ def peak_local_max(image, min_distance=10, threshold='deprecated',
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image: ndarray of floats
|
||||
image : ndarray of floats
|
||||
Input image.
|
||||
|
||||
min_distance: int
|
||||
min_distance : int
|
||||
Minimum number of pixels separating peaks and image boundary.
|
||||
|
||||
threshold : float
|
||||
Deprecated. See `threshold_rel`.
|
||||
|
||||
threshold_abs: float
|
||||
threshold_abs : float
|
||||
Minimum intensity of peaks.
|
||||
|
||||
threshold_rel: float
|
||||
threshold_rel : float
|
||||
Minimum intensity of peaks calculated as `max(image) * threshold_rel`.
|
||||
|
||||
num_peaks : int
|
||||
Maximum number of peaks. When the number of peaks exceeds `num_peaks`,
|
||||
return `num_peaks` coordinates based on peak intensity.
|
||||
|
||||
@@ -139,7 +139,6 @@ def greycoprops(P, prop='contrast'):
|
||||
`P[i,j,d,theta]` is the number of times that grey-level j
|
||||
occurs at a distance d and at an angle theta from
|
||||
grey-level i.
|
||||
|
||||
prop : {'contrast', 'dissimilarity', 'homogeneity', 'energy', \
|
||||
'correlation', 'ASM'}, optional
|
||||
The property of the GLCM to compute. The default is 'contrast'.
|
||||
@@ -241,8 +240,9 @@ def local_binary_pattern(image, P, R, method='default'):
|
||||
angular space).
|
||||
R : float
|
||||
Radius of circle (spatial resolution of the operator).
|
||||
method : {'D', 'R', 'U', 'V'}
|
||||
Method to determine the pattern::
|
||||
method : {'default', 'ror', 'uniform', 'var'}
|
||||
Method to determine the pattern.
|
||||
|
||||
* 'default': original local binary pattern which is gray scale but not
|
||||
rotation invariant.
|
||||
* 'ror': extension of default implementation which is gray scale and
|
||||
|
||||
@@ -16,7 +16,7 @@ def threshold_adaptive(image, block_size, method='gaussian', offset=0,
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : NxM ndarray
|
||||
image : (N, M) ndarray
|
||||
Input image.
|
||||
block_size : int
|
||||
Uneven size of pixel neighborhood which is used to calculate the
|
||||
@@ -45,7 +45,7 @@ def threshold_adaptive(image, block_size, method='gaussian', offset=0,
|
||||
|
||||
Returns
|
||||
-------
|
||||
threshold : NxM ndarray
|
||||
threshold : (N, M) ndarray
|
||||
Thresholded binary image
|
||||
|
||||
References
|
||||
|
||||
@@ -7,7 +7,7 @@ from skimage.util import img_as_float
|
||||
def _stackcopy(a, b):
|
||||
"""Copy b into each color layer of a, such that::
|
||||
|
||||
a[:,:,0] = a[:,:,1] = ... = b
|
||||
a[:,:,0] = a[:,:,1] = ... = b
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -37,12 +37,12 @@ class GeometricTransform(object):
|
||||
Parameters
|
||||
----------
|
||||
coords : (N, 2) array
|
||||
source coordinates
|
||||
Source coordinates.
|
||||
|
||||
Returns
|
||||
-------
|
||||
coords : (N, 2) array
|
||||
transformed coordinates
|
||||
Transformed coordinates.
|
||||
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
@@ -53,12 +53,12 @@ class GeometricTransform(object):
|
||||
Parameters
|
||||
----------
|
||||
coords : (N, 2) array
|
||||
source coordinates
|
||||
Source coordinates.
|
||||
|
||||
Returns
|
||||
-------
|
||||
coords : (N, 2) array
|
||||
transformed coordinates
|
||||
Transformed coordinates.
|
||||
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
@@ -182,9 +182,9 @@ class ProjectiveTransform(GeometricTransform):
|
||||
Parameters
|
||||
----------
|
||||
src : (N, 2) array
|
||||
source coordinates
|
||||
Source coordinates.
|
||||
dst : (N, 2) array
|
||||
destination coordinates
|
||||
Destination coordinates.
|
||||
|
||||
"""
|
||||
xs = src[:, 0]
|
||||
@@ -260,13 +260,13 @@ class AffineTransform(ProjectiveTransform):
|
||||
matrix : (3, 3) array, optional
|
||||
Homogeneous transformation matrix.
|
||||
scale : (sx, sy) as array, list or tuple, optional
|
||||
scale factors
|
||||
Scale factors.
|
||||
rotation : float, optional
|
||||
rotation angle in counter-clockwise direction as radians
|
||||
Rotation angle in counter-clockwise direction as radians.
|
||||
shear : float, optional
|
||||
shear angle in counter-clockwise direction as radians
|
||||
Shear angle in counter-clockwise direction as radians.
|
||||
translation : (tx, ty) as array, list or tuple, optional
|
||||
translation parameters
|
||||
Translation parameters.
|
||||
|
||||
"""
|
||||
|
||||
@@ -345,11 +345,11 @@ class SimilarityTransform(ProjectiveTransform):
|
||||
matrix : (3, 3) array, optional
|
||||
Homogeneous transformation matrix.
|
||||
scale : float, optional
|
||||
scale factor
|
||||
Scale factor.
|
||||
rotation : float, optional
|
||||
rotation angle in counter-clockwise direction as radians
|
||||
Rotation angle in counter-clockwise direction as radians.
|
||||
translation : (tx, ty) as array, list or tuple, optional
|
||||
x, y translation parameters
|
||||
x, y translation parameters.
|
||||
|
||||
"""
|
||||
|
||||
@@ -420,9 +420,9 @@ class SimilarityTransform(ProjectiveTransform):
|
||||
Parameters
|
||||
----------
|
||||
src : (N, 2) array
|
||||
source coordinates
|
||||
Source coordinates.
|
||||
dst : (N, 2) array
|
||||
destination coordinates
|
||||
Destination coordinates.
|
||||
|
||||
"""
|
||||
xs = src[:, 0]
|
||||
@@ -530,11 +530,11 @@ class PolynomialTransform(GeometricTransform):
|
||||
Parameters
|
||||
----------
|
||||
src : (N, 2) array
|
||||
source coordinates
|
||||
Source coordinates.
|
||||
dst : (N, 2) array
|
||||
destination coordinates
|
||||
Destination coordinates.
|
||||
order : int
|
||||
polynomial order (number of coefficients is order + 1)
|
||||
Polynomial order (number of coefficients is order + 1).
|
||||
|
||||
"""
|
||||
xs = src[:, 0]
|
||||
@@ -576,7 +576,7 @@ class PolynomialTransform(GeometricTransform):
|
||||
Returns
|
||||
-------
|
||||
coords : (N, 2) array
|
||||
transformed coordinates
|
||||
Transformed coordinates.
|
||||
|
||||
"""
|
||||
x = coords[:, 0]
|
||||
@@ -692,7 +692,7 @@ def matrix_transform(coords, matrix):
|
||||
Returns
|
||||
-------
|
||||
coords : (N, 2) array
|
||||
transformed coordinates
|
||||
Transformed coordinates.
|
||||
|
||||
"""
|
||||
return ProjectiveTransform(matrix)(coords)
|
||||
@@ -705,13 +705,13 @@ def warp_coords(orows, ocols, bands, coord_transform_fn,
|
||||
Parameters
|
||||
----------
|
||||
orows : int
|
||||
number of output rows
|
||||
Number of output rows.
|
||||
ocols : int
|
||||
number of output columns
|
||||
Number of output columns.
|
||||
bands : int
|
||||
number of color bands (aka channels)
|
||||
Number of color bands (aka channels).
|
||||
coord_transform_fn : callable like GeometricTransform.inverse
|
||||
Return input coordinates for given output coordinates
|
||||
Return input coordinates for given output coordinates.
|
||||
dtype : np.dtype or string
|
||||
dtype for return value (sane choices: float32 or float64)
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ def iradon(radon_image, theta=None, output_size=None,
|
||||
the image corresponds to a projection along a different angle.
|
||||
theta : array_like, dtype=float, optional
|
||||
Reconstruction angles (in degrees). Default: m angles evenly spaced
|
||||
between 0 and 180 (if the shape of `radon_image` is nxm)
|
||||
between 0 and 180 (if the shape of `radon_image` is (N, M)).
|
||||
output_size : int
|
||||
Number of rows and columns in the reconstruction.
|
||||
filter : str, optional (default ramp)
|
||||
|
||||
Reference in New Issue
Block a user