neulab/docprompting-conala huggingface dataset:
skimage.measure.profile_line(image, src, dst, linewidth=1, order=None, mode=None, cval=0.0, *, reduce_func=<function mean>) [source]
 
Return the intensity profile of an image measured along a scan line.  Parameters 
 
imagendarray, shape (M, N[, C]) 

The image, either grayscale (2D array) or multichannel (3D array, where the final axis contains the channel information).  
srcarray_like, shape (2, ) 

The coordinates of the start point of the scan line.  
dstarray_like, shape (2, ) 

The coordinates of the end point of the scan line. The destination point is included in the profile, in contrast to standard numpy indexing.  
linewidthint, optional 

Width of the scan, perpendicular to the line  
orderint in {0, 1, 2, 3, 4, 5}, optional 

The order of the spline interpolation, default is 0 if image.dtype is bool and 1 otherwise. The order has to be in the range 0-5. See skimage.transform.warp for detail.  
mode{‘constant’, ‘nearest’, ‘reflect’, ‘mirror’, ‘wrap’}, optional 

How to compute any values falling outside of the image.  
cvalfloat, optional 

If mode is ‘constant’, what constant value to use outside the image.  
reduce_funccallable, optional 

Function used to calculate the aggregation of pixel values perpendicular to the profile_line direction when linewidth > 1. If set to None the unreduced array will be returned.    Returns 
 
return_valuearray 

The intensity profile along the scan line. The length of the profile is the ceil of the computed length of the scan line.     Examples >>> x = np.array([[1, 1, 1, 2, 2, 2]])
>>> img = np.vstack([np.zeros_like(x), x, x, x, np.zeros_like(x)])
>>> img
array([[0, 0, 0, 0, 0, 0],
       [1, 1, 1, 2, 2, 2],
       [1, 1, 1, 2, 2, 2],
       [1, 1, 1, 2, 2, 2],
       [0, 0, 0, 0, 0, 0]])
>>> profile_line(img, (2, 1), (2, 4))
array([1., 1., 2., 2.])
>>> profile_line(img, (1, 0), (1, 6), cval=4)
array([1., 1., 1., 2., 2., 2., 4.])
 The destination point is included in the profile, in contrast to standard numpy indexing. For example: >>> profile_line(img, (1, 0), (1, 6))  # The final point is out of bounds
array([1., 1., 1., 2., 2., 2., 0.])
>>> profile_line(img, (1, 0), (1, 5))  # This accesses the full first row
array([1., 1., 1., 2., 2., 2.])
 For different reduce_func inputs: >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.mean)
array([0.66666667, 0.66666667, 0.66666667, 1.33333333])
>>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.max)
array([1, 1, 1, 2])
>>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sum)
array([2, 2, 2, 4])
 The unreduced array will be returned when reduce_func is None or when reduce_func acts on each pixel value individually. >>> profile_line(img, (1, 2), (4, 2), linewidth=3, order=0,
...     reduce_func=None)
array([[1, 1, 2],
       [1, 1, 2],
       [1, 1, 2],
       [0, 0, 0]])
>>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sqrt)
array([[1.        , 1.        , 0.        ],
       [1.        , 1.        , 0.        ],
       [1.        , 1.        , 0.        ],
       [1.41421356, 1.41421356, 0.        ]])
skimage.measure.shannon_entropy(image, base=2) [source]
 
Calculate the Shannon entropy of an image. The Shannon entropy is defined as S = -sum(pk * log(pk)), where pk are frequency/probability of pixels of value k.  Parameters 
 
image(N, M) ndarray 

Grayscale input image.  
basefloat, optional 

The logarithmic base to use.    Returns 
 
entropyfloat 
   Notes The returned value is measured in bits or shannon (Sh) for base=2, natural unit (nat) for base=np.e and hartley (Hart) for base=10. References  
1  
https://en.wikipedia.org/wiki/Entropy_(information_theory)  
2  
https://en.wiktionary.org/wiki/Shannon_entropy   Examples >>> from skimage import data
>>> from skimage.measure import shannon_entropy
>>> shannon_entropy(data.camera())
7.231695011055706
skimage.measure.subdivide_polygon(coords, degree=2, preserve_ends=False) [source]
 
Subdivision of polygonal curves using B-Splines. Note that the resulting curve is always within the convex hull of the original polygon. Circular polygons stay closed after subdivision.  Parameters 
 
coords(N, 2) array 

Coordinate array.  
degree{1, 2, 3, 4, 5, 6, 7}, optional 

