neulab/docprompting-conala huggingface dataset:
skimage.restoration.unwrap_phase(image, wrap_around=False, seed=None) [source]
 
Recover the original from a wrapped phase image. From an image wrapped to lie in the interval [-pi, pi), recover the original, unwrapped image.  Parameters 
 
image1D, 2D or 3D ndarray of floats, optionally a masked array 

The values should be in the range [-pi, pi). If a masked array is provided, the masked entries will not be changed, and their values will not be used to guide the unwrapping of neighboring, unmasked values. Masked 1D arrays are not allowed, and will raise a ValueError.  
wrap_aroundbool or sequence of bool, optional 

When an element of the sequence is True, the unwrapping process will regard the edges along the corresponding axis of the image to be connected and use this connectivity to guide the phase unwrapping process. If only a single boolean is given, it will apply to all axes. Wrap around is not supported for 1D arrays.  
seedint, optional 

Unwrapping 2D or 3D images uses random initialization. This sets the seed of the PRNG to achieve deterministic behavior.    Returns 
 
image_unwrappedarray_like, double 

Unwrapped image of the same shape as the input. If the input image was a masked array, the mask will be preserved.    Raises 
 ValueError

If called with a masked 1D array or called with a 1D array and wrap_around=True.     References  
1  
Miguel Arevallilo Herraez, David R. Burton, Michael J. Lalor, and Munther A. Gdeisat, “Fast two-dimensional phase-unwrapping algorithm based on sorting by reliability following a noncontinuous path”, Journal Applied Optics, Vol. 41, No. 35 (2002) 7437,  
2  
Abdul-Rahman, H., Gdeisat, M., Burton, D., & Lalor, M., “Fast three-dimensional phase-unwrapping algorithm based on sorting by reliability following a non-continuous path. In W. Osten, C. Gorecki, & E. L. Novak (Eds.), Optical Metrology (2005) 32–40, International Society for Optics and Photonics.   Examples >>> c0, c1 = np.ogrid[-1:1:128j, -1:1:128j]
>>> image = 12 * np.pi * np.exp(-(c0**2 + c1**2))
>>> image_wrapped = np.angle(np.exp(1j * image))
>>> image_unwrapped = unwrap_phase(image_wrapped)
>>> np.std(image_unwrapped - image) < 1e-6   # A constant offset is normal
True
skimage.segmentation.active_contour(image, snake, alpha=0.01, beta=0.1, w_line=0, w_edge=1, gamma=0.01, max_px_move=1.0, max_iterations=2500, convergence=0.1, *, boundary_condition='periodic', coordinates='rc') [source]
 
Active contour model. Active contours by fitting snakes to features of images. Supports single and multichannel 2D images. Snakes can be periodic (for segmentation) or have fixed and/or free ends. The output snake has the same length as the input boundary. As the number of points is constant, make sure that the initial snake has enough points to capture the details of the final contour.  Parameters 
 
image(N, M) or (N, M, 3) ndarray 

Input image.  
snake(N, 2) ndarray 

Initial snake coordinates. For periodic boundary conditions, endpoints must not be duplicated.  
alphafloat, optional 

Snake length shape parameter. Higher values makes snake contract faster.  
betafloat, optional 

Snake smoothness shape parameter. Higher values makes snake smoother.  
w_linefloat, optional 

Controls attraction to brightness. Use negative values to attract toward dark regions.  
w_edgefloat, optional 

Controls attraction to edges. Use negative values to repel snake from edges.  
gammafloat, optional 

Explicit time stepping parameter.  
max_px_movefloat, optional 

Maximum pixel distance to move per iteration.  
max_iterationsint, optional 

Maximum iterations to optimize snake shape.  
convergencefloat, optional 

Convergence criteria.  
boundary_conditionstring, optional 

Boundary conditions for the contour. Can be one of ‘periodic’, ‘free’, ‘fixed’, ‘free-fixed’, or ‘fixed-free’. ‘periodic’ attaches the two ends of the snake, ‘fixed’ holds the end-points in place, and ‘free’ allows free movement of the ends. ‘fixed’ and ‘free’ can be combined by parsing ‘fixed-free’, ‘free-fixed’. Parsing ‘fixed-fixed’ or ‘free-free’ yields same behaviour as ‘fixed’ and ‘free’, respectively.  
coordinates{‘rc’}, optional 

This option remains for compatibility purpose only and has no effect. It was introduced in 0.16 with the 'xy' option, but since 0.18, only the 'rc' option is valid. Coordinates must be set in a row-column format.    Returns 
 
snake(N, 2) ndarray 

