linumpy.intensity.normalize#

Intensity normalization, equalization and histogram matching.

Functions#

eqhist(image[, nbins])

Apply histogram equalisation on the input image.

normalize(image[, low_thresh, high_thresh])

Normalize an image using low and high intensity thresholds.

match_histogram(…)

Match im2 and im1 histograms.

match_histogram_sequentially(data, preproc_data, abspos, z)

Match neighbor tiles histograms sequentially.

get_smooth_intensity_transition(vol, slices_start)

Use a regularization function to get a smooth intensity transition between adjacent slices.

Module Contents#

linumpy.intensity.normalize.eqhist(image, nbins=32)[source]#

Apply histogram equalisation on the input image.

Parameters:
  • image (ndarray) – Input image

  • nbins (int) – Number of histogram bins to use

Returns:

Equalized image

Return type:

ndarray

linumpy.intensity.normalize.normalize(image, low_thresh=0.0, high_thresh=99.5)[source]#

Normalize an image using low and high intensity thresholds.

Parameters:
  • image (ndarray) – Image / volume to normalize

  • low_thresh (float) – Low intensity threshold to saturate (in percentile)

  • high_thresh (float) – High intensity threshold to saturate (in percentile)

Returns:

Normalized image / volume

Return type:

ndarray

linumpy.intensity.normalize.match_histogram(im1: numpy.ndarray, im2: numpy.ndarray, return_transforms: Literal[False] = ...) numpy.ndarray[source]#
linumpy.intensity.normalize.match_histogram(im1: numpy.ndarray, im2: numpy.ndarray, return_transforms: Literal[True]) tuple[Any, Any]

Match im2 and im1 histograms.

Parameters:
  • im1 (ndarray) – Reference image used as target

  • im2 (ndarray) – Image to be adjusted

  • return_transforms (bool) – If set to True, the transform functions will be returned instead of the adjusted image.

Returns:

  • ndarray – If returnTransform=False, returns adjusted image (im2)

  • list(interpolator functions) – If returnTransform=True, returns the function used to adjust im2 intensity to fit the im1 histogram. (V_inv, and T)

Notes

The returned interpolators V_inv and T need to be applied in chain. Example :

>> V_inv, T = match_histogram(im1, im2, returnTransform=True) >> im2p = V_inv(T(im2))

linumpy.intensity.normalize.match_histogram_sequentially(data, preproc_data, abspos, z, overwrite=False)[source]#

Match neighbor tiles histograms sequentially.

Parameters:
  • data (data object) – Used for iteration and to load/save volumes.

  • preproc_data (data object) – Output data object used to save preprocessed volumes.

  • abspos (ndarray) – Absolute positions for each tile.

  • z (int) – Slice index to process.

  • overwrite (bool) – If True, overwrite existing data.

Return type:

None

linumpy.intensity.normalize.get_smooth_intensity_transition(vol, slices_start)[source]#

Use a regularization function to get a smooth intensity transition between adjacent slices.

Parameters:
  • vol (ndarray) – Volume containing the slice to adjust

  • slices_start (list of int) – List of slice positions, corresponding to the slice transition location

  • compensateAttenuation (bool) – If true, compensation Beer-Lambert attenuation before the regularization (using a division by a low-pass version of the slice).

Returns:

Adjusted volume.

Return type:

ndarray

References