neulab/docprompting-conala huggingface dataset:
skimage.filters.threshold_mean(image) [source]
 
Return threshold value based on the mean of grayscale values.  Parameters 
 
image(N, M[, …, P]) ndarray 

Grayscale input image.    Returns 
 
thresholdfloat 

Upper threshold value. All pixels with an intensity higher than this value are assumed to be foreground.     References  
1  
C. A. Glasbey, “An analysis of histogram-based thresholding algorithms,” CVGIP: Graphical Models and Image Processing, vol. 55, pp. 532-537, 1993. DOI:10.1006/cgip.1993.1040   Examples >>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_mean(image)
>>> binary = image > thresh
skimage.filters.threshold_minimum(image=None, nbins=256, max_iter=10000, *, hist=None) [source]
 
Return threshold value based on minimum method. The histogram of the input image is computed if not provided and smoothed until there are only two maxima. Then the minimum in between is the threshold value. Either image or hist must be provided. In case hist is given, the actual histogram of the image is ignored.  Parameters 
 
image(M, N) ndarray, optional 

Input image.  
nbinsint, optional 

Number of bins used to calculate histogram. This value is ignored for integer arrays.  
max_iterint, optional 

Maximum number of iterations to smooth the histogram.  
histarray, or 2-tuple of arrays, optional 

Histogram to determine the threshold from and a corresponding array of bin center intensities. Alternatively, only the histogram can be passed.    Returns 
 
thresholdfloat 

Upper threshold value. All pixels with an intensity higher than this value are assumed to be foreground.    Raises 
 RuntimeError

If unable to find two local maxima in the histogram or if the smoothing takes more than 1e4 iterations.     References  
1  
C. A. Glasbey, “An analysis of histogram-based thresholding algorithms,” CVGIP: Graphical Models and Image Processing, vol. 55, pp. 532-537, 1993.  
2  
Prewitt, JMS & Mendelsohn, ML (1966), “The analysis of cell images”, Annals of the New York Academy of Sciences 128: 1035-1053 DOI:10.1111/j.1749-6632.1965.tb11715.x   Examples >>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_minimum(image)
>>> binary = image > thresh
skimage.filters.threshold_multiotsu(image, classes=3, nbins=256) [source]
 
Generate classes-1 threshold values to divide gray levels in image. The threshold values are chosen to maximize the total sum of pairwise variances between the thresholded graylevel classes. See Notes and [1] for more details.  Parameters 
 
image(N, M) ndarray 

Grayscale input image.  
classesint, optional 

Number of classes to be thresholded, i.e. the number of resulting regions.  
nbinsint, optional 

Number of bins used to calculate the histogram. This value is ignored for integer arrays.    Returns 
 
thresharray 

Array containing the threshold values for the desired classes.    Raises 
 ValueError

If image contains less grayscale value then the desired number of classes.     Notes This implementation relies on a Cython function whose complexity is \(O\left(\frac{Ch^{C-1}}{(C-1)!}\right)\), where \(h\) is the number of histogram bins and \(C\) is the number of classes desired. The input image must be grayscale. References  
1  
Liao, P-S., Chen, T-S. and Chung, P-C., “A fast algorithm for multilevel thresholding”, Journal of Information Science and Engineering 17 (5): 713-727, 2001. Available at: <https://ftp.iis.sinica.edu.tw/JISE/2001/200109_01.pdf> DOI:10.6688/JISE.2001.17.5.1  
2  
Tosa, Y., “Multi-Otsu Threshold”, a java plugin for ImageJ. Available at: <http://imagej.net/plugins/download/Multi_OtsuThreshold.java>   Examples >>> from skimage.color import label2rgb
>>> from skimage import data
>>> image = data.camera()
>>> thresholds = threshold_multiotsu(image)
>>> regions = np.digitize(image, bins=thresholds)
>>> regions_colorized = label2rgb(regions)
skimage.filters.threshold_niblack(image, window_size=15, k=0.2) [source]
 
Applies Niblack local threshold to an array. A threshold T is calculated for every pixel in the image using the following formula: T = m(x,y) - k * s(x,y)
 where m(x,y) and s(x,y) are the mean and standard deviation of pixel (x,y) neighborhood defined by a rectangular window with size w times w centered around the pixel. k is a configurable parameter that weights the effect of standard deviation.  Parameters 
 
imagendarray 

Input image.  
window_sizeint, or iterable of int, optional 