Optimised snake, same shape as input parameter.     References  
1  
Kass, M.; Witkin, A.; Terzopoulos, D. “Snakes: Active contour models”. International Journal of Computer Vision 1 (4): 321 (1988). DOI:10.1007/BF00133570   Examples >>> from skimage.draw import circle_perimeter
>>> from skimage.filters import gaussian
 Create and smooth image: >>> img = np.zeros((100, 100))
>>> rr, cc = circle_perimeter(35, 45, 25)
>>> img[rr, cc] = 1
>>> img = gaussian(img, 2)
 Initialize spline: >>> s = np.linspace(0, 2*np.pi, 100)
>>> init = 50 * np.array([np.sin(s), np.cos(s)]).T + 50
 Fit spline to image: >>> snake = active_contour(img, init, w_edge=0, w_line=1, coordinates='rc')  
>>> dist = np.sqrt((45-snake[:, 0])**2 + (35-snake[:, 1])**2)  
>>> int(np.mean(dist))  
25
skimage.segmentation.checkerboard_level_set(image_shape, square_size=5) [source]
 
Create a checkerboard level set with binary values.  Parameters 
 
image_shapetuple of positive integers 

Shape of the image.  
square_sizeint, optional 

Size of the squares of the checkerboard. It defaults to 5.    Returns 
 
outarray with shape image_shape 

Binary level set of the checkerboard.      See also  
circle_level_set
skimage.segmentation.circle_level_set(image_shape, center=None, radius=None) [source]
 
Create a circle level set with binary values.  Parameters 
 
image_shapetuple of positive integers 

Shape of the image  
centertuple of positive integers, optional 

Coordinates of the center of the circle given in (row, column). If not given, it defaults to the center of the image.  
radiusfloat, optional 

Radius of the circle. If not given, it is set to the 75% of the smallest image dimension.    Returns 
 
outarray with shape image_shape 

Binary level set of the circle with the given radius and center.    Warns 
 Deprecated:

 New in version 0.17: This function is deprecated and will be removed in scikit-image 0.19. Please use the function named disk_level_set instead.       See also  
checkerboard_level_set
skimage.segmentation.clear_border(labels, buffer_size=0, bgval=0, in_place=False, mask=None) [source]
 
Clear objects connected to the label image border.  Parameters 
 
labels(M[, N[, …, P]]) array of int or bool 

Imaging data labels.  
buffer_sizeint, optional 

The width of the border examined. By default, only objects that touch the outside of the image are removed.  
bgvalfloat or int, optional 

Cleared objects are set to this value.  
in_placebool, optional 

Whether or not to manipulate the labels array in-place.  
maskndarray of bool, same shape as image, optional. 

Image data mask. Objects in labels image overlapping with False pixels of mask will be removed. If defined, the argument buffer_size will be ignored.    Returns 
 
out(M[, N[, …, P]]) array 

Imaging data labels with cleared borders     Examples >>> import numpy as np
>>> from skimage.segmentation import clear_border
>>> labels = np.array([[0, 0, 0, 0, 0, 0, 0, 1, 0],
...                    [1, 1, 0, 0, 1, 0, 0, 1, 0],
...                    [1, 1, 0, 1, 0, 1, 0, 0, 0],
...                    [0, 0, 0, 1, 1, 1, 1, 0, 0],
...                    [0, 1, 1, 1, 1, 1, 1, 1, 0],
...                    [0, 0, 0, 0, 0, 0, 0, 0, 0]])
>>> clear_border(labels)
array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 1, 0, 0, 0, 0],
       [0, 0, 0, 1, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 0, 0],
       [0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0]])
>>> mask = np.array([[0, 0, 1, 1, 1, 1, 1, 1, 1],
...                  [0, 0, 1, 1, 1, 1, 1, 1, 1],
...                  [1, 1, 1, 1, 1, 1, 1, 1, 1],
...                  [1, 1, 1, 1, 1, 1, 1, 1, 1],
...                  [1, 1, 1, 1, 1, 1, 1, 1, 1],
...                  [1, 1, 1, 1, 1, 1, 1, 1, 1]]).astype(bool)
>>> clear_border(labels, mask=mask)
array([[0, 0, 0, 0, 0, 0, 0, 1, 0],
       [0, 0, 0, 0, 1, 0, 0, 1, 0],
       [0, 0, 0, 1, 0, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 0, 0],
       [0, 1, 1, 1, 1, 1, 1, 1, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0]])
skimage.segmentation.disk_level_set(image_shape, *, center=None, radius=None) [source]
 
