plenoptic.process.polar_to_rectangular_dict#

plenoptic.process.polar_to_rectangular_dict(energy, state)[source]#

Return the real and imaginary parts of tensor in a dictionary.

Keys in the output are identical to those in the input. Will grab residuals from energy, if present, with keys "residual_highpass" and "residual_lowpass".

Parameters:
  • energy (dict) – The dictionary of torch.Tensor containing the local complex amplitude.

  • state (dict) – The dictionary of torch.Tensor containing the local phase.

Return type:

dict

Returns:

coeff_dict – A dictionary containing complex tensors of coefficients.

See also

polar_to_rectangular

Same operation on tensors.

rectangular_to_polar_dict

The inverse operation.

local_gain_release_dict

The analogous function for real-valued signals.

Examples

>>> import plenoptic as po
>>> import numpy as np
>>> import torch
>>> img = po.data.einstein()
>>> spyr = po.process.SteerablePyramidFreq(
...     img.shape[-2:], is_complex=True, height=3
... )
>>> coeffs = spyr(img)
>>> energy, state = po.process.rectangular_to_polar_dict(coeffs, residuals=True)
>>> coeffs_back = po.process.polar_to_rectangular_dict(energy, state)
>>> all(torch.allclose(coeffs[key], coeffs_back[key]) for key in coeffs)
True
>>> po.plot.pyrshow(coeffs_back)
<PyrFigure size ...>

(png, hires.png, pdf)

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