neulab/docprompting-conala huggingface dataset:
skimage.img_as_bool(image, force_copy=False) [source]
 
Convert an image to boolean format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of bool (bool_) 

Output image.     Notes The upper half of the input dtype’s positive range is True, and the lower half is False. All negative values (if present) are False.
skimage.img_as_float(image, force_copy=False) [source]
 
Convert an image to floating point format. This function is similar to img_as_float64, but will not convert lower-precision floating point arrays to float64.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of float 

Output image.     Notes The range of a floating point image is [0.0, 1.0] or [-1.0, 1.0] when converting from unsigned or signed datatypes, respectively. If the input image has a float type, intensity values are not modified and can be outside the ranges [0.0, 1.0] or [-1.0, 1.0].
skimage.img_as_float32(image, force_copy=False) [source]
 
Convert an image to single-precision (32-bit) floating point format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of float32 

Output image.     Notes The range of a floating point image is [0.0, 1.0] or [-1.0, 1.0] when converting from unsigned or signed datatypes, respectively. If the input image has a float type, intensity values are not modified and can be outside the ranges [0.0, 1.0] or [-1.0, 1.0].
skimage.img_as_float64(image, force_copy=False) [source]
 
Convert an image to double-precision (64-bit) floating point format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of float64 

Output image.     Notes The range of a floating point image is [0.0, 1.0] or [-1.0, 1.0] when converting from unsigned or signed datatypes, respectively. If the input image has a float type, intensity values are not modified and can be outside the ranges [0.0, 1.0] or [-1.0, 1.0].
skimage.img_as_int(image, force_copy=False) [source]
 
Convert an image to 16-bit signed integer format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of int16 

Output image.     Notes The values are scaled between -32768 and 32767. If the input data-type is positive-only (e.g., uint8), then the output image will still only have positive values.
skimage.img_as_ubyte(image, force_copy=False) [source]
 
Convert an image to 8-bit unsigned integer format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of ubyte (uint8) 

Output image.     Notes Negative input values will be clipped. Positive values are scaled between 0 and 255.
skimage.img_as_uint(image, force_copy=False) [source]
 
Convert an image to 16-bit unsigned integer format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of uint16 

Output image.     Notes Negative input values will be clipped. Positive values are scaled between 0 and 65535.
skimage.io.call_plugin(kind, *args, **kwargs) [source]
 
Find the appropriate plugin of ‘kind’ and execute it.  Parameters 
 
kind{‘imshow’, ‘imsave’, ‘imread’, ‘imread_collection’} 

Function to look up.  
pluginstr, optional 

Plugin to load. Defaults to None, in which case the first matching plugin is used.  
*args, **kwargsarguments and keyword arguments 

Passed to the plugin function.
skimage.io.concatenate_images(ic) [source]
 
Concatenate all images in the image collection into an array.  Parameters 
 
ican iterable of images 

The images to be concatenated.    Returns 
 
array_catndarray 

An array having one more dimension than the images in ic.    Raises 
 ValueError

If images in ic don’t have identical shapes.      See also  
ImageCollection.concatenate, MultiImage.concatenate 
  Notes concatenate_images receives any iterable object containing images, including ImageCollection and MultiImage, and returns a NumPy array.
skimage.io.find_available_plugins(loaded=False) [source]
 
List available plugins.  Parameters 
 
loadedbool 

If True, show only those plugins currently loaded. By default, all plugins are shown.    Returns 
 
pdict 

Dictionary with plugin names as keys and exposed functions as values.
class skimage.io.ImageCollection(load_pattern, conserve_memory=True, load_func=None, **load_func_kwargs) [source]
 
Bases: object Load and manage a collection of image files.  Parameters 
 
load_patternstr or list of str 

Pattern string or list of strings to load. The filename path can be absolute or relative.  
conserve_memorybool, optional 

If True, ImageCollection does not keep more than one in memory at a specific time. Otherwise, images will be cached once they are loaded.    Other Parameters 
 
load_funccallable 

imread by default. See notes below.     Notes Note that files are always returned in alphanumerical order. Also note that slicing returns a new ImageCollection, not a view into the data. ImageCollection can be modified to load images from an arbitrary source by specifying a combination of load_pattern and load_func. For an ImageCollection ic, ic[5] uses load_func(load_pattern[5]) to load the image. Imagine, for example, an ImageCollection that loads every third frame from a video file: video_file = 'no_time_for_that_tiny.gif'