Create a disk level set with binary values.  Parameters 
 
image_shapetuple of positive integers 

Shape of the image  
centertuple of positive integers, optional 

Coordinates of the center of the disk given in (row, column). If not given, it defaults to the center of the image.  
radiusfloat, optional 

Radius of the disk. If not given, it is set to the 75% of the smallest image dimension.    Returns 
 
outarray with shape image_shape 

Binary level set of the disk with the given radius and center.      See also  
checkerboard_level_set
skimage.segmentation.expand_labels(label_image, distance=1) [source]
 
Expand labels in label image by distance pixels without overlapping. Given a label image, expand_labels grows label regions (connected components) outwards by up to distance pixels without overflowing into neighboring regions. More specifically, each background pixel that is within Euclidean distance of <= distance pixels of a connected component is assigned the label of that connected component. Where multiple connected components are within distance pixels of a background pixel, the label value of the closest connected component will be assigned (see Notes for the case of multiple labels at equal distance).  Parameters 
 
label_imagendarray of dtype int 

label image  
distancefloat 

Euclidean distance in pixels by which to grow the labels. Default is one.    Returns 
 
enlarged_labelsndarray of dtype int 

Labeled array, where all connected regions have been enlarged      See also  
skimage.measure.label(), skimage.segmentation.watershed(), skimage.morphology.dilation()

  Notes Where labels are spaced more than distance pixels are apart, this is equivalent to a morphological dilation with a disc or hyperball of radius distance. However, in contrast to a morphological dilation, expand_labels will not expand a label region into a neighboring region. This implementation of expand_labels is derived from CellProfiler [1], where it is known as module “IdentifySecondaryObjects (Distance-N)” [2]. There is an important edge case when a pixel has the same distance to multiple regions, as it is not defined which region expands into that space. Here, the exact behavior depends on the upstream implementation of scipy.ndimage.distance_transform_edt. References  
1  
https://cellprofiler.org  
2  
https://github.com/CellProfiler/CellProfiler/blob/082930ea95add7b72243a4fa3d39ae5145995e9c/cellprofiler/modules/identifysecondaryobjects.py#L559   Examples >>> labels = np.array([0, 1, 0, 0, 0, 0, 2])
>>> expand_labels(labels, distance=1)
array([1, 1, 1, 0, 0, 2, 2])
 Labels will not overwrite each other: >>> expand_labels(labels, distance=3)
array([1, 1, 1, 1, 2, 2, 2])
 In case of ties, behavior is undefined, but currently resolves to the label closest to (0,) * ndim in lexicographical order. >>> labels_tied = np.array([0, 1, 0, 2, 0])
>>> expand_labels(labels_tied, 1)
array([1, 1, 1, 2, 2])
>>> labels2d = np.array(
...     [[0, 1, 0, 0],
...      [2, 0, 0, 0],
...      [0, 3, 0, 0]]
... )
>>> expand_labels(labels2d, 1)
array([[2, 1, 1, 0],
       [2, 2, 0, 0],
       [2, 3, 3, 0]])
skimage.segmentation.felzenszwalb(image, scale=1, sigma=0.8, min_size=20, multichannel=True) [source]
 
Computes Felsenszwalb’s efficient graph based image segmentation. Produces an oversegmentation of a multichannel (i.e. RGB) image using a fast, minimum spanning tree based clustering on the image grid. The parameter scale sets an observation level. Higher scale means less and larger segments. sigma is the diameter of a Gaussian kernel, used for smoothing the image prior to segmentation. The number of produced segments as well as their size can only be controlled indirectly through scale. Segment size within an image can vary greatly depending on local contrast. For RGB images, the algorithm uses the euclidean distance between pixels in color space.  Parameters 
 
image(width, height, 3) or (width, height) ndarray 

Input image.  
scalefloat 

Free parameter. Higher means larger clusters.  
sigmafloat 

Width (standard deviation) of Gaussian kernel used in preprocessing.  
min_sizeint 

Minimum component size. Enforced using postprocessing.  
multichannelbool, optional (default: True) 

Whether the last axis of the image is to be interpreted as multiple channels. A value of False, for a 3D image, is not currently supported.    Returns 
 
segment_mask(width, height) ndarray 

Integer mask indicating segment labels.     Notes The k parameter used in the original paper renamed to scale here. References  
1  
Efficient graph-based image segmentation, Felzenszwalb, P.F. and Huttenlocher, D.P. International Journal of Computer Vision, 2004   Examples >>> from skimage.segmentation import felzenszwalb
>>> from skimage.data import coffee
>>> img = coffee()
>>> segments = felzenszwalb(img, scale=3.0, sigma=0.95, min_size=5)
skimage.segmentation.flood(image, seed_point, *, selem=None, connectivity=None, tolerance=None) [source]
 