Degree of B-Spline. Default is 2.  
preserve_endsbool, optional 

Preserve first and last coordinate of non-circular polygon. Default is False.    Returns 
 
coords(M, 2) array 

Subdivided coordinate array.     References  
1  
http://mrl.nyu.edu/publications/subdiv-course2000/coursenotes00.pdf
skimage.metrics.adapted_rand_error(image_true=None, image_test=None, *, table=None, ignore_labels=(0, )) [source]
 
Compute Adapted Rand error as defined by the SNEMI3D contest. [1]  Parameters 
 
image_truendarray of int 

Ground-truth label image, same shape as im_test.  
image_testndarray of int 

Test image.  
tablescipy.sparse array in crs format, optional 

A contingency table built with skimage.evaluate.contingency_table. If None, it will be computed on the fly.  
ignore_labelssequence of int, optional 

Labels to ignore. Any part of the true image labeled with any of these values will not be counted in the score.    Returns 
 
arefloat 

The adapted Rand error; equal to \(1 - \frac{2pr}{p + r}\), where p and r are the precision and recall described below.  
precfloat 

The adapted Rand precision: this is the number of pairs of pixels that have the same label in the test label image and in the true image, divided by the number in the test image.  
recfloat 

The adapted Rand recall: this is the number of pairs of pixels that have the same label in the test label image and in the true image, divided by the number in the true image.     Notes Pixels with label 0 in the true segmentation are ignored in the score. References  
1  
Arganda-Carreras I, Turaga SC, Berger DR, et al. (2015) Crowdsourcing the creation of image segmentation algorithms for connectomics. Front. Neuroanat. 9:142. DOI:10.3389/fnana.2015.00142
skimage.metrics.contingency_table(im_true, im_test, *, ignore_labels=None, normalize=False) [source]
 
Return the contingency table for all regions in matched segmentations.  Parameters 
 
im_truendarray of int 

Ground-truth label image, same shape as im_test.  
im_testndarray of int 

Test image.  
ignore_labelssequence of int, optional 

Labels to ignore. Any part of the true image labeled with any of these values will not be counted in the score.  
normalizebool 

Determines if the contingency table is normalized by pixel count.    Returns 
 
contscipy.sparse.csr_matrix 

A contingency table. cont[i, j] will equal the number of voxels labeled i in im_true and j in im_test.
skimage.metrics.hausdorff_distance(image0, image1) [source]
 
Calculate the Hausdorff distance between nonzero elements of given images. The Hausdorff distance [1] is the maximum distance between any point on image0 and its nearest point on image1, and vice-versa.  Parameters 
 
image0, image1ndarray 

Arrays where True represents a point that is included in a set of points. Both arrays must have the same shape.    Returns 
 
distancefloat 

The Hausdorff distance between coordinates of nonzero pixels in image0 and image1, using the Euclidian distance.     References  
1  
http://en.wikipedia.org/wiki/Hausdorff_distance   Examples >>> points_a = (3, 0)
>>> points_b = (6, 0)
>>> shape = (7, 1)
>>> image_a = np.zeros(shape, dtype=bool)
>>> image_b = np.zeros(shape, dtype=bool)
>>> image_a[points_a] = True
>>> image_b[points_b] = True
>>> hausdorff_distance(image_a, image_b)
3.0
skimage.metrics.mean_squared_error(image0, image1) [source]
 
Compute the mean-squared error between two images.  Parameters 
 
image0, image1ndarray 

Images. Any dimensionality, must have same shape.    Returns 
 
msefloat 

The mean-squared error (MSE) metric.     Notes  Changed in version 0.16: This function was renamed from skimage.measure.compare_mse to skimage.metrics.mean_squared_error.
skimage.metrics.normalized_root_mse(image_true, image_test, *, normalization='euclidean') [source]
 
Compute the normalized root mean-squared error (NRMSE) between two images.  Parameters 
 
image_truendarray 

Ground-truth image, same shape as im_test.  
image_testndarray 

Test image.  
normalization{‘euclidean’, ‘min-max’, ‘mean’}, optional 

Controls the normalization method to use in the denominator of the NRMSE. There is no standard method of normalization across the literature [1]. The methods available here are as follows:  
‘euclidean’ : normalize by the averaged Euclidean norm of im_true: NRMSE = RMSE * sqrt(N) / || im_true ||
 where || . || denotes the Frobenius norm and N = im_true.size. This result is equivalent to: NRMSE = || im_true - im_test || / || im_true ||.
  ‘min-max’ : normalize by the intensity range of im_true. ‘mean’ : normalize by the mean of im_true
     Returns 
 
