imfun.lib

imfun.lib.DFoF(vec, normL=None, th=1e-06)

Subtract mean value along first axis and normalize to it

imfun.lib.DFoSD(vec, normL=None, th=1e-06)

Subtract mean value along first axis and normalize to S.D.

imfun.lib.ar1(alpha=0.74)

Simple auto-regression model

imfun.lib.auto_threshold(arr, init_th=None, max_iter=10000000.0)

Automatic threhold with INTERMEANS(I) algorithm

Parameters:
  • arr: array-like
  • init_th: starting threshold
  • max_iter: upper limit of iterations
Returns:
  • threshold: float

Based on: T. Ridler and S. Calvard, “Picture thresholding using an iterative selection method,” IEEE Trans. Systems Man Cybernet., vol. 8, pp. 630-632, 1978.

imfun.lib.baseline_als(y, lam=None, p=0.1, niter=10)

Implements an Asymmetric Least Squares Smoothing baseline correction algorithm (P. Eilers, H. Boelens 2005)

imfun.lib.bounce(function, *args)

Bounce back onto the trampoline, with an upcoming function call.

imfun.lib.clip_and_rescale(arr, nout=100)

convert data to floats in 0...1, throwing out nout max values

imfun.lib.embedded_to_full(x)

Restore ‘full’ object from it’s embedding, e.g. full image from object subframe

imfun.lib.embedding(arr, delarrp=True)

Return an embeding of the non-zero portion of an array.

Parameters:
  • arr: array
  • delarrp: predicate whether to delete the arr
Returns tuple (out, (sh, slices)) of:
  • out: array, which is a bounding box around non-zero elements of an input array
  • sh: full shape of the input data
  • slices: a list of slices which define the bounding box
imfun.lib.eu_dist2d(p1, p2)

Euler distance between two points

imfun.lib.extrema2(v, *args, **kwargs)

First and second order extrema

imfun.lib.ifnot(a, b)

if a is not None, return a, else return b

imfun.lib.imresize(a, nx, ny, **kw)

Resize and image or other 2D array with affine transform # idea from Sci-Py mailing list (by Pauli Virtanen)

imfun.lib.land(value)

Jump off the trampoline, and land with a value.

imfun.lib.locextr(v, x=None, refine=True, output='full', sort_values=True, **kwargs)

Finds local extrema

imfun.lib.ma2d(m, n)

Moving average in 2d (for rows)

imfun.lib.mask4overlay(mask, colorind=0, alpha=0.9)

Put a binary mask in some color channel and make regions where the mask is False transparent

imfun.lib.mask4overlay2(mask, color=(1, 0, 0), alpha=0.9)

Put a binary mask in some color channel and make regions where the mask is False transparent

imfun.lib.mask_num_std(mat, n, func=<function <lambda> at 0x7fcac6e9dc80>)

Same as threshold, but threshold value is times S.D. of the matrix

imfun.lib.mc_levels(transform_fn, size=(256, 256), level=3, N=1000.0)

Return Monte-Carlo estimation of noise \sigma

Parameters:
  • transform_fn: (`function’) – decomposition transformation to use
  • size: (tuple) – size of random noisy images
  • level: (int) – level of decomposition
  • N: (num) – number of random images to process
Returns:
  • 1 \times level vector of noise \sigma estimations
imfun.lib.n_random_locs(n, shape)

return a list of n random locations within shape

imfun.lib.rescale(arr)

Rescales array to [0..1] interval

imfun.lib.trampoline(function, *args)

Bounces a function over and over, until we “land” off the trampoline.

imfun.lib.with_time(fn, *args, **kwargs)

take a function and timer its evaluation

imfun.lib.with_time_dec(fn)

decorator to time function evaluation