Mask corresponding to a flood fill. Starting at a specific seed_point, connected points equal or within tolerance of the seed value are found.  Parameters 
 
imagendarray 

An n-dimensional array.  
seed_pointtuple or int 

The point in image used as the starting point for the flood fill. If the image is 1D, this point may be given as an integer.  
selemndarray, optional 

A structuring element used to determine the neighborhood of each evaluated pixel. It must contain only 1’s and 0’s, have the same number of dimensions as image. If not given, all adjacent pixels are considered as part of the neighborhood (fully connected).  
connectivityint, optional 

A number used to determine the neighborhood of each evaluated pixel. Adjacent pixels whose squared distance from the center is larger or equal to connectivity are considered neighbors. Ignored if selem is not None.  
tolerancefloat or int, optional 

If None (default), adjacent values must be strictly equal to the initial value of image at seed_point. This is fastest. If a value is given, a comparison will be done at every point and if within tolerance of the initial value will also be filled (inclusive).    Returns 
 
maskndarray 

A Boolean array with the same shape as image is returned, with True values for areas connected to and equal (or within tolerance of) the seed point. All other values are False.     Notes The conceptual analogy of this operation is the ‘paint bucket’ tool in many raster graphics programs. This function returns just the mask representing the fill. If indices are desired rather than masks for memory reasons, the user can simply run numpy.nonzero on the result, save the indices, and discard this mask. Examples >>> from skimage.morphology import flood
>>> image = np.zeros((4, 7), dtype=int)
>>> image[1:3, 1:3] = 1
>>> image[3, 0] = 1
>>> image[1:3, 4:6] = 2
>>> image[3, 6] = 3
>>> image
array([[0, 0, 0, 0, 0, 0, 0],
       [0, 1, 1, 0, 2, 2, 0],
       [0, 1, 1, 0, 2, 2, 0],
       [1, 0, 0, 0, 0, 0, 3]])
 Fill connected ones with 5, with full connectivity (diagonals included): >>> mask = flood(image, (1, 1))