Window size specified as a single odd integer (3, 5, 7, …), or an iterable of length image.ndim containing only odd integers (e.g. (1, 5, 5)).  
kfloat, optional 

Value of parameter k in threshold formula.    Returns 
 
threshold(N, M) ndarray 

Threshold mask. All pixels with an intensity higher than this value are assumed to be foreground.     Notes This algorithm is originally designed for text recognition. The Bradley threshold is a particular case of the Niblack one, being equivalent to >>> from skimage import data
>>> image = data.page()
>>> q = 1
>>> threshold_image = threshold_niblack(image, k=0) * q
 for some value q. By default, Bradley and Roth use q=1. References  
1  
W. Niblack, An introduction to Digital Image Processing, Prentice-Hall, 1986.  
2  
D. Bradley and G. Roth, “Adaptive thresholding using Integral Image”, Journal of Graphics Tools 12(2), pp. 13-21, 2007. DOI:10.1080/2151237X.2007.10129236   Examples >>> from skimage import data
>>> image = data.page()
>>> threshold_image = threshold_niblack(image, window_size=7, k=0.1)
skimage.filters.threshold_otsu(image=None, nbins=256, *, hist=None) [source]
 
Return threshold value based on Otsu’s method. Either image or hist must be provided. If hist is provided, the actual histogram of the image is ignored.  Parameters 
 
image(N, M) ndarray, optional 

Grayscale input image.  
nbinsint, optional 

Number of bins used to calculate histogram. This value is ignored for integer arrays.  
histarray, or 2-tuple of arrays, optional 

Histogram from which to determine the threshold, and optionally a corresponding array of bin center intensities. An alternative use of this function is to pass it only hist.    Returns 
 
thresholdfloat 

Upper threshold value. All pixels with an intensity higher than this value are assumed to be foreground.     Notes The input image must be grayscale. References  
1  
Wikipedia, https://en.wikipedia.org/wiki/Otsu’s_Method   Examples >>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_otsu(image)
>>> binary = image <= thresh
skimage.filters.threshold_sauvola(image, window_size=15, k=0.2, r=None) [source]
 
Applies Sauvola local threshold to an array. Sauvola is a modification of Niblack technique. In the original method a threshold T is calculated for every pixel in the image using the following formula: T = m(x,y) * (1 + k * ((s(x,y) / R) - 1))
 where m(x,y) and s(x,y) are the mean and standard deviation of pixel (x,y) neighborhood defined by a rectangular window with size w times w centered around the pixel. k is a configurable parameter that weights the effect of standard deviation. R is the maximum standard deviation of a greyscale image.  Parameters 
 
imagendarray 

Input image.  
window_sizeint, or iterable of int, optional 

Window size specified as a single odd integer (3, 5, 7, …), or an iterable of length image.ndim containing only odd integers (e.g. (1, 5, 5)).  
kfloat, optional 

Value of the positive parameter k.  
rfloat, optional 

Value of R, the dynamic range of standard deviation. If None, set to the half of the image dtype range.    Returns 
 
threshold(N, M) ndarray 

Threshold mask. All pixels with an intensity higher than this value are assumed to be foreground.     Notes This algorithm is originally designed for text recognition. References  
1  
J. Sauvola and M. Pietikainen, “Adaptive document image binarization,” Pattern Recognition 33(2), pp. 225-236, 2000. DOI:10.1016/S0031-3203(99)00055-2   Examples >>> from skimage import data
>>> image = data.page()
>>> t_sauvola = threshold_sauvola(image, window_size=15, k=0.2)
>>> binary_image = image > t_sauvola
skimage.filters.threshold_triangle(image, nbins=256) [source]
 
Return threshold value based on the triangle algorithm.  Parameters 
 
image(N, M[, …, P]) ndarray 

Grayscale input image.  
nbinsint, optional 

Number of bins used to calculate histogram. This value is ignored for integer arrays.    Returns 
 
thresholdfloat 

Upper threshold value. All pixels with an intensity higher than this value are assumed to be foreground.     References  
1  
Zack, G. W., Rogers, W. E. and Latt, S. A., 1977, Automatic Measurement of Sister Chromatid Exchange Frequency, Journal of Histochemistry and Cytochemistry 25 (7), pp. 741-753 DOI:10.1177/25.7.70454  
2  
ImageJ AutoThresholder code, http://fiji.sc/wiki/index.php/Auto_Threshold   Examples >>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_triangle(image)
>>> binary = image > thresh
skimage.filters.threshold_yen(image=None, nbins=256, *, hist=None) [source]
 
