neulab/docprompting-conala huggingface dataset:
predict_xy(t, params=None) [source]
 
Predict x- and y-coordinates using the estimated model.  Parameters 
 
tarray 

Angles in circle in radians. Angles start to count from positive x-axis to positive y-axis in a right-handed system.  
params(5, ) array, optional 

Optional custom parameter set.    Returns 
 
xy(…, 2) array 

Predicted x- and y-coordinates.
residuals(data) [source]
 
Determine residuals of data to model. For each point the shortest distance to the ellipse is returned.  Parameters 
 
data(N, 2) array 

N points with (x, y) coordinates, respectively.    Returns 
 
residuals(N, ) array 

Residual for each data point.
skimage.measure.grid_points_in_poly(shape, verts) [source]
 
Test whether points on a specified grid are inside a polygon. For each (r, c) coordinate on a grid, i.e. (0, 0), (0, 1) etc., test whether that point lies inside a polygon.  Parameters 
 
shapetuple (M, N) 

Shape of the grid.  
verts(V, 2) array 

Specify the V vertices of the polygon, sorted either clockwise or anti-clockwise. The first point may (but does not need to be) duplicated.    Returns 
 
mask(M, N) ndarray of bool 

True where the grid falls inside the polygon.      See also  
points_in_poly
skimage.measure.inertia_tensor(image, mu=None) [source]
 
Compute the inertia tensor of the input image.  Parameters 
 
imagearray 

The input image.  
muarray, optional 

The pre-computed central moments of image. The inertia tensor computation requires the central moments of the image. If an application requires both the central moments and the inertia tensor (for example, skimage.measure.regionprops), then it is more efficient to pre-compute them and pass them to the inertia tensor call.    Returns 
 
Tarray, shape (image.ndim, image.ndim) 

The inertia tensor of the input image. \(T_{i, j}\) contains the covariance of image intensity along axes \(i\) and \(j\).     References  
1  
https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_tensor  
2  
Bernd Jähne. Spatio-Temporal Image Processing: Theory and Scientific Applications. (Chapter 8: Tensor Methods) Springer, 1993.
skimage.measure.inertia_tensor_eigvals(image, mu=None, T=None) [source]
 
Compute the eigenvalues of the inertia tensor of the image. The inertia tensor measures covariance of the image intensity along the image axes. (See inertia_tensor.) The relative magnitude of the eigenvalues of the tensor is thus a measure of the elongation of a (bright) object in the image.  Parameters 
 
imagearray 

The input image.  
muarray, optional 

The pre-computed central moments of image.  
Tarray, shape (image.ndim, image.ndim) 

The pre-computed inertia tensor. If T is given, mu and image are ignored.    Returns 
 
eigvalslist of float, length image.ndim 

The eigenvalues of the inertia tensor of image, in descending order.     Notes Computing the eigenvalues requires the inertia tensor of the input image. This is much faster if the central moments (mu) are provided, or, alternatively, one can provide the inertia tensor (T) directly.
skimage.measure.label(input, background=None, return_num=False, connectivity=None) [source]
 
Label connected regions of an integer array. Two pixels are connected when they are neighbors and have the same value. In 2D, they can be neighbors either in a 1- or 2-connected sense. The value refers to the maximum number of orthogonal hops to consider a pixel/voxel a neighbor: 1-connectivity     2-connectivity     diagonal connection close-up

     [ ]           [ ]  [ ]  [ ]             [ ]
      |               \  |  /                 |  <- hop 2
[ ]--[x]--[ ]      [ ]--[x]--[ ]        [x]--[ ]
      |               /  |  \             hop 1
     [ ]           [ ]  [ ]  [ ]
  Parameters 
 
inputndarray of dtype int 

Image to label.  
backgroundint, optional 

Consider all pixels with this value as background pixels, and label them as 0. By default, 0-valued pixels are considered as background pixels.  
return_numbool, optional 

Whether to return the number of assigned labels.  
connectivityint, optional 

Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor. Accepted values are ranging from 1 to input.ndim. If None, a full connectivity of input.ndim is used.    Returns 
 
labelsndarray of dtype int 

Labeled array, where all connected regions are assigned the same integer value.  
numint, optional 

Number of labels, which equals the maximum label index and is only returned if return_num is True.      See also  
regionprops


regionprops_table

  References  
