fluidimage.works.preproc#

Works Preprocess#

To preprocess series of images using topology.

Provides:

toolbox

Preprocess toolbox

_toolbox_cv

Preprocess toolbox

_toolbox_py

Preprocess toolbox

io

Handles I/O of images to tools

Provides:

class fluidimage.works.preproc.WorkPreproc(params=None)[source]#

Bases: BaseWorkFromSerie

Work for preprocessing.

Preprocess series of images with various tools.

classmethod create_default_params(backend='python')[source]#

Class method returning the default parameters.

Parameters:
backend: {‘python’, ‘opencv’}

Specifies which backend to use.

calcul(serie)[source]#

Apply all enabled preprocessing tools on the series of arrays and returns the result as a data object.

display(ind=0, hist=False)[source]#

Display figures to study the preprocessing

Documentation for params#

Documentation for params.series

Parameters indicating the input series of images.

  • path : str, {‘’}

    String indicating the input images (can be a full path towards an image file or a string given to glob).

  • str_subset : ‘pairs’

    String indicating as a Python slicing how couples of images are formed. There is one couple per value of i. The values of i are set with the other parameters ind_start, ind_step and ind_stop approximately with the function range (range(ind_start, ind_stop, ind_step)).

    Python slicing is a very powerful notation to define subset from a (possibly multidimensional) set of images. For a user, an alternative is to understand how Python slicing works. See for example this page: http://stackoverflow.com/questions/509211/explain-pythons-slice-notation.

    Another possibility is to follow simple examples:

    For single-frame images (im0, im1, im2, im3, …), we keep the default value ‘i:i+2’ to form the couples (im0, im1), (im1, im2), …

    To see what it gives, one can use IPython and range:

    >>> i = 0
    >>> list(range(10))[i:i+2]
    [0, 1]
    
    >>> list(range(10))[i:i+4:2]
    [0, 2]
    

    We see that we can also use the value ‘i:i+4:2’ to form the couples (im0, im2), (im1, im3), …

    For double-frame images (im1a, im1b, im2a, im2b, …) you can write

    >>> params.series.str_subset = 'i, 0:2'
    

    In this case, the first couple will be (im1a, im1b).

    To get the first couple (im1a, im1a), we would have to write

    >>> params.series.str_subset = 'i:i+2, 0'
    
  • ind_start : int, {‘first’}

  • ind_step : int, {1}

  • int_stop : None

Documentation for params.tools

Documentation for params.tools.sliding_median#

Subtracts the median calculated within a sliding window from the centre of

the window.

imgarray_like

Single image as numpy array or multiple images as array-like object

weightscalar

Fraction of median to be subtracted from each pixel. Value of weight should be in the interval (0.0, 1.0).

window_sizescalar or tuple

Sets the size of the sliding window. Specifying window_size=3 is equivalent to window_size=(3,3).

boundary_condition{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}

Mode of handling array borders.

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.sliding_minima#

Subtracts the minimum calculated within a sliding window from the centre of

the window.

imgarray_like

Single image as numpy array or multiple images as array-like object

weightscalar

Fraction of minima to be subtracted from each pixel. Value of weight should be in the interval (0.0,1.0).

window_sizescalar or tuple

Sets the size of the sliding window. Specifying window_size=3 is equivalent to window_size=(3,3).

boundary_condition{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}

Mode of handling array borders.

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.sliding_percentile#

Flexible version of median filter. Low percentile values work well

for dense images.

imgarray_like

Series of images as a 3D numpy array, or a list or a set

percentilescalar

Percentile to filter. Setting percentile = 50 is equivalent to a sliding_median filter.

weightscalar

Fraction of median to be subtracted from each pixel. Value of weight should be in the interval (0.0, 1.0).

window_shapetuple of integers

Specifies the shape of the window as follows (dt, dy, dx)

boundary_condition{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}

Mode of handling array borders.

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.temporal_median#

Subtracts the median calculated in time and space, for each pixel.

Median filter works well for sparse images.

imgarray_like

Series of images as a 3D numpy array, or a list or a set

weightscalar

Fraction of median to be subtracted from each pixel. Value of weight should be in the interval (0.0,1.0).

window_shapetuple of integers