def vidread_step(f, step):
    vid = imageio.get_reader(f)
    seq = [v for v in vid.iter_data()]
    return seq[::step]

ic = ImageCollection(video_file, load_func=vidread_step, step=3)

ic  # is an ImageCollection object of length 1 because there is 1 file

x = ic[0]  # calls vidread_step(video_file, step=3)
x[5]  # is the sixth element of a list of length 8 (24 / 3)
 Another use of load_func would be to convert all images to uint8: def imread_convert(f):
    return imread(f).astype(np.uint8)

ic = ImageCollection('/tmp/*.png', load_func=imread_convert)
 Examples >>> import skimage.io as io
>>> from skimage import data_dir
 >>> coll = io.ImageCollection(data_dir + '/chess*.png')
>>> len(coll)
2
>>> coll[0].shape
(200, 200)
 >>> ic = io.ImageCollection(['/tmp/work/*.png', '/tmp/other/*.jpg'])
  Attributes 
 
fileslist of str 

If a pattern string is given for load_pattern, this attribute stores the expanded file list. Otherwise, this is equal to load_pattern.      
__init__(load_pattern, conserve_memory=True, load_func=None, **load_func_kwargs) [source]
 
Load and manage a collection of images. 
  
concatenate() [source]
 
Concatenate all images in the collection into an array.  Returns 
 
arnp.ndarray 

An array having one more dimension than the images in self.    Raises 
 ValueError

If images in the ImageCollection don’t have identical shapes.      See also  
concatenate_images

  
  
property conserve_memory 
  
property files 
  
reload(n=None) [source]
 
Clear the image cache.  Parameters 
 
nNone or int 

Clear the cache for this image only. By default, the entire cache is erased.
concatenate() [source]
 
Concatenate all images in the collection into an array.  Returns 
 
arnp.ndarray 

An array having one more dimension than the images in self.    Raises 
 ValueError

If images in the ImageCollection don’t have identical shapes.      See also  
concatenate_images
reload(n=None) [source]
 
Clear the image cache.  Parameters 
 
nNone or int 

Clear the cache for this image only. By default, the entire cache is erased.
__init__(load_pattern, conserve_memory=True, load_func=None, **load_func_kwargs) [source]
 
Load and manage a collection of images.
skimage.io.imread(fname, as_gray=False, plugin=None, **plugin_args) [source]
 
Load an image from file.  Parameters 
 
fnamestring 

Image file name, e.g. test.jpg or URL.  
as_graybool, optional 

If True, convert color images to gray-scale (64-bit floats). Images that are already in gray-scale format are not converted.  
pluginstr, optional 

Name of plugin to use. By default, the different plugins are tried (starting with imageio) until a suitable candidate is found. If not given and fname is a tiff file, the tifffile plugin will be used.    Returns 
 
img_arrayndarray 

The different color bands/channels are stored in the third dimension, such that a gray-image is MxN, an RGB-image MxNx3 and an RGBA-image MxNx4.    Other Parameters 
 
plugin_argskeywords 

Passed to the given plugin.
skimage.io.imread_collection(load_pattern, conserve_memory=True, plugin=None, **plugin_args) [source]
 
Load a collection of images.  Parameters 
 
load_patternstr or list 

List of objects to load. These are usually filenames, but may vary depending on the currently active plugin. See the docstring for ImageCollection for the default behaviour of this parameter.  
conserve_memorybool, optional 

If True, never keep more than one in memory at a specific time. Otherwise, images will be cached once they are loaded.    Returns 
 
icImageCollection 

Collection of images.    Other Parameters 
 
plugin_argskeywords 

Passed to the given plugin.
skimage.io.imsave(fname, arr, plugin=None, check_contrast=True, **plugin_args) [source]
 
Save an image to file.  Parameters 
 
fnamestr 

Target filename.  
arrndarray of shape (M,N) or (M,N,3) or (M,N,4) 

Image data.  
pluginstr, optional 

