plenoptic.process.local_gain_control#

plenoptic.process.local_gain_control(x, epsilon=1e-08)[source]#

Spatially local gain control.

Compute the local energy and phase of a real-valued tensor.

Parameters:
  • x (Tensor) – Tensor of shape (batch, channel, height, width) or (batch, channel, angle, height, width).

  • epsilon (float (default: 1e-08)) – Small constant to avoid division by zero.

Return type:

tuple[Tensor, Tensor]

Returns:

  • norm – The local energy of x, shape (batch, channel, height/2, width/2) or (batch, channel, angle, height/2, width/2), depending on dimensionality of x.

  • direction – The local phase of x (a.k.a. local unit vector, or local state), shape (batch, channel, height, width) or (batch, channel, angle, height, width), depending on dimensionality of x.

Raises:

ValueError – If x does not have 4 or 5 dimensions.

See also

local_gain_control_dict

Same operation on dictionaries.

local_gain_release

The inverse operation.

rectangular_to_polar

The analogous function for complex-valued signals.

Notes

Norm and direction (analogous to complex amplitude and phase) are defined using blurring operator and division. Indeed blurring the responses removes high frequencies introduced by the squaring operation. In the complex case adding the quadrature pair response has the same effect (note that this is most clearly seen in the frequency domain). Here computing the direction (phase) reduces to dividing out the norm (amplitude), indeed the signal only has one real component. This is a normalization operation (local unit vector), hence the connection to local gain control.

Examples

>>> import plenoptic as po
>>> img = po.data.einstein()
>>> norm, direction = po.process.local_gain_control(img)
>>> po.plot.imshow([img, norm, direction], title=["image", "norm", "direction"])
<PyrFigure size ...>

(png, hires.png, pdf)

../../_images/plenoptic-process-local_gain_control-1.png