nrmsefloat 

The NRMSE metric.     Notes  Changed in version 0.16: This function was renamed from skimage.measure.compare_nrmse to skimage.metrics.normalized_root_mse.  References  
1  
https://en.wikipedia.org/wiki/Root-mean-square_deviation
skimage.metrics.peak_signal_noise_ratio(image_true, image_test, *, data_range=None) [source]
 
Compute the peak signal to noise ratio (PSNR) for an image.  Parameters 
 
image_truendarray 

Ground-truth image, same shape as im_test.  
image_testndarray 

Test image.  
data_rangeint, optional 

The data range of the input image (distance between minimum and maximum possible values). By default, this is estimated from the image data-type.    Returns 
 
psnrfloat 

The PSNR metric.     Notes  Changed in version 0.16: This function was renamed from skimage.measure.compare_psnr to skimage.metrics.peak_signal_noise_ratio.  References  
1  
https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio
skimage.metrics.structural_similarity(im1, im2, *, win_size=None, gradient=False, data_range=None, multichannel=False, gaussian_weights=False, full=False, **kwargs) [source]
 
Compute the mean structural similarity index between two images.  Parameters 
 
im1, im2ndarray 

Images. Any dimensionality with same shape.  
win_sizeint or None, optional 

The side-length of the sliding window used in comparison. Must be an odd value. If gaussian_weights is True, this is ignored and the window size will depend on sigma.  
gradientbool, optional 

If True, also return the gradient with respect to im2.  
data_rangefloat, optional 

The data range of the input image (distance between minimum and maximum possible values). By default, this is estimated from the image data-type.  
multichannelbool, optional 

If True, treat the last dimension of the array as channels. Similarity calculations are done independently for each channel then averaged.  
gaussian_weightsbool, optional 

If True, each patch has its mean and variance spatially weighted by a normalized Gaussian kernel of width sigma=1.5.  
fullbool, optional 

If True, also return the full structural similarity image.    Returns 
 
mssimfloat 

The mean structural similarity index over the image.  
gradndarray 

The gradient of the structural similarity between im1 and im2 [2]. This is only returned if gradient is set to True.  
Sndarray 

The full SSIM image. This is only returned if full is set to True.    Other Parameters 
 
use_sample_covariancebool 

If True, normalize covariances by N-1 rather than, N where N is the number of pixels within the sliding window.  
K1float 

Algorithm parameter, K1 (small constant, see [1]).  
K2float 

Algorithm parameter, K2 (small constant, see [1]).  
sigmafloat 

Standard deviation for the Gaussian when gaussian_weights is True.     Notes To match the implementation of Wang et. al. [1], set gaussian_weights to True, sigma to 1.5, and use_sample_covariance to False.  Changed in version 0.16: This function was renamed from skimage.measure.compare_ssim to skimage.metrics.structural_similarity.  References  
1(1,2,3)  
Wang, Z., Bovik, A. C., Sheikh, H. R., & Simoncelli, E. P. (2004). Image quality assessment: From error visibility to structural similarity. IEEE Transactions on Image Processing, 13, 600-612. https://ece.uwaterloo.ca/~z70wang/publications/ssim.pdf, DOI:10.1109/TIP.2003.819861  
2  
Avanaki, A. N. (2009). Exact global histogram specification optimized for structural similarity. Optical Review, 16, 613-621. arXiv:0901.0065 DOI:10.1007/s10043-009-0119-z
skimage.metrics.variation_of_information(image0=None, image1=None, *, table=None, ignore_labels=()) [source]
 
Return symmetric conditional entropies associated with the VI. [1] The variation of information is defined as VI(X,Y) = H(X|Y) + H(Y|X). If X is the ground-truth segmentation, then H(X|Y) can be interpreted as the amount of under-segmentation and H(X|Y) as the amount of over-segmentation. In other words, a perfect over-segmentation will have H(X|Y)=0 and a perfect under-segmentation will have H(Y|X)=0.  Parameters 
 
image0, image1ndarray of int 

Label images / segmentations, must have same shape.  
tablescipy.sparse array in csr format, optional 

A contingency table built with skimage.evaluate.contingency_table. If None, it will be computed with skimage.evaluate.contingency_table. If given, the entropies will be computed from this table and any images will be ignored.  
ignore_labelssequence of int, optional 

Labels to ignore. Any part of the true image labeled with any of these values will not be counted in the score.    Returns 
 
vindarray of float, shape (2,) 