1  
Christophe Fiorio and Jens Gustedt, “Two linear time Union-Find strategies for image processing”, Theoretical Computer Science 154 (1996), pp. 165-181.  
2  
Kensheng Wu, Ekow Otoo and Arie Shoshani, “Optimizing connected component labeling algorithms”, Paper LBNL-56864, 2005, Lawrence Berkeley National Laboratory (University of California), http://repositories.cdlib.org/lbnl/LBNL-56864   Examples >>> import numpy as np
>>> x = np.eye(3).astype(int)
>>> print(x)
[[1 0 0]
 [0 1 0]
 [0 0 1]]
>>> print(label(x, connectivity=1))
[[1 0 0]
 [0 2 0]
 [0 0 3]]
>>> print(label(x, connectivity=2))
[[1 0 0]
 [0 1 0]
 [0 0 1]]
>>> print(label(x, background=-1))
[[1 2 2]
 [2 1 2]
 [2 2 1]]
>>> x = np.array([[1, 0, 0],
...               [1, 1, 5],
...               [0, 0, 0]])
>>> print(label(x))
[[1 0 0]
 [1 1 2]
 [0 0 0]]
class skimage.measure.LineModelND [source]
 
Bases: skimage.measure.fit.BaseModel Total least squares estimator for N-dimensional lines. In contrast to ordinary least squares line estimation, this estimator minimizes the orthogonal distances of points to the estimated line. Lines are defined by a point (origin) and a unit vector (direction) according to the following vector equation: X = origin + lambda * direction
 Examples >>> x = np.linspace(1, 2, 25)
>>> y = 1.5 * x + 3
>>> lm = LineModelND()
>>> lm.estimate(np.stack([x, y], axis=-1))
True
>>> tuple(np.round(lm.params, 5))
(array([1.5 , 5.25]), array([0.5547 , 0.83205]))
>>> res = lm.residuals(np.stack([x, y], axis=-1))
>>> np.abs(np.round(res, 9))
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0.])
>>> np.round(lm.predict_y(x[:5]), 3)
array([4.5  , 4.562, 4.625, 4.688, 4.75 ])
>>> np.round(lm.predict_x(y[:5]), 3)
array([1.   , 1.042, 1.083, 1.125, 1.167])
  Attributes 
 
paramstuple 

Line model parameters in the following order origin, direction.      
__init__() [source]
 
Initialize self. See help(type(self)) for accurate signature. 
  
estimate(data) [source]
 
Estimate line model from data. This minimizes the sum of shortest (orthogonal) distances from the given data points to the estimated line.  Parameters 
 
data(N, dim) array 

N points in a space of dimensionality dim >= 2.    Returns 
 
successbool 

True, if model estimation succeeds.     
  
predict(x, axis=0, params=None) [source]
 
Predict intersection of the estimated line model with a hyperplane orthogonal to a given axis.  Parameters 
 
x(n, 1) array 

Coordinates along an axis.  
axisint 

Axis orthogonal to the hyperplane intersecting the line.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
data(n, m) array 

Predicted coordinates.    Raises 
 ValueError

If the line is parallel to the given axis.     
  
predict_x(y, params=None) [source]
 
Predict x-coordinates for 2D lines using the estimated model. Alias for: predict(y, axis=1)[:, 0]
  Parameters 
 
yarray 

y-coordinates.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
xarray 

Predicted x-coordinates.     
  
predict_y(x, params=None) [source]
 
Predict y-coordinates for 2D lines using the estimated model. Alias for: predict(x, axis=0)[:, 1]
  Parameters 
 
xarray 

x-coordinates.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
yarray 

Predicted y-coordinates.     
  
residuals(data, params=None) [source]
 
Determine residuals of data to model. For each point, the shortest (orthogonal) distance to the line is returned. It is obtained by projecting the data onto the line.  Parameters 
 
data(N, dim) array 

N points in a space of dimension dim.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
residuals(N, ) array 

Residual for each data point.
estimate(data) [source]
 
Estimate line model from data. This minimizes the sum of shortest (orthogonal) distances from the given data points to the estimated line.  Parameters 
 
data(N, dim) array 

N points in a space of dimensionality dim >= 2.    Returns 
 
successbool 

True, if model estimation succeeds.
predict(x, axis=0, params=None) [source]
 
Predict intersection of the estimated line model with a hyperplane orthogonal to a given axis.  Parameters 
 
x(n, 1) array 

Coordinates along an axis.  
axisint 

Axis orthogonal to the hyperplane intersecting the line.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
data(n, m) array 

Predicted coordinates.    Raises 
 ValueError

If the line is parallel to the given axis.
predict_x(y, params=None) [source]
 
Predict x-coordinates for 2D lines using the estimated model. Alias for: predict(y, axis=1)[:, 0]
  Parameters 
 