Name of plugin to use. By default, the different plugins are tried (starting with imageio) until a suitable candidate is found. If not given and fname is a tiff file, the tifffile plugin will be used.  
check_contrastbool, optional 

Check for low contrast and print warning (default: True).    Other Parameters 
 
plugin_argskeywords 

Passed to the given plugin.     Notes When saving a JPEG, the compression ratio may be controlled using the quality keyword argument which is an integer with values in [1, 100] where 1 is worst quality and smallest file size, and 100 is best quality and largest file size (default 75). This is only available when using the PIL and imageio plugins.
skimage.io.imshow(arr, plugin=None, **plugin_args) [source]
 
Display an image.  Parameters 
 
arrndarray or str 

Image data or name of image file.  
pluginstr 

Name of plugin to use. By default, the different plugins are tried (starting with imageio) until a suitable candidate is found.    Other Parameters 
 
plugin_argskeywords 

Passed to the given plugin.
skimage.io.imshow_collection(ic, plugin=None, **plugin_args) [source]
 
Display a collection of images.  Parameters 
 
icImageCollection 

Collection to display.  
pluginstr 

Name of plugin to use. By default, the different plugins are tried until a suitable candidate is found.    Other Parameters 
 
plugin_argskeywords 

Passed to the given plugin.
skimage.io.load_sift(f) [source]
 
Read SIFT or SURF features from externally generated file. This routine reads SIFT or SURF files generated by binary utilities from http://people.cs.ubc.ca/~lowe/keypoints/ and http://www.vision.ee.ethz.ch/~surf/. This routine does not generate SIFT/SURF features from an image. These algorithms are patent encumbered. Please use skimage.feature.CENSURE instead.  Parameters 
 
filelikestring or open file 

Input file generated by the feature detectors from http://people.cs.ubc.ca/~lowe/keypoints/ or http://www.vision.ee.ethz.ch/~surf/ .  
mode{‘SIFT’, ‘SURF’}, optional 

Kind of descriptor used to generate filelike.    Returns 
 
datarecord array with fields 

 
 row: int

row position of feature    
 column: int

column position of feature    
 scale: float

feature scale    
 orientation: float

feature orientation    
 data: array

feature values
skimage.io.load_surf(f) [source]
 
Read SIFT or SURF features from externally generated file. This routine reads SIFT or SURF files generated by binary utilities from http://people.cs.ubc.ca/~lowe/keypoints/ and http://www.vision.ee.ethz.ch/~surf/. This routine does not generate SIFT/SURF features from an image. These algorithms are patent encumbered. Please use skimage.feature.CENSURE instead.  Parameters 
 
filelikestring or open file 

Input file generated by the feature detectors from http://people.cs.ubc.ca/~lowe/keypoints/ or http://www.vision.ee.ethz.ch/~surf/ .  
mode{‘SIFT’, ‘SURF’}, optional 

Kind of descriptor used to generate filelike.    Returns 
 
datarecord array with fields 

 
 row: int

row position of feature    
 column: int

column position of feature    
 scale: float

feature scale    
 orientation: float

feature orientation    
 data: array

feature values
class skimage.io.MultiImage(filename, conserve_memory=True, dtype=None, **imread_kwargs) [source]
 
Bases: skimage.io.collection.ImageCollection A class containing all frames from multi-frame images.  Parameters 
 
load_patternstr or list of str 

Pattern glob or filenames to load. The path can be absolute or relative.  
conserve_memorybool, optional 

Whether to conserve memory by only caching a single frame. Default is True.    Other Parameters 
 
load_funccallable 

imread by default. See notes below.     Notes If conserve_memory=True the memory footprint can be reduced, however the performance can be affected because frames have to be read from file more often. The last accessed frame is cached, all other frames will have to be read from file. The current implementation makes use of tifffile for Tiff files and PIL otherwise. Examples >>> from skimage import data_dir
 >>> img = MultiImage(data_dir + '/multipage.tif') 
>>> len(img) 
2
>>> for frame in img: 
...     print(frame.shape) 
(15, 10)
(15, 10)
  
__init__(filename, conserve_memory=True, dtype=None, **imread_kwargs) [source]
 
Load a multi-img. 
  
property filename
__init__(filename, conserve_memory=True, dtype=None, **imread_kwargs) [source]
 
