neulab/docprompting-conala huggingface dataset:
skimage.registration.optical_flow_ilk(reference_image, moving_image, *, radius=7, num_warp=10, gaussian=False, prefilter=False, dtype=<class 'numpy.float32'>) [source]
 
Coarse to fine optical flow estimator. The iterative Lucas-Kanade (iLK) solver is applied at each level of the image pyramid. iLK [1] is a fast and robust alternative to TVL1 algorithm although less accurate for rendering flat surfaces and object boundaries (see [2]).  Parameters 
 
reference_imagendarray, shape (M, N[, P[, …]]) 

The first gray scale image of the sequence.  
moving_imagendarray, shape (M, N[, P[, …]]) 

The second gray scale image of the sequence.  
radiusint, optional 

Radius of the window considered around each pixel.  
num_warpint, optional 

Number of times moving_image is warped.  
gaussianbool, optional 

If True, a Gaussian kernel is used for the local integration. Otherwise, a uniform kernel is used.  
prefilterbool, optional 

Whether to prefilter the estimated optical flow before each image warp. When True, a median filter with window size 3 along each axis is applied. This helps to remove potential outliers.  
dtypedtype, optional 

Output data type: must be floating point. Single precision provides good results and saves memory usage and computation time compared to double precision.    Returns 
 