The conditional entropies of image1|image0 and image0|image1.     References  
1  
Marina Meilă (2007), Comparing clusterings—an information based distance, Journal of Multivariate Analysis, Volume 98, Issue 5, Pages 873-895, ISSN 0047-259X, DOI:10.1016/j.jmva.2006.11.013.
skimage.morphology.ball(radius, dtype=<class 'numpy.uint8'>) [source]
 
Generates a ball-shaped structuring element. This is the 3D equivalent of a disk. A pixel is within the neighborhood if the Euclidean distance between it and the origin is no greater than radius.  Parameters 
 
radiusint 

The radius of the ball-shaped structuring element.    Returns 
 
selemndarray 

The structuring element where elements of the neighborhood are 1 and 0 otherwise.    Other Parameters 
 
dtypedata-type 

The data type of the structuring element.
skimage.morphology.binary_closing(image, selem=None, out=None) [source]
 
Return fast binary morphological closing of an image. This function returns the same result as greyscale closing but performs faster for binary images. The morphological closing on an image is defined as a dilation followed by an erosion. Closing can remove small dark spots (i.e. “pepper”) and connect small bright cracks. This tends to “close” up (dark) gaps between (bright) features.  Parameters 
 
imagendarray 

Binary input image.  
selemndarray, optional 

The neighborhood expressed as a 2-D array of 1’s and 0’s. If None, use a cross-shaped structuring element (connectivity=1).  
outndarray of bool, optional 

The array to store the result of the morphology. If None, is passed, a new array will be allocated.    Returns 
 
closingndarray of bool 

The result of the morphological closing.
skimage.morphology.binary_dilation(image, selem=None, out=None) [source]
 
Return fast binary morphological dilation of an image. This function returns the same result as greyscale dilation but performs faster for binary images. Morphological dilation sets a pixel at (i,j) to the maximum over all pixels in the neighborhood centered at (i,j). Dilation enlarges bright regions and shrinks dark regions.  Parameters 
 
imagendarray 

Binary input image.  
selemndarray, optional 

The neighborhood expressed as a 2-D array of 1’s and 0’s. If None, use a cross-shaped structuring element (connectivity=1).  
outndarray of bool, optional 

The array to store the result of the morphology. If None is passed, a new array will be allocated.    Returns 
 
dilatedndarray of bool or uint 

The result of the morphological dilation with values in [False, True].
skimage.morphology.binary_erosion(image, selem=None, out=None) [source]
 
Return fast binary morphological erosion of an image. This function returns the same result as greyscale erosion but performs faster for binary images. Morphological erosion sets a pixel at (i,j) to the minimum over all pixels in the neighborhood centered at (i,j). Erosion shrinks bright regions and enlarges dark regions.  Parameters 
 
imagendarray 

Binary input image.  
selemndarray, optional 

The neighborhood expressed as a 2-D array of 1’s and 0’s. If None, use a cross-shaped structuring element (connectivity=1).  
outndarray of bool, optional 

The array to store the result of the morphology. If None is passed, a new array will be allocated.    Returns 
 
erodedndarray of bool or uint 

The result of the morphological erosion taking values in [False, True].
skimage.morphology.binary_opening(image, selem=None, out=None) [source]
 
Return fast binary morphological opening of an image. This function returns the same result as greyscale opening but performs faster for binary images. The morphological opening on an image is defined as an erosion followed by a dilation. Opening can remove small bright spots (i.e. “salt”) and connect small dark cracks. This tends to “open” up (dark) gaps between (bright) features.  Parameters 
 
imagendarray 

Binary input image.  
selemndarray, optional 

The neighborhood expressed as a 2-D array of 1’s and 0’s. If None, use a cross-shaped structuring element (connectivity=1).  
outndarray of bool, optional 

The array to store the result of the morphology. If None is passed, a new array will be allocated.    Returns 
 
openingndarray of bool 

The result of the morphological opening.
skimage.morphology.black_tophat(image, selem=None, out=None) [source]
 
Return black top hat of an image. The black top hat of an image is defined as its morphological closing minus the original image. This operation returns the dark spots of the image that are smaller than the structuring element. Note that dark spots in the original image are bright spots after the black top hat.  Parameters 
 
imagendarray 

Image array.  
selemndarray, optional 

The neighborhood expressed as a 2-D array of 1’s and 0’s. If None, use cross-shaped structuring element (connectivity=1).  
outndarray, optional 

The array to store the result of the morphology. If None is passed, a new array will be allocated.    Returns 
 
outarray, same shape and type as image 

The result of the morphological black top hat.      See also  
white_tophat

  References  