yarray 

y-coordinates.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
xarray 

Predicted x-coordinates.
predict_y(x, params=None) [source]
 
Predict y-coordinates for 2D lines using the estimated model. Alias for: predict(x, axis=0)[:, 1]
  Parameters 
 
xarray 

x-coordinates.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
yarray 

Predicted y-coordinates.
residuals(data, params=None) [source]
 
Determine residuals of data to model. For each point, the shortest (orthogonal) distance to the line is returned. It is obtained by projecting the data onto the line.  Parameters 
 
data(N, dim) array 

N points in a space of dimension dim.  
params(2, ) array, optional 

Optional custom parameter set in the form (origin, direction).    Returns 
 
residuals(N, ) array 

Residual for each data point.
skimage.measure.mesh_surface_area(verts, faces) [source]
 
Compute surface area, given vertices & triangular faces  Parameters 
 
verts(V, 3) array of floats 

Array containing (x, y, z) coordinates for V unique mesh vertices.  
faces(F, 3) array of ints 

List of length-3 lists of integers, referencing vertex coordinates as provided in verts    Returns 
 
areafloat 

Surface area of mesh. Units now [coordinate units] ** 2.      See also  
skimage.measure.marching_cubes


skimage.measure.marching_cubes_classic

  Notes The arguments expected by this function are the first two outputs from skimage.measure.marching_cubes. For unit correct output, ensure correct spacing was passed to skimage.measure.marching_cubes. This algorithm works properly only if the faces provided are all triangles.
skimage.measure.moments(image, order=3) [source]
 
Calculate all raw image moments up to a certain order.  The following properties can be calculated from raw image moments:

 Area as: M[0, 0]. Centroid as: {M[1, 0] / M[0, 0], M[0, 1] / M[0, 0]}.    Note that raw moments are neither translation, scale nor rotation invariant.  Parameters 
 
imagenD double or uint8 array 

Rasterized shape as image.  
orderint, optional 

Maximum order of moments. Default is 3.    Returns 
 
m(order + 1, order + 1) array 

Raw image moments.     References  
1  
Wilhelm Burger, Mark Burge. Principles of Digital Image Processing: Core Algorithms. Springer-Verlag, London, 2009.  
2  
B. Jähne. Digital Image Processing. Springer-Verlag, Berlin-Heidelberg, 6. edition, 2005.  
3  
T. H. Reiss. Recognizing Planar Objects Using Invariant Image Features, from Lecture notes in computer science, p. 676. Springer, Berlin, 1993.  
4  
https://en.wikipedia.org/wiki/Image_moment   Examples >>> image = np.zeros((20, 20), dtype=np.double)
>>> image[13:17, 13:17] = 1
>>> M = moments(image)
>>> centroid = (M[1, 0] / M[0, 0], M[0, 1] / M[0, 0])
>>> centroid
(14.5, 14.5)
skimage.measure.moments_central(image, center=None, order=3, **kwargs) [source]
 
Calculate all central image moments up to a certain order. The center coordinates (cr, cc) can be calculated from the raw moments as: {M[1, 0] / M[0, 0], M[0, 1] / M[0, 0]}. Note that central moments are translation invariant but not scale and rotation invariant.  Parameters 
 
imagenD double or uint8 array 

Rasterized shape as image.  
centertuple of float, optional 

Coordinates of the image centroid. This will be computed if it is not provided.  
orderint, optional 

The maximum order of moments computed.    Returns 
 
mu(order + 1, order + 1) array 

Central image moments.     References  
1  
Wilhelm Burger, Mark Burge. Principles of Digital Image Processing: Core Algorithms. Springer-Verlag, London, 2009.  
2  
B. Jähne. Digital Image Processing. Springer-Verlag, Berlin-Heidelberg, 6. edition, 2005.  
3  
T. H. Reiss. Recognizing Planar Objects Using Invariant Image Features, from Lecture notes in computer science, p. 676. Springer, Berlin, 1993.  
4  
https://en.wikipedia.org/wiki/Image_moment   Examples >>> image = np.zeros((20, 20), dtype=np.double)
>>> image[13:17, 13:17] = 1
>>> M = moments(image)
>>> centroid = (M[1, 0] / M[0, 0], M[0, 1] / M[0, 0])
>>> moments_central(image, centroid)
array([[16.,  0., 20.,  0.],
       [ 0.,  0.,  0.,  0.],
       [20.,  0., 25.,  0.],
       [ 0.,  0.,  0.,  0.]])
skimage.measure.moments_coords(coords, order=3) [source]
 
