locan.visualize.transform.HistogramEqualization

class locan.visualize.transform.HistogramEqualization(vmin=None, vmax=None, reference=None, power=1, n_bins=65536, mask=None)[source]

Bases: Normalize, Transform

Histogram equalization with power intensification.

The transformation function as described in [1] is \(f(a, p)\) according to:

\[\frac{f(a) - f(a_min)} {f(a_max) - f(a_min)} = \frac{\int_{a_min}^{a}{h^p(a') da'}} {\int_{a_min}^{a_max}{h^p(a') da'}}\]

Here, \(a\) is an intensity value, \(p\) the power (a parameter), and \(h(a)\) the histogram of intensities.

Note

The default for n_bins is 65536 (16 bit). For most SMLM datasets this should be sufficient to resolve individual localizations despite a large dynamic range. Setting n_bins to 256 (8 bit) is too course for many SMLM datasets.

References

Parameters:
  • vmin (int | float | None) – min intensity

  • vmax (int | float | None) – max intensity

  • reference (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes], None]) – The data values to define the transformation function. If None then the values in __call__ are used.

  • power (float) – The power intensification parameter.

  • n_bins (int) – Number of bins used to compute the intensity histogram.

  • mask (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes], None]) – A bool mask with shape equal to that of values. If reference is None, reference is set to values[mask]. The transformation determined from reference is then applied to all values.

Methods

__init__([vmin, vmax, reference, power, ...])

autoscale(A)

Set vmin, vmax to min, max of A.

autoscale_None(A)

If vmin or vmax are not set, use the min/max of A to set them.

inverse(values)

A Transformation object that performs the inverse operation.

process_value(value)

Homogenize the input value for easy and efficient normalization.

scaled()

Return whether vmin and vmax are both set.

Attributes

clip

vmax

vmin

__call__(values)[source]

Histogram equalization with power intensification.

Parameters:

values (Union[_Buffer, _SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[bool | int | float | complex | str | bytes]]) – The input values.

Return type:

npt.NDArray[np.float64]

inverse(values)[source]

A Transformation object that performs the inverse operation.

Return type:

ndarray[tuple[int, ...], dtype[Any]]