1  
https://en.wikipedia.org/wiki/Top-hat_transform   Examples >>> # Change dark peak to bright peak and subtract background
>>> import numpy as np
>>> from skimage.morphology import square
>>> dark_on_grey = np.array([[7, 6, 6, 6, 7],
...                          [6, 5, 4, 5, 6],
...                          [6, 4, 0, 4, 6],
...                          [6, 5, 4, 5, 6],
...                          [7, 6, 6, 6, 7]], dtype=np.uint8)
>>> black_tophat(dark_on_grey, square(3))
array([[0, 0, 0, 0, 0],
       [0, 0, 1, 0, 0],
       [0, 1, 5, 1, 0],
       [0, 0, 1, 0, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
skimage.morphology.closing(image, selem=None, out=None) [source]
 
Return greyscale morphological closing of an image. The morphological closing on an image is defined as a dilation followed by an erosion. Closing can remove small dark spots (i.e. “pepper”) and connect small bright cracks. This tends to “close” up (dark) gaps between (bright) features.  Parameters 
 
imagendarray 

Image array.  
selemndarray, optional 

The neighborhood expressed as an array of 1’s and 0’s. If None, use cross-shaped structuring element (connectivity=1).  
outndarray, optional 

The array to store the result of the morphology. If None, is passed, a new array will be allocated.    Returns 
 
closingarray, same shape and type as image 

The result of the morphological closing.     Examples >>> # Close a gap between two bright lines
>>> import numpy as np
>>> from skimage.morphology import square
>>> broken_line = np.array([[0, 0, 0, 0, 0],
...                         [0, 0, 0, 0, 0],
...                         [1, 1, 0, 1, 1],
...                         [0, 0, 0, 0, 0],
...                         [0, 0, 0, 0, 0]], dtype=np.uint8)
>>> closing(broken_line, square(3))
array([[0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0],
       [1, 1, 1, 1, 1],
       [0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0]], dtype=uint8)
skimage.morphology.convex_hull_image(image, offset_coordinates=True, tolerance=1e-10) [source]
 
Compute the convex hull image of a binary image. The convex hull is the set of pixels included in the smallest convex polygon that surround all white pixels in the input image.  Parameters 
 
imagearray 

Binary input image. This array is cast to bool before processing.  
offset_coordinatesbool, optional 

If True, a pixel at coordinate, e.g., (4, 7) will be represented by coordinates (3.5, 7), (4.5, 7), (4, 6.5), and (4, 7.5). This adds some “extent” to a pixel when computing the hull.  
tolerancefloat, optional 

Tolerance when determining whether a point is inside the hull. Due to numerical floating point errors, a tolerance of 0 can result in some points erroneously being classified as being outside the hull.    Returns 
 
hull(M, N) array of bool 

Binary image with pixels in convex hull set to True.     References  
1  
https://blogs.mathworks.com/steve/2011/10/04/binary-image-convex-hull-algorithm-notes/
skimage.morphology.convex_hull_object(image, *, connectivity=2) [source]
 
Compute the convex hull image of individual objects in a binary image. The convex hull is the set of pixels included in the smallest convex polygon that surround all white pixels in the input image.  Parameters 
 
image(M, N) ndarray 

Binary input image.  
connectivity{1, 2}, int, optional 

Determines the neighbors of each pixel. Adjacent elements within a squared distance of connectivity from pixel center are considered neighbors.: 1-connectivity      2-connectivity
      [ ]           [ ]  [ ]  [ ]
       |               \  |  /
 [ ]--[x]--[ ]      [ ]--[x]--[ ]
       |               /  |  \
      [ ]           [ ]  [ ]  [ ]
    Returns 
 
hullndarray of bool 

Binary image with pixels inside convex hull set to True.     Notes This function uses skimage.morphology.label to define unique objects, finds the convex hull of each using convex_hull_image, and combines these regions with logical OR. Be aware the convex hulls of unconnected objects may overlap in the result. If this is suspected, consider using convex_hull_image separately on each object or adjust connectivity.
skimage.morphology.cube(width, dtype=<class 'numpy.uint8'>) [source]
 
Generates a cube-shaped structuring element. This is the 3D equivalent of a square. Every pixel along the perimeter has a chessboard distance no greater than radius (radius=floor(width/2)) pixels.  Parameters 
 
widthint 

The width, height and depth of the cube.    Returns 
 
selemndarray 

A structuring element consisting only of ones, i.e. every pixel belongs to the neighborhood.    Other Parameters 
 
dtypedata-type 

The data type of the structuring element.