flowndarray, shape ((reference_image.ndim, M, N[, P[, …]]) 

The estimated optical flow components for each axis.     Notes  The implemented algorithm is described in Table2 of [1]. Color images are not supported.  References  
1(1,2)  
Le Besnerais, G., & Champagnat, F. (2005, September). Dense optical flow by iterative local window registration. In IEEE International Conference on Image Processing 2005 (Vol. 1, pp. I-137). IEEE. DOI:10.1109/ICIP.2005.1529706  
2  
Plyer, A., Le Besnerais, G., & Champagnat, F. (2016). Massively parallel Lucas Kanade optical flow for real-time video processing applications. Journal of Real-Time Image Processing, 11(4), 713-730. DOI:10.1007/s11554-014-0423-0   Examples >>> from skimage.color import rgb2gray
>>> from skimage.data import stereo_motorcycle
>>> from skimage.registration import optical_flow_ilk
>>> reference_image, moving_image, disp = stereo_motorcycle()
>>> # --- Convert the images to gray level: color is not supported.
>>> reference_image = rgb2gray(reference_image)
>>> moving_image = rgb2gray(moving_image)
>>> flow = optical_flow_ilk(moving_image, reference_image)
skimage.registration.optical_flow_tvl1(reference_image, moving_image, *, attachment=15, tightness=0.3, num_warp=5, num_iter=10, tol=0.0001, prefilter=False, dtype=<class 'numpy.float32'>) [source]
 
Coarse to fine optical flow estimator. The TV-L1 solver is applied at each level of the image pyramid. TV-L1 is a popular algorithm for optical flow estimation introduced by Zack et al. [1], improved in [2] and detailed in [3].  Parameters 
 
reference_imagendarray, shape (M, N[, P[, …]]) 

The first gray scale image of the sequence.  
moving_imagendarray, shape (M, N[, P[, …]]) 

The second gray scale image of the sequence.  
attachmentfloat, optional 

Attachment parameter (\(\lambda\) in [1]). The smaller this parameter is, the smoother the returned result will be.  
tightnessfloat, optional 

Tightness parameter (\(\tau\) in [1]). It should have a small value in order to maintain attachement and regularization parts in correspondence.  
num_warpint, optional 

Number of times image1 is warped.  
num_iterint, optional 

Number of fixed point iteration.  
tolfloat, optional 

Tolerance used as stopping criterion based on the L² distance between two consecutive values of (u, v).  
prefilterbool, optional 

Whether to prefilter the estimated optical flow before each image warp. When True, a median filter with window size 3 along each axis is applied. This helps to remove potential outliers.  
dtypedtype, optional 

Output data type: must be floating point. Single precision provides good results and saves memory usage and computation time compared to double precision.    Returns 
 
flowndarray, shape ((image0.ndim, M, N[, P[, …]]) 

The estimated optical flow components for each axis.     Notes Color images are not supported. References  
1(1,2,3)  
Zach, C., Pock, T., & Bischof, H. (2007, September). A duality based approach for realtime TV-L 1 optical flow. In Joint pattern recognition symposium (pp. 214-223). Springer, Berlin, Heidelberg. DOI:10.1007/978-3-540-74936-3_22  
2  
Wedel, A., Pock, T., Zach, C., Bischof, H., & Cremers, D. (2009). An improved algorithm for TV-L 1 optical flow. In Statistical and geometrical approaches to visual motion analysis (pp. 23-45). Springer, Berlin, Heidelberg. DOI:10.1007/978-3-642-03061-1_2  
3  
Pérez, J. S., Meinhardt-Llopis, E., & Facciolo, G. (2013). TV-L1 optical flow estimation. Image Processing On Line, 2013, 137-150. DOI:10.5201/ipol.2013.26   Examples >>> from skimage.color import rgb2gray
>>> from skimage.data import stereo_motorcycle
>>> from skimage.registration import optical_flow_tvl1
>>> image0, image1, disp = stereo_motorcycle()
>>> # --- Convert the images to gray level: color is not supported.
>>> image0 = rgb2gray(image0)
>>> image1 = rgb2gray(image1)
>>> flow = optical_flow_tvl1(image1, image0)
skimage.restoration.ball_kernel(radius, ndim) [source]
 
Create a ball kernel for restoration.rolling_ball.  Parameters 
 
radiusint 

Radius of the ball.  
ndimint 

Number of dimensions of the ball. ndim should match the dimensionality of the image the kernel will be applied to.    Returns 
 
kernelndarray 

The kernel containing the surface intensity of the top half of the ellipsoid.      See also  
rolling_ball
skimage.restoration.calibrate_denoiser(image, denoise_function, denoise_parameters, *, stride=4, approximate_loss=True, extra_output=False) [source]
 
Calibrate a denoising function and return optimal J-invariant version. The returned function is partially evaluated with optimal parameter values set for denoising the input image.  Parameters 
 
imagendarray 

Input data to be denoised (converted using img_as_float).  
denoise_functionfunction 

Denoising function to be calibrated.  
denoise_parametersdict of list 

Ranges of parameters for denoise_function to be calibrated over.  
strideint, optional 

Stride used in masking procedure that converts denoise_function to J-invariance.  
approximate_lossbool, optional 

Whether to approximate the self-supervised loss used to evaluate the denoiser by only computing it on one masked version of the image. If False, the runtime will be a factor of stride**image.ndim longer.  
extra_outputbool, optional 

If True, return parameters and losses in addition to the calibrated denoising function    Returns 
 
best_denoise_functionfunction 

The optimal J-invariant version of denoise_function.  
If extra_output is True, the following tuple is also returned: 

(parameters_tested, losses)tuple (list of dict, list of int) 

List of parameters tested for denoise_function, as a dictionary of kwargs Self-supervised loss for each set of parameters in parameters_tested.     Notes The calibration procedure uses a self-supervised mean-square-error loss to evaluate the performance of J-invariant versions of denoise_function. The minimizer of the self-supervised loss is also the minimizer of the ground-truth loss (i.e., the true MSE error) [1]. The returned function can be used on the original noisy image, or other images with similar characteristics.  
Increasing the stride increases the performance of best_denoise_function 

at the expense of increasing its runtime. It has no effect on the runtime of the calibration.   References  
1  
J. Batson & L. Royer. Noise2Self: Blind Denoising by Self-Supervision, International Conference on Machine Learning, p. 524-533 (2019).   Examples >>> from skimage import color, data
>>> from skimage.restoration import denoise_wavelet
>>> import numpy as np
>>> img = color.rgb2gray(data.astronaut()[:50, :50])
>>> noisy = img + 0.5 * img.std() * np.random.randn(*img.shape)
>>> parameters = {'sigma': np.arange(0.1, 0.4, 0.02)}
>>> denoising_function = calibrate_denoiser(noisy, denoise_wavelet,
...                                         denoise_parameters=parameters)
>>> denoised_img = denoising_function(img)
skimage.restoration.cycle_spin(x, func, max_shifts, shift_steps=1, num_workers=None, multichannel=False, func_kw={}) [source]
 
Cycle spinning (repeatedly apply func to shifted versions of x).  Parameters 
 
xarray-like 

Data for input to func.  
funcfunction 

A function to apply to circularly shifted versions of x. Should take x as its first argument. Any additional arguments can be supplied via func_kw.  
max_shiftsint or tuple 

If an integer, shifts in range(0, max_shifts+1) will be used along each axis of x. If a tuple, range(0, max_shifts[i]+1) will be along axis i.  
shift_stepsint or tuple, optional 

The step size for the shifts applied along axis, i, are:: range((0, max_shifts[i]+1, shift_steps[i])). If an integer is provided, the same step size is used for all axes.  
num_workersint or None, optional 

The number of parallel threads to use during cycle spinning. If set to None, the full set of available cores are used.  
multichannelbool, optional 

Whether to treat the final axis as channels (no cycle shifts are performed over the channels axis).  
func_kwdict, optional 

Additional keyword arguments to supply to func.    Returns 
 
avg_ynp.ndarray 

The output of func(x, **func_kw) averaged over all combinations of the specified axis shifts.     Notes Cycle spinning was proposed as a way to approach shift-invariance via performing several circular shifts of a shift-variant transform [1]. For a n-level discrete wavelet transforms, one may wish to perform all shifts up to max_shifts = 2**n - 1. In practice, much of the benefit can often be realized with only a small number of shifts per axis. For transforms such as the blockwise discrete cosine transform, one may wish to evaluate shifts up to the block size used by the transform. References  
1  
R.R. Coifman and D.L. Donoho. “Translation-Invariant De-Noising”. Wavelets and Statistics, Lecture Notes in Statistics, vol.103. Springer, New York, 1995, pp.125-150. DOI:10.1007/978-1-4612-2544-7_9   Examples >>> import skimage.data
>>> from skimage import img_as_float
>>> from skimage.restoration import denoise_wavelet, cycle_spin
>>> img = img_as_float(skimage.data.camera())
>>> sigma = 0.1
>>> img = img + sigma * np.random.standard_normal(img.shape)
>>> denoised = cycle_spin(img, func=denoise_wavelet,
...                       max_shifts=3)
skimage.restoration.denoise_bilateral(image, win_size=None, sigma_color=None, sigma_spatial=1, bins=10000, mode='constant', cval=0, multichannel=False) [source]
 
Denoise image using bilateral filter.  Parameters 
 
imagendarray, shape (M, N[, 3]) 

Input image, 2D grayscale or RGB.  
win_sizeint 

Window size for filtering. If win_size is not specified, it is calculated as max(5, 2 * ceil(3 * sigma_spatial) + 1).  
sigma_colorfloat 

Standard deviation for grayvalue/color distance (radiometric similarity). A larger value results in averaging of pixels with larger radiometric differences. Note, that the image will be converted using the img_as_float function and thus the standard deviation is in respect to the range [0, 1]. If the value is None the standard deviation of the image will be used.  
sigma_spatialfloat 

Standard deviation for range distance. A larger value results in averaging of pixels with larger spatial differences.  
binsint 

Number of discrete values for Gaussian weights of color filtering. A larger value results in improved accuracy.  
mode{‘constant’, ‘edge’, ‘symmetric’, ‘reflect’, ‘wrap’} 

How to handle values outside the image borders. See numpy.pad for detail.  
cvalstring 

Used in conjunction with mode ‘constant’, the value outside the image boundaries.  
multichannelbool 

Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.    Returns 
 
denoisedndarray 

Denoised image.     Notes This is an edge-preserving, denoising filter. It averages pixels based on their spatial closeness and radiometric similarity [1]. Spatial closeness is measured by the Gaussian function of the Euclidean distance between two pixels and a certain standard deviation (sigma_spatial). Radiometric similarity is measured by the Gaussian function of the Euclidean distance between two color values and a certain standard deviation (sigma_color). References  
1  
C. Tomasi and R. Manduchi. “Bilateral Filtering for Gray and Color Images.” IEEE International Conference on Computer Vision (1998) 839-846. DOI:10.1109/ICCV.1998.710815   Examples >>> from skimage import data, img_as_float
>>> astro = img_as_float(data.astronaut())
>>> astro = astro[220:300, 220:320]
>>> noisy = astro + 0.6 * astro.std() * np.random.random(astro.shape)
>>> noisy = np.clip(noisy, 0, 1)
>>> denoised = denoise_bilateral(noisy, sigma_color=0.05, sigma_spatial=15,
...                              multichannel=True)
skimage.restoration.denoise_tv_bregman(image, weight, max_iter=100, eps=0.001, isotropic=True, *, multichannel=False) [source]
 
Perform total-variation denoising using split-Bregman optimization. Total-variation denoising (also know as total-variation regularization) tries to find an image with less total-variation under the constraint of being similar to the input image, which is controlled by the regularization parameter ([1], [2], [3], [4]).  Parameters 
 
imagendarray 

Input data to be denoised (converted using img_as_float`).  
weightfloat 

Denoising weight. The smaller the weight, the more denoising (at the expense of less similarity to the input). The regularization parameter lambda is chosen as 2 * weight.  
epsfloat, optional 

Relative difference of the value of the cost function that determines the stop criterion. The algorithm stops when: SUM((u(n) - u(n-1))**2) < eps
  
max_iterint, optional 

Maximal number of iterations used for the optimization.  
isotropicboolean, optional 

Switch between isotropic and anisotropic TV denoising.  
multichannelbool, optional 

Apply total-variation denoising separately for each channel. This option should be true for color images, otherwise the denoising is also applied in the channels dimension.    Returns 
 
undarray 

Denoised image.     References  
1  
https://en.wikipedia.org/wiki/Total_variation_denoising  
2  
Tom Goldstein and Stanley Osher, “The Split Bregman Method For L1 Regularized Problems”, ftp://ftp.math.ucla.edu/pub/camreport/cam08-29.pdf  
3  
Pascal Getreuer, “Rudin–Osher–Fatemi Total Variation Denoising using Split Bregman” in Image Processing On Line on 2012–05–19, https://www.ipol.im/pub/art/2012/g-tvd/article_lr.pdf  
4  
https://web.math.ucsb.edu/~cgarcia/UGProjects/BregmanAlgorithms_JacquelineBush.pdf
skimage.restoration.denoise_tv_chambolle(image, weight=0.1, eps=0.0002, n_iter_max=200, multichannel=False) [source]
 
Perform total-variation denoising on n-dimensional images.  Parameters 
 
imagendarray of ints, uints or floats 

Input data to be denoised. image can be of any numeric type, but it is cast into an ndarray of floats for the computation of the denoised image.  
weightfloat, optional 

Denoising weight. The greater weight, the more denoising (at the expense of fidelity to input).  
epsfloat, optional 

Relative difference of the value of the cost function that determines the stop criterion. The algorithm stops when: (E_(n-1) - E_n) < eps * E_0  
n_iter_maxint, optional 

Maximal number of iterations used for the optimization.  
multichannelbool, optional 

Apply total-variation denoising separately for each channel. This option should be true for color images, otherwise the denoising is also applied in the channels dimension.    Returns 
 
outndarray 

Denoised image.     Notes Make sure to set the multichannel parameter appropriately for color images. The principle of total variation denoising is explained in https://en.wikipedia.org/wiki/Total_variation_denoising The principle of total variation denoising is to minimize the total variation of the image, which can be roughly described as the integral of the norm of the image gradient. Total variation denoising tends to produce “cartoon-like” images, that is, piecewise-constant images. This code is an implementation of the algorithm of Rudin, Fatemi and Osher that was proposed by Chambolle in [1]. References  
1  
A. Chambolle, An algorithm for total variation minimization and applications, Journal of Mathematical Imaging and Vision, Springer, 2004, 20, 89-97.   Examples 2D example on astronaut image: >>> from skimage import color, data
>>> img = color.rgb2gray(data.astronaut())[:50, :50]
>>> img += 0.5 * img.std() * np.random.randn(*img.shape)
>>> denoised_img = denoise_tv_chambolle(img, weight=60)
 3D example on synthetic data: >>> x, y, z = np.ogrid[0:20, 0:20, 0:20]
>>> mask = (x - 22)**2 + (y - 20)**2 + (z - 17)**2 < 8**2
>>> mask = mask.astype(float)
>>> mask += 0.2*np.random.randn(*mask.shape)
>>> res = denoise_tv_chambolle(mask, weight=100)
skimage.restoration.ellipsoid_kernel(shape, intensity) [source]
 
Create an ellipoid kernel for restoration.rolling_ball.  Parameters 
 
shapearraylike 

Length of the principal axis of the ellipsoid (excluding the intensity axis). The kernel needs to have the same dimensionality as the image it will be applied to.  
intensityint 

Length of the intensity axis of the ellipsoid.    Returns 
 
kernelndarray 

The kernel containing the surface intensity of the top half of the ellipsoid.      See also  
rolling_ball
skimage.restoration.estimate_sigma(image, average_sigmas=False, multichannel=False) [source]
 
Robust wavelet-based estimator of the (Gaussian) noise standard deviation.  Parameters 
 
imagendarray 

Image for which to estimate the noise standard deviation.  
average_sigmasbool, optional 

If true, average the channel estimates of sigma. Otherwise return a list of sigmas corresponding to each channel.  
multichannelbool 

Estimate sigma separately for each channel.    Returns 
 
sigmafloat or list 

Estimated noise standard deviation(s). If multichannel is True and average_sigmas is False, a separate noise estimate for each channel is returned. Otherwise, the average of the individual channel estimates is returned.     Notes This function assumes the noise follows a Gaussian distribution. The estimation algorithm is based on the median absolute deviation of the wavelet detail coefficients as described in section 4.2 of [1]. References  
1  
D. L. Donoho and I. M. Johnstone. “Ideal spatial adaptation by wavelet shrinkage.” Biometrika 81.3 (1994): 425-455. DOI:10.1093/biomet/81.3.425   Examples >>> import skimage.data
>>> from skimage import img_as_float
>>> img = img_as_float(skimage.data.camera())
>>> sigma = 0.1
>>> img = img + sigma * np.random.standard_normal(img.shape)
>>> sigma_hat = estimate_sigma(img, multichannel=False)
skimage.restoration.inpaint_biharmonic(image, mask, multichannel=False) [source]
 
Inpaint masked points in image with biharmonic equations.  Parameters 
 
image(M[, N[, …, P]][, C]) ndarray 

Input image.  
mask(M[, N[, …, P]]) ndarray 

Array of pixels to be inpainted. Have to be the same shape as one of the ‘image’ channels. Unknown pixels have to be represented with 1, known pixels - with 0.  
multichannelboolean, optional 

If True, the last image dimension is considered as a color channel, otherwise as spatial.    Returns 
 
out(M[, N[, …, P]][, C]) ndarray 

Input image with masked pixels inpainted.     References  
1  
N.S.Hoang, S.B.Damelin, “On surface completion and image inpainting by biharmonic functions: numerical aspects”, arXiv:1707.06567  
2  
C. K. Chui and H. N. Mhaskar, MRA Contextual-Recovery Extension of Smooth Functions on Manifolds, Appl. and Comp. Harmonic Anal., 28 (2010), 104-113, DOI:10.1016/j.acha.2009.04.004   Examples >>> img = np.tile(np.square(np.linspace(0, 1, 5)), (5, 1))
>>> mask = np.zeros_like(img)
>>> mask[2, 2:] = 1
>>> mask[1, 3:] = 1
>>> mask[0, 4:] = 1
>>> out = inpaint_biharmonic(img, mask)
skimage.restoration.richardson_lucy(image, psf, iterations=50, clip=True, filter_epsilon=None) [source]
 
Richardson-Lucy deconvolution.  Parameters 
 
imagendarray 

Input degraded image (can be N dimensional).  
psfndarray 

The point spread function.  
iterationsint, optional 

Number of iterations. This parameter plays the role of regularisation.  
clipboolean, optional 

True by default. If true, pixel value of the result above 1 or under -1 are thresholded for skimage pipeline compatibility.  filter_epsilon: float, optional

Value below which intermediate results become 0 to avoid division by small numbers.    Returns 
 
im_deconvndarray 

The deconvolved image.     References  
1  
https://en.wikipedia.org/wiki/Richardson%E2%80%93Lucy_deconvolution   Examples >>> from skimage import img_as_float, data, restoration
>>> camera = img_as_float(data.camera())
>>> from scipy.signal import convolve2d
>>> psf = np.ones((5, 5)) / 25
>>> camera = convolve2d(camera, psf, 'same')
>>> camera += 0.1 * camera.std() * np.random.standard_normal(camera.shape)
>>> deconvolved = restoration.richardson_lucy(camera, psf, 5)
skimage.restoration.rolling_ball(image, *, radius=100, kernel=None, nansafe=False, num_threads=None) [source]
 
Estimate background intensity by rolling/translating a kernel. This rolling ball algorithm estimates background intensity for a ndimage in case of uneven exposure. It is a generalization of the frequently used rolling ball algorithm [1].  Parameters 
 
imagendarray 

The image to be filtered.  
radiusint, optional 

Radius of a ball shaped kernel to be rolled/translated in the image. Used if kernel = None.  
kernelndarray, optional 

The kernel to be rolled/translated in the image. It must have the same number of dimensions as image. Kernel is filled with the intensity of the kernel at that position.  nansafe: bool, optional

If False (default) assumes that none of the values in image are np.nan, and uses a faster implementation.  num_threads: int, optional

The maximum number of threads to use. If None use the OpenMP default value; typically equal to the maximum number of virtual cores. Note: This is an upper limit to the number of threads. The exact number is determined by the system’s OpenMP library.    Returns 
 
backgroundndarray 

The estimated background of the image.     Notes For the pixel that has its background intensity estimated (without loss of generality at center) the rolling ball method centers kernel under it and raises the kernel until the surface touches the image umbra at some pos=(y,x). The background intensity is then estimated using the image intensity at that position (image[pos]) plus the difference of kernel[center] - kernel[pos]. This algorithm assumes that dark pixels correspond to the background. If you have a bright background, invert the image before passing it to the function, e.g., using utils.invert. See the gallery example for details. This algorithm is sensitive to noise (in particular salt-and-pepper noise). If this is a problem in your image, you can apply mild gaussian smoothing before passing the image to this function. References  
1  
Sternberg, Stanley R. “Biomedical image processing.” Computer 1 (1983): 22-34. DOI:10.1109/MC.1983.1654163   Examples >>> import numpy as np
>>> from skimage import data
>>> from skimage.restoration import rolling_ball
>>> image = data.coins()
>>> background = rolling_ball(data.coins())
>>> filtered_image = image - background
 >>> import numpy as np
>>> from skimage import data
>>> from skimage.restoration import rolling_ball, ellipsoid_kernel
>>> image = data.coins()
>>> kernel = ellipsoid_kernel((101, 101), 75)
>>> background = rolling_ball(data.coins(), kernel=kernel)
>>> filtered_image = image - background