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 oftorch.Tensorcontaining the local complex amplitude.state (
dict) – The dictionary oftorch.Tensorcontaining the local phase.
- Return type:
- Returns:
coeff_dict – A dictionary containing complex tensors of coefficients.
See also
polar_to_rectangularSame operation on tensors.
rectangular_to_polar_dictThe inverse operation.
local_gain_release_dictThe 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 ...>