Return threshold value based on Yen’s method. Either image or hist must be provided. In case hist is given, the actual histogram of the image is ignored.  Parameters 
 
image(N, M) ndarray, optional 

Input image.  
nbinsint, optional 

Number of bins used to calculate histogram. This value is ignored for integer arrays.  
histarray, or 2-tuple of arrays, optional 

Histogram from which to determine the threshold, and optionally a corresponding array of bin center intensities. An alternative use of this function is to pass it only hist.    Returns 
 
thresholdfloat 

Upper threshold value. All pixels with an intensity higher than this value are assumed to be foreground.     References  
1  
Yen J.C., Chang F.J., and Chang S. (1995) “A New Criterion for Automatic Multilevel Thresholding” IEEE Trans. on Image Processing, 4(3): 370-378. DOI:10.1109/83.366472  
2  
Sezgin M. and Sankur B. (2004) “Survey over Image Thresholding Techniques and Quantitative Performance Evaluation” Journal of Electronic Imaging, 13(1): 146-165, DOI:10.1117/1.1631315 http://www.busim.ee.boun.edu.tr/~sankur/SankurFolder/Threshold_survey.pdf  
3  
ImageJ AutoThresholder code, http://fiji.sc/wiki/index.php/Auto_Threshold   Examples >>> from skimage.data import camera
>>> image = camera()
>>> thresh = threshold_yen(image)
>>> binary = image <= thresh
skimage.filters.try_all_threshold(image, figsize=(8, 5), verbose=True) [source]
 
Returns a figure comparing the outputs of different thresholding methods.  Parameters 
 
image(N, M) ndarray 

Input image.  
figsizetuple, optional 

Figure size (in inches).  
verbosebool, optional 

Print function name for each method.    Returns 
 
fig, axtuple 

Matplotlib figure and axes.     Notes The following algorithms are used:  isodata li mean minimum otsu triangle yen  Examples >>> from skimage.data import text
>>> fig, ax = try_all_threshold(text(), figsize=(10, 6), verbose=False)
skimage.filters.wiener(data, impulse_response=None, filter_params={}, K=0.25, predefined_filter=None) [source]
 
Minimum Mean Square Error (Wiener) inverse filter.  Parameters 
 
data(M,N) ndarray 

Input data.  
Kfloat or (M,N) ndarray 

Ratio between power spectrum of noise and undegraded image.  
impulse_responsecallable f(r, c, **filter_params) 

Impulse response of the filter. See LPIFilter2D.__init__.  
filter_paramsdict 

Additional keyword parameters to the impulse_response function.    Other Parameters 
 
predefined_filterLPIFilter2D 

If you need to apply the same filter multiple times over different images, construct the LPIFilter2D and specify it here.
skimage.filters.window(window_type, shape, warp_kwargs=None) [source]
 
Return an n-dimensional window of a given size and dimensionality.  Parameters 
 
window_typestring, float, or tuple 

The type of window to be created. Any window type supported by scipy.signal.get_window is allowed here. See notes below for a current list, or the SciPy documentation for the version of SciPy on your machine.  
shapetuple of int or int 

The shape of the window along each axis. If an integer is provided, a 1D window is generated.  
warp_kwargsdict 

Keyword arguments passed to skimage.transform.warp (e.g., warp_kwargs={'order':3} to change interpolation method).    Returns 
 
nd_windowndarray 

A window of the specified shape. dtype is np.double.     Notes This function is based on scipy.signal.get_window and thus can access all of the window types available to that function (e.g., "hann", "boxcar"). Note that certain window types require parameters that have to be supplied with the window name as a tuple (e.g., ("tukey", 0.8)). If only a float is supplied, it is interpreted as the beta parameter of the Kaiser window. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.windows.get_window.html for more details. Note that this function generates a double precision array of the specified shape and can thus generate very large arrays that consume a large amount of available memory. The approach taken here to create nD windows is to first calculate the Euclidean distance from the center of the intended nD window to each position in the array. That distance is used to sample, with interpolation, from a 1D window returned from scipy.signal.get_window. The method of interpolation can be changed with the order keyword argument passed to skimage.transform.warp. Some coordinates in the output window will be outside of the original signal; these will be filled in with zeros. Window types: - boxcar - triang - blackman - hamming - hann - bartlett - flattop - parzen - bohman - blackmanharris - nuttall - barthann - kaiser (needs beta) - gaussian (needs standard deviation) - general_gaussian (needs power, width) - slepian (needs width) - dpss (needs normalized half-bandwidth) - chebwin (needs attenuation) - exponential (needs decay scale) - tukey (needs taper fraction) References  
1  
Two-dimensional window design, Wikipedia, https://en.wikipedia.org/wiki/Two_dimensional_window_design   Examples Return a Hann window with shape (512, 512): >>> from skimage.filters import window
>>> w = window('hann', (512, 512))
 Return a Kaiser window with beta parameter of 16 and shape (256, 256, 35): >>> w = window(16, (256, 256, 35))
 Return a Tukey window with an alpha parameter of 0.8 and shape (100, 300): >>> w = window(('tukey', 0.8), (100, 300))
