fluidimage.topologies.preproc#

Topology for image preprocessing (fluidimage.topologies.preproc)#

class fluidimage.topologies.preproc.TopologyPreproc(params: ParamContainer, logging_level='info', nb_max_workers=None)[source]#

Bases: TopologyBaseFromSeries

Preprocess series of images.

The most useful methods for the user (in particular compute()) are defined in the base class fluidimage.topologies.base.TopologyBase.

Parameters:
params: None

A ParamContainer (created with the class method create_default_params()) containing the parameters for the computation.

logging_level: str, {‘warning’, ‘info’, ‘debug’, …}

Logging level.

nb_max_workers: None, int

Maximum numbers of “workers”. If None, a number is computed from the number of cores detected. If there are memory errors, you can try to decrease the number of workers.

Splitter#

alias of SplitterFromSeries

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

Class method returning the default parameters.

Typical usage:

params = TopologyPreproc.create_default_params()
# modify parameters here
...

topo = TopologyPreproc(params)
Parameters:
backend{‘python’, ‘opencv’}

Specifies which backend to use.

save_preproc_object(obj: PreprocResults)[source]#

Save a preprocessing object

compute_indices_to_be_computed()[source]#

Compute the indices corresponding to the series to be computed

fill_subsets_of_names_and_paths(input_queue: None, output_queues: Tuple[Dict]) None[source]#

Fill the two first queues

make_subsets(input_queues: Tuple[Dict], output_queue: Dict) bool[source]#

Create the subsets of images

Documentation for params#

Documentation for params.series

Parameters describing image loading prior to preprocessing.

  • str_subset : str

    Determines the subset from the whole series of images that should be loaded and preprocessed together. Particularly useful when temporal filtering requires multiple images.

    For example, for a series of images with just one index,

    >>> str_subset = 'i:i+1'   # load one image at a time
    >>> str_subset = 'i-2:i+3'  # loads 5 images at a time
    

    Similarly for two indices,

    >>> str_subset = 'i:i+1,0'   # load one image at a time, with second index fixed
    >>> str_subset = 'i-2:i+3,0'  # loads 5 images at a time, with second index fixed
    
  • ind_start : int

    Start index for the whole series of images being loaded. For more details: see {class}`fluiddyn.util.serieofarrays.SeriesOfArrays`.

  • ind_stop : int

    Stop index for the whole series of images being loaded. For more details: see {class}`fluiddyn.util.serieofarrays.SeriesOfArrays`.

  • ind_step : int

    Step index for the whole series of images being loaded. For more details: see {class}`fluiddyn.util.serieofarrays.SeriesOfArrays`.

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

Documentation for params.saving

Parameters describing image saving after preprocessing.

  • path : str or None

    Path to which preprocessed images are saved.

  • how : str {‘ask’, ‘new_dir’, ‘complete’, ‘recompute’}

    How preprocessed images must be saved if it already exists or not.

  • postfix : str

    A suffix added to the new directory where preprocessed images are saved.

  • format : str {‘img’, ‘hdf5’}

    Format in which preprocessed image data must be saved.

  • str_subset : str or None

    NotImplemented! Determines the sub-subset of images must be saved from subset of images that were loaded and preprocessed. When set as None, saves the middle image from every subset.

Documentation for params.im2im

  • im2im : str {None}

    Function or class to be used to process the images.

  • args_init : object {None}

    An argument given to the init function of the class used to process the images.

Classes

Topology

alias of TopologyPreproc

TopologyPreproc(params[, logging_level, ...])

Preprocess series of images.