Load a multi-img.
skimage.io.plugin_info(plugin) [source]
 
Return plugin meta-data.  Parameters 
 
pluginstr 

Name of plugin.    Returns 
 
mdict 

Meta data as specified in plugin .ini.
skimage.io.plugin_order() [source]
 
Return the currently preferred plugin order.  Returns 
 
pdict 

Dictionary of preferred plugin order, with function name as key and plugins (in order of preference) as value.
skimage.io.pop() [source]
 
Pop an image from the shared image stack.  Returns 
 
imgndarray 

Image popped from the stack.
skimage.io.push(img) [source]
 
Push an image onto the shared image stack.  Parameters 
 
imgndarray 

Image to push.
skimage.io.show() [source]
 
Display pending images. Launch the event loop of the current gui plugin, and display all pending images, queued via imshow. This is required when using imshow from non-interactive scripts. A call to show will block execution of code until all windows have been closed. Examples >>> import skimage.io as io
 >>> for i in range(4):
...     ax_im = io.imshow(np.random.rand(50, 50))
>>> io.show()
skimage.io.use_plugin(name, kind=None) [source]
 
Set the default plugin for a specified operation. The plugin will be loaded if it hasn’t been already.  Parameters 
 
namestr 

Name of plugin.  
kind{‘imsave’, ‘imread’, ‘imshow’, ‘imread_collection’, ‘imshow_collection’}, optional 

Set the plugin for this function. By default, the plugin is set for all functions.      See also  
available_plugins 

List of available plugins    Examples To use Matplotlib as the default image reader, you would write: >>> from skimage import io
>>> io.use_plugin('matplotlib', 'imread')
 To see a list of available plugins run io.available_plugins. Note that this lists plugins that are defined, but the full list may not be usable if your system does not have the required libraries installed.
skimage.lookfor(what) [source]
 
Do a keyword search on scikit-image docstrings.  Parameters 
 
whatstr 

Words to look for.     Examples >>> import skimage
>>> skimage.lookfor('regular_grid')
Search results for 'regular_grid'
---------------------------------
skimage.lookfor
    Do a keyword search on scikit-image docstrings.
skimage.util.regular_grid
    Find `n_points` regularly spaced along `ar_shape`.
skimage.measure.approximate_polygon(coords, tolerance) [source]
 
Approximate a polygonal chain with the specified tolerance. It is based on the Douglas-Peucker algorithm. Note that the approximated polygon is always within the convex hull of the original polygon.  Parameters 
 
coords(N, 2) array 

Coordinate array.  
tolerancefloat 

Maximum distance from original points of polygon to approximated polygonal chain. If tolerance is 0, the original coordinate array is returned.    Returns 
 
coords(M, 2) array 

Approximated polygonal chain where M <= N.     References  
1  
https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
skimage.measure.block_reduce(image, block_size, func=<function sum>, cval=0, func_kwargs=None) [source]
 
Downsample image by applying function func to local blocks. This function is useful for max and mean pooling, for example.  Parameters 
 
imagendarray 

N-dimensional input image.  
block_sizearray_like 

Array containing down-sampling integer factor along each axis.  
funccallable 

Function object which is used to calculate the return value for each local block. This function must implement an axis parameter. Primary functions are numpy.sum, numpy.min, numpy.max, numpy.mean and numpy.median. See also func_kwargs.  
cvalfloat 

Constant padding value if image is not perfectly divisible by the block size.  
func_kwargsdict 

Keyword arguments passed to func. Notably useful for passing dtype argument to np.mean. Takes dictionary of inputs, e.g.: func_kwargs={'dtype': np.float16}).    Returns 
 
imagendarray 

Down-sampled image with same number of dimensions as input image.     Examples >>> from skimage.measure import block_reduce
>>> image = np.arange(3*3*4).reshape(3, 3, 4)
>>> image 
array([[[ 0,  1,  2,  3],
        [ 4,  5,  6,  7],
        [ 8,  9, 10, 11]],
       [[12, 13, 14, 15],
        [16, 17, 18, 19],
        [20, 21, 22, 23]],
       [[24, 25, 26, 27],
        [28, 29, 30, 31],
        [32, 33, 34, 35]]])