skimage.future.fit_segmenter(labels, features, clf) [source]
 
Segmentation using labeled parts of the image and a classifier.  Parameters 
 
labelsndarray of ints 

Image of labels. Labels >= 1 correspond to the training set and label 0 to unlabeled pixels to be segmented.  
featuresndarray 

Array of features, with the first dimension corresponding to the number of features, and the other dimensions correspond to labels.shape.  
clfclassifier object 

classifier object, exposing a fit and a predict method as in scikit-learn’s API, for example an instance of RandomForestClassifier or LogisticRegression classifier.    Returns 
 
clfclassifier object 

classifier trained on labels    Raises 
 
NotFittedError if self.clf has not been fitted yet (use self.fit).
skimage.future.graph.cut_normalized(labels, rag, thresh=0.001, num_cuts=10, in_place=True, max_edge=1.0, *, random_state=None) [source]
 
Perform Normalized Graph cut on the Region Adjacency Graph. Given an image’s labels and its similarity RAG, recursively perform a 2-way normalized cut on it. All nodes belonging to a subgraph that cannot be cut further are assigned a unique label in the output.  Parameters 
 
labelsndarray 

The array of labels.  
ragRAG 

The region adjacency graph.  
threshfloat 

The threshold. A subgraph won’t be further subdivided if the value of the N-cut exceeds thresh.  
num_cutsint 

The number or N-cuts to perform before determining the optimal one.  
in_placebool 

If set, modifies rag in place. For each node n the function will set a new attribute rag.nodes[n]['ncut label'].  
max_edgefloat, optional 

The maximum possible value of an edge in the RAG. This corresponds to an edge between identical regions. This is used to put self edges in the RAG.  
random_stateint, RandomState instance or None, optional 

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random. The random state is used for the starting point of scipy.sparse.linalg.eigsh.    Returns 
 
outndarray 

The new labeled array.     References  
1  
Shi, J.; Malik, J., “Normalized cuts and image segmentation”, Pattern Analysis and Machine Intelligence, IEEE Transactions on, vol. 22, no. 8, pp. 888-905, August 2000.   Examples >>> from skimage import data, segmentation
>>> from skimage.future import graph
>>> img = data.astronaut()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_mean_color(img, labels, mode='similarity')
>>> new_labels = graph.cut_normalized(labels, rag)
skimage.future.graph.cut_threshold(labels, rag, thresh, in_place=True) [source]
 
Combine regions separated by weight less than threshold. Given an image’s labels and its RAG, output new labels by combining regions whose nodes are separated by a weight less than the given threshold.  Parameters 
 
labelsndarray 

The array of labels.  
ragRAG 

The region adjacency graph.  
threshfloat 

The threshold. Regions connected by edges with smaller weights are combined.  
in_placebool 

If set, modifies rag in place. The function will remove the edges with weights less that thresh. If set to False the function makes a copy of rag before proceeding.    Returns 
 
outndarray 

The new labelled array.     References  
1  
Alain Tremeau and Philippe Colantoni “Regions Adjacency Graph Applied To Color Image Segmentation” DOI:10.1109/83.841950   Examples >>> from skimage import data, segmentation
>>> from skimage.future import graph
>>> img = data.astronaut()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_mean_color(img, labels)
>>> new_labels = graph.cut_threshold(labels, rag, 10)
skimage.future.graph.merge_hierarchical(labels, rag, thresh, rag_copy, in_place_merge, merge_func, weight_func) [source]
 
Perform hierarchical merging of a RAG. Greedily merges the most similar pair of nodes until no edges lower than thresh remain.  Parameters 
 
labelsndarray 

The array of labels.  
ragRAG 

The Region Adjacency Graph.  
threshfloat 

Regions connected by an edge with weight smaller than thresh are merged.  
rag_copybool 