Calculate all raw image moments up to a certain order.  The following properties can be calculated from raw image moments:

 Area as: M[0, 0]. Centroid as: {M[1, 0] / M[0, 0], M[0, 1] / M[0, 0]}.    Note that raw moments are neither translation, scale nor rotation invariant.  Parameters 
 
coords(N, D) double or uint8 array 

Array of N points that describe an image of D dimensionality in Cartesian space.  
orderint, optional 

Maximum order of moments. Default is 3.    Returns 
 
M(order + 1, order + 1, …) array 

Raw image moments. (D dimensions)     References  
1  
Johannes Kilian. Simple Image Analysis By Moments. Durham University, version 0.2, Durham, 2001.   Examples >>> coords = np.array([[row, col]
...                    for row in range(13, 17)
...                    for col in range(14, 18)], dtype=np.double)
>>> M = moments_coords(coords)
>>> centroid = (M[1, 0] / M[0, 0], M[0, 1] / M[0, 0])
>>> centroid
(14.5, 15.5)
skimage.measure.moments_coords_central(coords, center=None, order=3) [source]
 
Calculate all central image moments up to a certain order.  The following properties can be calculated from raw image moments:

 Area as: M[0, 0]. Centroid as: {M[1, 0] / M[0, 0], M[0, 1] / M[0, 0]}.    Note that raw moments are neither translation, scale nor rotation invariant.  Parameters 
 
coords(N, D) double or uint8 array 

Array of N points that describe an image of D dimensionality in Cartesian space. A tuple of coordinates as returned by np.nonzero is also accepted as input.  
centertuple of float, optional 

Coordinates of the image centroid. This will be computed if it is not provided.  
orderint, optional 

Maximum order of moments. Default is 3.    Returns 
 
Mc(order + 1, order + 1, …) array 

Central image moments. (D dimensions)     References  
1  
Johannes Kilian. Simple Image Analysis By Moments. Durham University, version 0.2, Durham, 2001.   Examples >>> coords = np.array([[row, col]
...                    for row in range(13, 17)
...                    for col in range(14, 18)])
>>> moments_coords_central(coords)
array([[16.,  0., 20.,  0.],
       [ 0.,  0.,  0.,  0.],
       [20.,  0., 25.,  0.],
       [ 0.,  0.,  0.,  0.]])
 As seen above, for symmetric objects, odd-order moments (columns 1 and 3, rows 1 and 3) are zero when centered on the centroid, or center of mass, of the object (the default). If we break the symmetry by adding a new point, this no longer holds: >>> coords2 = np.concatenate((coords, [[17, 17]]), axis=0)
>>> np.round(moments_coords_central(coords2),
...          decimals=2)  
array([[17.  ,  0.  , 22.12, -2.49],
       [ 0.  ,  3.53,  1.73,  7.4 ],
       [25.88,  6.02, 36.63,  8.83],
       [ 4.15, 19.17, 14.8 , 39.6 ]])
 Image moments and central image moments are equivalent (by definition) when the center is (0, 0): >>> np.allclose(moments_coords(coords),
...             moments_coords_central(coords, (0, 0)))
True
skimage.measure.moments_hu(nu) [source]
 
Calculate Hu’s set of image moments (2D-only). Note that this set of moments is proofed to be translation, scale and rotation invariant.  Parameters 
 
nu(M, M) array 

Normalized central image moments, where M must be >= 4.    Returns 
 
nu(7,) array 

Hu’s set of image moments.     References  
1  
M. K. Hu, “Visual Pattern Recognition by Moment Invariants”, IRE Trans. Info. Theory, vol. IT-8, pp. 179-187, 1962  
2  
Wilhelm Burger, Mark Burge. Principles of Digital Image Processing: Core Algorithms. Springer-Verlag, London, 2009.  
3  
B. Jähne. Digital Image Processing. Springer-Verlag, Berlin-Heidelberg, 6. edition, 2005.  
4  
T. H. Reiss. Recognizing Planar Objects Using Invariant Image Features, from Lecture notes in computer science, p. 676. Springer, Berlin, 1993.  
5  
https://en.wikipedia.org/wiki/Image_moment   Examples >>> image = np.zeros((20, 20), dtype=np.double)
>>> image[13:17, 13:17] = 0.5
>>> image[10:12, 10:12] = 1
>>> mu = moments_central(image)
>>> nu = moments_normalized(mu)
>>> moments_hu(nu)
array([7.45370370e-01, 3.51165981e-01, 1.04049179e-01, 4.06442107e-02,
       2.64312299e-03, 2.40854582e-02, 4.33680869e-19])