Specifies the shape of the window as follows (nt, ny, nx) or (ny, nx).

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.temporal_minima#

Subtracts the minima calculated in time and space, for each pixel.

imgsarray_like

Series of images as a 3D numpy array, or a list or a set

weightscalar

Fraction of minima to be subtracted from each pixel. Value of weight should be in the interval (0.0,1.0).

window_shapetuple of integers

Specifies the shape of the window as follows (nt, ny, nx) or (ny, nx).

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.temporal_percentile#

Flexible version of median filter. Low percentile values work well

for dense images.

imgarray_like

Series of images as a 3D numpy array, or a list or a set

percentilescalar

Percentile to filter. Setting percentile = 50 is equivalent to a temporal_median filter.

weightscalar

Fraction of median to be subtracted from each pixel. Value of weight should be in the interval (0.0,1.0).

window_shapetuple of integers

Specifies the shape of the window as follows (nt, ny, nx) or (ny, nx).

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.global_threshold#

Trims pixel intensities which are outside the interval (minima, maxima).

imgarray_like

Single image as numpy array or multiple images as array-like object

minima, maximafloat

Sets the threshold

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.adaptive_threshold#

Adaptive threshold transforms a grayscale image to a binary image.

Useful in identifying particles.

imgarray_like

Single image as numpy array or multiple images as array-like object

window_sizescalar

Sets the size of the pixel neighbourhood to calculate threshold.

offsetscalar

Constant to be subtracted from the mean.

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.rescale_intensity#

Rescale image intensities, between the specified minima and maxima,

by using a multiplicative factor.

imgarray_like

Single image as numpy array or multiple images as array-like object

minima, maximafloat

Sets the range to which current intensities have to be rescaled.

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.equalize_hist_global#

Increases global contrast of the image. Equalized image would have a

roughly linear cumulative distribution function for each pixel neighborhood. It works well when pixel intensities are nearly uniform [1,2].

imgarray_like

Single image as numpy array or multiple images as array-like object

nbinsinteger

Number of bins to calculate histogram

Set as True to enable the tool

Documentation for params.tools.equalize_hist_local#

Adaptive histogram equalization (AHE) emphasizes every local graylevel variations [1].

Caution: It has a tendency to overamplify noise in homogenous regions [2].

imgarray_like

Single image as numpy array or multiple images as array-like object

radiusinteger

Radius of the disk shaped window.

Set as True to enable the tool

Documentation for params.tools.equalize_hist_adapt#

Contrast Limited Adaptive Histogram Equalization (CLAHE).

Increases local contrast.

imgarray_like

Single image as numpy array or multiple images as array-like object

window_shapetuple of integers

Specifies the shape of the window as follows (dx, dy)

nbinsinteger

Number of bins to calculate histogram

Set as True to enable the tool

Documentation for params.tools.gamma_correction#

Gamma correction or power law transform. It can be expressed as:

\[I_{out} = gain \times {I_{in}} ^ {\gamma}\]

Adjusts contrast without changing the shape of the histogram. For the values .. \(\gamma > 1\) : Histogram shifts towards left (darker) .. \(\gamma < 1\) : Histogram shifts towards right (lighter)

imgarray_like

Single image as numpy array or multiple images as array-like object

gammafloat

Non-negative real number

gainfloat

Multiplying factor

Set as True to enable the tool

Documentation for params.tools.sharpen#

Sharpen image edges.

imgarray_like

Single image as numpy array or multiple images as array-like object

sigma1, sigma2float

Std deviation for two passes gaussian filters. sigma1 > sigma2

alphafloat

Factor by which the image will be sharpened

  • enable : bool

Set as True to enable the tool

Documentation for params.tools.rescale_intensity_tanh#

Rescale image intensities, using a tanh fit. The maximum intensity of the

output is set by the threshold parameter.

imgarray_like

Single image as numpy array or multiple images as array-like object

threshold:

Value of intensity with which img is normalized img_out = max(img) * tanh( img / threshold) If threshold is None: threshold = 2 * np.sqrt(np.mean(img**2))

  • enable : bool

Set as True to enable the tool

Classes

Work

alias of WorkPreproc

WorkPreproc([params])

Work for preprocessing.