pystack3d.intensity_rescaling module

Functions related to the intensity rescaling processing

pystack3d.intensity_rescaling.init_args(params, shape)

Initialize arguments related to the current processing (‘intensity_rescaling’) and return a specific array to share (histo)

Parameters:
  • params (dict) – Dictionary related to the current process. See the related documentation for more details.

  • shape (tuple of 3 int) – Shape of the stack to process

Returns:

histo – Histogram to be shared during the (multi)processing

Return type:

numpy.ndarray((shape[0], nbins))

pystack3d.intensity_rescaling.intensity_rescaling(fnames=None, inds_partition=None, queue_incr=None, nbins=256, range_bins=None, filter_size=10, output_dirname=None)

Function for image intensity rescaling

Parameters:
  • fnames (list of pathlib.Path, optional) – List of ‘.tif’ filenames to process

  • inds_partition (list of ints, optional) – List of indexes to be considered by the global var SHARED_ARRAY when working in multiprocessing

  • queue_incr (multiprocessing.Queue, optional) – Queue passed to the function to interact with the progress bar

  • nbins (int, optional) – Number of bins in the histograms

  • range_bins (list of 2 floats, optional) – Range used in the histograms. If None, do a preliminary loop on all files to extract [vmin, vmax]

  • filter_size (int, optional) – Filter size for the histograms filtering operation (transverse 1d uniform filter) used as target for the image intensity rescaling. Value filter_size = -1 operates a standard transverse averaging through all the slices.

  • output_dirname (str, optional) – Directory pathname for process results saving

pystack3d.intensity_rescaling.eval(img, cdf_target, x_target, nbins, range_bins)

Find closest pixel-matches corresponding to the CDF (Cumulative Distribution Function) of the input image, given the value of the CDF H of the targeted image at the corresponding x_target location, s.t. :

cdf_target = H(x_target) <=> x_target = H-1(cdf_target)

https://stackoverflow.com/questions/32655686

Parameters:
  • img (numpy.ndarray((m, n))) – input image to rescale

  • cdf_target (list of 'nbins' floats) – CDF to target

  • x_target (list of 'nbins' floats) – support (gray levels) related to cdf_target values

  • nbins (int) – Number of bins to consider

  • range_bins (list of 2 floats) – Range associated to the bins

Returns:

img_rescaled – the corresponding intensity-rescaled image

Return type:

numpy.ndarray((m, n))

pystack3d.intensity_rescaling.cdf_calculation(img, nbins, range_bins)

Return the CDF (Cumulative Distribution Function) of an image

Parameters:
  • img (numpy.ndarray((m, n))) – image to handle

  • nbins (int) – Number of bins to consider

  • range_bins (list of 2 floats) – Range associated to the bins

Returns:

img_cdf – The corresponding CDF

Return type:

list of ‘nbins’ floats

pystack3d.intensity_rescaling.plot(output_dirname)

Plot the specific data related to the current process