>>> block_reduce(image, block_size=(3, 3, 1), func=np.mean)
array([[[16., 17., 18., 19.]]])
>>> image_max1 = block_reduce(image, block_size=(1, 3, 4), func=np.max)
>>> image_max1 
array([[[11]],
       [[23]],
       [[35]]])
>>> image_max2 = block_reduce(image, block_size=(3, 1, 4), func=np.max)
>>> image_max2 
array([[[27],
        [31],
        [35]]])
class skimage.measure.CircleModel [source]
 
Bases: skimage.measure.fit.BaseModel Total least squares estimator for 2D circles. The functional model of the circle is: r**2 = (x - xc)**2 + (y - yc)**2
 This estimator minimizes the squared distances from all points to the circle: min{ sum((r - sqrt((x_i - xc)**2 + (y_i - yc)**2))**2) }
 A minimum number of 3 points is required to solve for the parameters. Examples >>> t = np.linspace(0, 2 * np.pi, 25)
>>> xy = CircleModel().predict_xy(t, params=(2, 3, 4))
>>> model = CircleModel()
>>> model.estimate(xy)
True
>>> tuple(np.round(model.params, 5))
(2.0, 3.0, 4.0)
>>> res = model.residuals(xy)
>>> 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.])
  Attributes 
 
paramstuple 

Circle model parameters in the following order xc, yc, r.      
__init__() [source]
 
Initialize self. See help(type(self)) for accurate signature. 
  
estimate(data) [source]
 
Estimate circle model from data using total least squares.  Parameters 
 
data(N, 2) array 

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

True, if model estimation succeeds.     
  
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(3, ) 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 circle is returned.  Parameters 
 
data(N, 2) array 

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

Residual for each data point.
estimate(data) [source]
 
Estimate circle model from data using total least squares.  Parameters 
 
data(N, 2) array 

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

True, if model estimation succeeds.
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(3, ) 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 circle is returned.  Parameters 
 
data(N, 2) array 

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

Residual for each data point.
__init__() [source]
 
Initialize self. See help(type(self)) for accurate signature.
class skimage.measure.EllipseModel [source]
 
Bases: skimage.measure.fit.BaseModel Total least squares estimator for 2D ellipses. The functional model of the ellipse is: xt = xc + a*cos(theta)*cos(t) - b*sin(theta)*sin(t)
yt = yc + a*sin(theta)*cos(t) + b*cos(theta)*sin(t)
d = sqrt((x - xt)**2 + (y - yt)**2)
 where (xt, yt) is the closest point on the ellipse to (x, y). Thus d is the shortest distance from the point to the ellipse. The estimator is based on a least squares minimization. The optimal solution is computed directly, no iterations are required. This leads to a simple, stable and robust fitting method. The params attribute contains the parameters in the following order: xc, yc, a, b, theta
 Examples >>> xy = EllipseModel().predict_xy(np.linspace(0, 2 * np.pi, 25),
...                                params=(10, 15, 4, 8, np.deg2rad(30)))
>>> ellipse = EllipseModel()
>>> ellipse.estimate(xy)
True
>>> np.round(ellipse.params, 2)
array([10.  , 15.  ,  4.  ,  8.  ,  0.52])
>>> np.round(abs(ellipse.residuals(xy)), 5)
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.])
  Attributes 
 
paramstuple 

Ellipse model parameters in the following order xc, yc, a, b, theta.      
__init__() [source]
 
Initialize self. See help(type(self)) for accurate signature. 
  
estimate(data) [source]
 
Estimate circle model from data using total least squares.  Parameters 
 
data(N, 2) array 

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

True, if model estimation succeeds.     References  
1  
Halir, R.; Flusser, J. “Numerically stable direct least squares fitting of ellipses”. In Proc. 6th International Conference in Central Europe on Computer Graphics and Visualization. WSCG (Vol. 98, pp. 125-132).   
  
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.
estimate(data) [source]
 
Estimate circle model from data using total least squares.  Parameters 
 
data(N, 2) array 

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

True, if model estimation succeeds.     References  
1  
Halir, R.; Flusser, J. “Numerically stable direct least squares fitting of ellipses”. In Proc. 6th International Conference in Central Europe on Computer Graphics and Visualization. WSCG (Vol. 98, pp. 125-132).