skimage.measure.moments_normalized(mu, order=3) [source]
 
Calculate all normalized central image moments up to a certain order. Note that normalized central moments are translation and scale invariant but not rotation invariant.  Parameters 
 
mu(M,[ …,] M) array 

Central image moments, where M must be greater than or equal to order.  
orderint, optional 

Maximum order of moments. Default is 3.    Returns 
 
nu(order + 1,[ …,] order + 1) array 

Normalized central image moments.     References  
1  
Wilhelm Burger, Mark Burge. Principles of Digital Image Processing: Core Algorithms. Springer-Verlag, London, 2009.  
2  
B. Jähne. Digital Image Processing. Springer-Verlag, Berlin-Heidelberg, 6. edition, 2005.  
3  
T. H. Reiss. Recognizing Planar Objects Using Invariant Image Features, from Lecture notes in computer science, p. 676. Springer, Berlin, 1993.  
4  
https://en.wikipedia.org/wiki/Image_moment   Examples >>> image = np.zeros((20, 20), dtype=np.double)
>>> image[13:17, 13:17] = 1
>>> m = moments(image)
>>> centroid = (m[0, 1] / m[0, 0], m[1, 0] / m[0, 0])
>>> mu = moments_central(image, centroid)
>>> moments_normalized(mu)
array([[       nan,        nan, 0.078125  , 0.        ],
       [       nan, 0.        , 0.        , 0.        ],
       [0.078125  , 0.        , 0.00610352, 0.        ],
       [0.        , 0.        , 0.        , 0.        ]])
skimage.measure.perimeter(image, neighbourhood=4) [source]
 
Calculate total perimeter of all objects in binary image.  Parameters 
 
image(N, M) ndarray 

2D binary image.  
neighbourhood4 or 8, optional 

Neighborhood connectivity for border pixel determination. It is used to compute the contour. A higher neighbourhood widens the border on which the perimeter is computed.    Returns 
 
perimeterfloat 

Total perimeter of all objects in binary image.     References  
1  
K. Benkrid, D. Crookes. Design and FPGA Implementation of a Perimeter Estimator. The Queen’s University of Belfast. http://www.cs.qub.ac.uk/~d.crookes/webpubs/papers/perimeter.doc   Examples >>> from skimage import data, util
>>> from skimage.measure import label
>>> # coins image (binary)
>>> img_coins = data.coins() > 110
>>> # total perimeter of all objects in the image
>>> perimeter(img_coins, neighbourhood=4)  
7796.867...
>>> perimeter(img_coins, neighbourhood=8)  
8806.268...
skimage.measure.perimeter_crofton(image, directions=4) [source]
 
Calculate total Crofton perimeter of all objects in binary image.  Parameters 
 
image(N, M) ndarray 

2D image. If image is not binary, all values strictly greater than zero are considered as the object.  
directions2 or 4, optional 

Number of directions used to approximate the Crofton perimeter. By default, 4 is used: it should be more accurate than 2. Computation time is the same in both cases.    Returns 
 
perimeterfloat 

Total perimeter of all objects in binary image.     Notes This measure is based on Crofton formula [1], which is a measure from integral geometry. It is defined for general curve length evaluation via a double integral along all directions. In a discrete space, 2 or 4 directions give a quite good approximation, 4 being more accurate than 2 for more complex shapes. Similar to perimeter(), this function returns an approximation of the perimeter in continuous space. References  
1  
https://en.wikipedia.org/wiki/Crofton_formula  
2  
S. Rivollier. Analyse d’image geometrique et morphometrique par diagrammes de forme et voisinages adaptatifs generaux. PhD thesis, 2010. Ecole Nationale Superieure des Mines de Saint-Etienne. https://tel.archives-ouvertes.fr/tel-00560838   Examples >>> from skimage import data, util
>>> from skimage.measure import label
>>> # coins image (binary)
>>> img_coins = data.coins() > 110
>>> # total perimeter of all objects in the image
>>> perimeter_crofton(img_coins, directions=2)  
8144.578...
>>> perimeter_crofton(img_coins, directions=4)  
7837.077...
skimage.measure.points_in_poly(points, verts) [source]
 
Test whether points lie inside a polygon.  Parameters 
 
points(N, 2) array 

Input points, (x, y).  
verts(M, 2) array 

Vertices of the polygon, sorted either clockwise or anti-clockwise. The first point may (but does not need to be) duplicated.    Returns 
 
mask(N,) array of bool 

True if corresponding point is inside the polygon.      See also  
grid_points_in_poly