>>> image_flooded = image.copy()
>>> image_flooded[mask] = 5
>>> image_flooded
array([[0, 0, 0, 0, 0, 0, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [5, 0, 0, 0, 0, 0, 3]])
 Fill connected ones with 5, excluding diagonal points (connectivity 1): >>> mask = flood(image, (1, 1), connectivity=1)
>>> image_flooded = image.copy()
>>> image_flooded[mask] = 5
>>> image_flooded
array([[0, 0, 0, 0, 0, 0, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [1, 0, 0, 0, 0, 0, 3]])
 Fill with a tolerance: >>> mask = flood(image, (0, 0), tolerance=1)
>>> image_flooded = image.copy()
>>> image_flooded[mask] = 5
>>> image_flooded
array([[5, 5, 5, 5, 5, 5, 5],
       [5, 5, 5, 5, 2, 2, 5],
       [5, 5, 5, 5, 2, 2, 5],
       [5, 5, 5, 5, 5, 5, 3]])
skimage.segmentation.flood_fill(image, seed_point, new_value, *, selem=None, connectivity=None, tolerance=None, in_place=False, inplace=None) [source]
 
Perform flood filling on an image. Starting at a specific seed_point, connected points equal or within tolerance of the seed value are found, then set to new_value.  Parameters 
 
imagendarray 

An n-dimensional array.  
seed_pointtuple or int 

The point in image used as the starting point for the flood fill. If the image is 1D, this point may be given as an integer.  
new_valueimage type 

New value to set the entire fill. This must be chosen in agreement with the dtype of image.  
selemndarray, optional 

A structuring element used to determine the neighborhood of each evaluated pixel. It must contain only 1’s and 0’s, have the same number of dimensions as image. If not given, all adjacent pixels are considered as part of the neighborhood (fully connected).  
connectivityint, optional 

A number used to determine the neighborhood of each evaluated pixel. Adjacent pixels whose squared distance from the center is less than or equal to connectivity are considered neighbors. Ignored if selem is not None.  
tolerancefloat or int, optional 

If None (default), adjacent values must be strictly equal to the value of image at seed_point to be filled. This is fastest. If a tolerance is provided, adjacent points with values within plus or minus tolerance from the seed point are filled (inclusive).  
in_placebool, optional 

If True, flood filling is applied to image in place. If False, the flood filled result is returned without modifying the input image (default).  
inplacebool, optional 

This parameter is deprecated and will be removed in version 0.19.0 in favor of in_place. If True, flood filling is applied to image inplace. If False, the flood filled result is returned without modifying the input image (default).    Returns 
 
filledndarray 

An array with the same shape as image is returned, with values in areas connected to and equal (or within tolerance of) the seed point replaced with new_value.     Notes The conceptual analogy of this operation is the ‘paint bucket’ tool in many raster graphics programs. Examples >>> from skimage.morphology import flood_fill
>>> image = np.zeros((4, 7), dtype=int)
>>> image[1:3, 1:3] = 1
>>> image[3, 0] = 1
>>> image[1:3, 4:6] = 2
>>> image[3, 6] = 3
>>> image
array([[0, 0, 0, 0, 0, 0, 0],
       [0, 1, 1, 0, 2, 2, 0],
       [0, 1, 1, 0, 2, 2, 0],
       [1, 0, 0, 0, 0, 0, 3]])
 Fill connected ones with 5, with full connectivity (diagonals included): >>> flood_fill(image, (1, 1), 5)
array([[0, 0, 0, 0, 0, 0, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [5, 0, 0, 0, 0, 0, 3]])
 Fill connected ones with 5, excluding diagonal points (connectivity 1): >>> flood_fill(image, (1, 1), 5, connectivity=1)
array([[0, 0, 0, 0, 0, 0, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [0, 5, 5, 0, 2, 2, 0],
       [1, 0, 0, 0, 0, 0, 3]])
 Fill with a tolerance: >>> flood_fill(image, (0, 0), 5, tolerance=1)
array([[5, 5, 5, 5, 5, 5, 5],
       [5, 5, 5, 5, 2, 2, 5],
       [5, 5, 5, 5, 2, 2, 5],
       [5, 5, 5, 5, 5, 5, 3]])
skimage.segmentation.inverse_gaussian_gradient(image, alpha=100.0, sigma=5.0) [source]
 
Inverse of gradient magnitude. Compute the magnitude of the gradients in the image and then inverts the result in the range [0, 1]. Flat areas are assigned values close to 1, while areas close to borders are assigned values close to 0. This function or a similar one defined by the user should be applied over the image as a preprocessing step before calling morphological_geodesic_active_contour.  Parameters 
 
image(M, N) or (L, M, N) array 

Grayscale image or volume.  
alphafloat, optional 

Controls the steepness of the inversion. A larger value will make the transition between the flat areas and border areas steeper in the resulting array.  
sigmafloat, optional 

Standard deviation of the Gaussian filter applied over the image.    Returns 
 
gimage(M, N) or (L, M, N) array 

Preprocessed image (or volume) suitable for morphological_geodesic_active_contour.
skimage.segmentation.join_segmentations(s1, s2) [source]
 
Return the join of the two input segmentations. The join J of S1 and S2 is defined as the segmentation in which two voxels are in the same segment if and only if they are in the same segment in both S1 and S2.  Parameters 
 
s1, s2numpy arrays 

s1 and s2 are label fields of the same shape.    Returns 
 
jnumpy array 

The join segmentation of s1 and s2.     Examples >>> from skimage.segmentation import join_segmentations
>>> s1 = np.array([[0, 0, 1, 1],
...                [0, 2, 1, 1],
...                [2, 2, 2, 1]])
>>> s2 = np.array([[0, 1, 1, 0],
...                [0, 1, 1, 0],
...                [0, 1, 1, 1]])
>>> join_segmentations(s1, s2)
array([[0, 1, 3, 2],
       [0, 5, 3, 2],
       [4, 5, 5, 3]])
skimage.segmentation.mark_boundaries(image, label_img, color=(1, 1, 0), outline_color=None, mode='outer', background_label=0) [source]
 
Return image with boundaries between labeled regions highlighted.  Parameters 
 
image(M, N[, 3]) array 

Grayscale or RGB image.  
label_img(M, N) array of int 

Label array where regions are marked by different integer values.  
colorlength-3 sequence, optional 

RGB color of boundaries in the output image.  
outline_colorlength-3 sequence, optional 

RGB color surrounding boundaries in the output image. If None, no outline is drawn.  
modestring in {‘thick’, ‘inner’, ‘outer’, ‘subpixel’}, optional 

The mode for finding boundaries.  
background_labelint, optional 

Which label to consider background (this is only useful for modes inner and outer).    Returns 
 
marked(M, N, 3) array of float 

An image in which the boundaries between labels are superimposed on the original image.      See also  
find_boundaries