From 32afefef2336eda736ff5f305b24927d7535b790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 00:08:29 +0200 Subject: [PATCH 1/8] Fix doc string of texture detection --- skimage/feature/_texture.pyx | 3 ++- skimage/feature/texture.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/skimage/feature/_texture.pyx b/skimage/feature/_texture.pyx index 0e82c306..5fb53e90 100644 --- a/skimage/feature/_texture.pyx +++ b/skimage/feature/_texture.pyx @@ -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' diff --git a/skimage/feature/texture.py b/skimage/feature/texture.py index aa970d18..22b5d0d8 100644 --- a/skimage/feature/texture.py +++ b/skimage/feature/texture.py @@ -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 From 4fe9f39c45ed1cc21848a27fc1ac14d68ab5d771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 00:16:52 +0200 Subject: [PATCH 2/8] Fix shape format of arrays in doc strings --- skimage/filter/thresholding.py | 4 ++-- skimage/transform/radon_transform.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/skimage/filter/thresholding.py b/skimage/filter/thresholding.py index 022cacc5..3f8acdef 100644 --- a/skimage/filter/thresholding.py +++ b/skimage/filter/thresholding.py @@ -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 diff --git a/skimage/transform/radon_transform.py b/skimage/transform/radon_transform.py index b716a6f1..f80cc3cb 100644 --- a/skimage/transform/radon_transform.py +++ b/skimage/transform/radon_transform.py @@ -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) From 7acb9f9efb89a3834e6f9476d209665b535cdb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 00:27:55 +0200 Subject: [PATCH 3/8] Fix short description in doc string --- skimage/data/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/skimage/data/__init__.py b/skimage/data/__init__.py index 7e351293..5e51d353 100644 --- a/skimage/data/__init__.py +++ b/skimage/data/__init__.py @@ -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 ----- From e9b8645ee67e58fb322354f663744279b667dfa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 00:29:18 +0200 Subject: [PATCH 4/8] Fix parameter format in doc string of peak_local_max --- skimage/feature/peak.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/skimage/feature/peak.py b/skimage/feature/peak.py index 57eb3bb7..4765974e 100644 --- a/skimage/feature/peak.py +++ b/skimage/feature/peak.py @@ -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. From 83a52f4d393ac1ffc3f951ad88e850c300e01ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 00:32:20 +0200 Subject: [PATCH 5/8] Capitalize parameter descriptions in draw package --- skimage/draw/_draw.pyx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/skimage/draw/_draw.pyx b/skimage/draw/_draw.pyx index fbd525fa..ca0c502a 100644 --- a/skimage/draw/_draw.pyx +++ b/skimage/draw/_draw.pyx @@ -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``. """ From fc7859471f6101aba604ef3ee06262cc97b27f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 00:35:16 +0200 Subject: [PATCH 6/8] Fix examples of exposure package --- skimage/exposure/exposure.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/skimage/exposure/exposure.py b/skimage/exposure/exposure.py index 5a722308..b0ef45cf 100644 --- a/skimage/exposure/exposure.py +++ b/skimage/exposure/exposure.py @@ -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) From db9af0dc2d59788c222ed7b4cd76d06cd1d21902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 08:25:04 +0200 Subject: [PATCH 7/8] Capitalize parameter descriptions in geometric transforms --- skimage/transform/_geometric.py | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/skimage/transform/_geometric.py b/skimage/transform/_geometric.py index cec591a9..c3b47a3b 100644 --- a/skimage/transform/_geometric.py +++ b/skimage/transform/_geometric.py @@ -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) From 00b3e90e42eb66824a110321509f85afe3e2f944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 26 Aug 2012 08:37:51 +0200 Subject: [PATCH 8/8] Fix description of polygon example script --- doc/examples/plot_polygon.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/examples/plot_polygon.py b/doc/examples/plot_polygon.py index 6eaef0bf..5b745fed 100644 --- a/doc/examples/plot_polygon.py +++ b/doc/examples/plot_polygon.py @@ -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