If set, the RAG copied before modifying.  
in_place_mergebool 

If set, the nodes are merged in place. Otherwise, a new node is created for each merge..  
merge_funccallable 

This function is called before merging two nodes. For the RAG graph while merging src and dst, it is called as follows merge_func(graph, src, dst).  
weight_funccallable 

The function to compute the new weights of the nodes adjacent to the merged node. This is directly supplied as the argument weight_func to merge_nodes.    Returns 
 
outndarray 

The new labeled array.
skimage.future.graph.ncut(labels, rag, thresh=0.001, num_cuts=10, in_place=True, max_edge=1.0, *, random_state=None) [source]
 
Perform Normalized Graph cut on the Region Adjacency Graph. Given an image’s labels and its similarity RAG, recursively perform a 2-way normalized cut on it. All nodes belonging to a subgraph that cannot be cut further are assigned a unique label in the output.  Parameters 
 
labelsndarray 

The array of labels.  
ragRAG 

The region adjacency graph.  
threshfloat 

The threshold. A subgraph won’t be further subdivided if the value of the N-cut exceeds thresh.  
num_cutsint 

The number or N-cuts to perform before determining the optimal one.  
in_placebool 

If set, modifies rag in place. For each node n the function will set a new attribute rag.nodes[n]['ncut label'].  
max_edgefloat, optional 

The maximum possible value of an edge in the RAG. This corresponds to an edge between identical regions. This is used to put self edges in the RAG.  
random_stateint, RandomState instance or None, optional 

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random. The random state is used for the starting point of scipy.sparse.linalg.eigsh.    Returns 
 
outndarray 

The new labeled array.     References  
1  
Shi, J.; Malik, J., “Normalized cuts and image segmentation”, Pattern Analysis and Machine Intelligence, IEEE Transactions on, vol. 22, no. 8, pp. 888-905, August 2000.   Examples >>> from skimage import data, segmentation
>>> from skimage.future import graph
>>> img = data.astronaut()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_mean_color(img, labels, mode='similarity')
>>> new_labels = graph.cut_normalized(labels, rag)
add_edge(u, v, attr_dict=None, **attr) [source]
 
Add an edge between u and v while updating max node id.  See also networkx.Graph.add_edge().
add_node(n, attr_dict=None, **attr) [source]
 
Add node n while updating the maximum node id.  See also networkx.Graph.add_node().
copy() [source]
 
Copy the graph with its max node id.  See also networkx.Graph.copy().
fresh_copy() [source]
 
Return a fresh copy graph with the same data structure. A fresh copy has no nodes, edges or graph attributes. It is the same data structure as the current graph. This method is typically used to create an empty version of the graph. This is required when subclassing Graph with networkx v2 and does not cause problems for v1. Here is more detail from the network migrating from 1.x to 2.x document: With the new GraphViews (SubGraph, ReversedGraph, etc)
you can't assume that ``G.__class__()`` will create a new
instance of the same graph type as ``G``. In fact, the
call signature for ``__class__`` differs depending on
whether ``G`` is a view or a base class. For v2.x you
should use ``G.fresh_copy()`` to create a null graph of
the correct type---ready to fill with nodes and edges.
merge_nodes(src, dst, weight_func=<function min_weight>, in_place=True, extra_arguments=[], extra_keywords={}) [source]
 
Merge node src and dst. The new combined node is adjacent to all the neighbors of src and dst. weight_func is called to decide the weight of edges incident on the new node.  Parameters 
 
src, dstint 

Nodes to be merged.  
weight_funccallable, optional 

Function to decide the attributes of edges incident on the new node. For each neighbor n for src and `dst, weight_func will be called as follows: weight_func(src, dst, n, *extra_arguments, **extra_keywords). src, dst and n are IDs of vertices in the RAG object which is in turn a subclass of networkx.Graph. It is expected to return a dict of attributes of the resulting edge.  
in_placebool, optional 

If set to True, the merged node has the id dst, else merged node has a new id which is returned.  
extra_argumentssequence, optional 

The sequence of extra positional arguments passed to weight_func.  
extra_keywordsdictionary, optional 

The dict of keyword arguments passed to the weight_func.    Returns 
 
idint 

The id of the new node.     Notes If in_place is False the resulting node has a new id, rather than dst.
next_id() [source]
 
Returns the id for the new node to be inserted. The current implementation returns one more than the maximum id.  Returns 
 
idint 

The id of the new node to be inserted.