Context
sigima/tools/image/fourier.py converts spectra to decibels using an absolute floor:
# magnitude_spectrum (line ~80)
z1 = 20 * np.log10(z1.clip(1e-10))
# psd (line ~110)
z1 = 10 * np.log10(z1.clip(1e-10))
The 1D path (sigima/tools/signal/fourier.py) used the same approach until #50 replaced it with a peak-relative floor (_to_decibel), set at the machine epsilon of the maximum value, i.e. about 313 dB below the peak for the amplitude convention. The two paths are therefore now inconsistent.
Problem
An absolute floor makes the logarithmic scale dependent on the physical unit of the image, whereas the decibel is by nature a relative quantity:
- The same image expressed in volts and in millivolts does not yield the same dB spectrum — not merely offset by a constant, but different in shape, because the floor does not clip the same spectral lines.
- For a low-amplitude image (all
|FFT| values below 1e-10), the whole spectrum collapses onto the floor: the result is a uniformly flat image at −200 dB, carrying no information at all.
- Conversely, for a high-amplitude image the floor is so far down that it no longer acts as a guard: an exactly null spectral line is still clipped to −200 dB, an arbitrary value that then propagates to autoscaling and statistics.
Proposed fix
Reuse the _to_decibel logic introduced on the 1D side: floor at peak * np.finfo(float).eps.
To be decided at implementation time:
- factor the helper into a module shared by both paths, or duplicate it on the image side;
- the desired behaviour when the spectrum is identically zero (the 1D implementation returns
-inf, which is questionable for an image meant to be displayed).
Impact
⚠️ Visible change in results. Image spectra in logarithmic scale change (only the clipped lines). Linear-scale spectra are unaffected. To be handled like the other numerical fixes of 1.1.6: explicit release note.
Origin
Found during the pre-1.1.6 audit, deliberately left out of the scope of #50 because it changes published 2D values.
Context
sigima/tools/image/fourier.pyconverts spectra to decibels using an absolute floor:The 1D path (
sigima/tools/signal/fourier.py) used the same approach until #50 replaced it with a peak-relative floor (_to_decibel), set at the machine epsilon of the maximum value, i.e. about 313 dB below the peak for the amplitude convention. The two paths are therefore now inconsistent.Problem
An absolute floor makes the logarithmic scale dependent on the physical unit of the image, whereas the decibel is by nature a relative quantity:
|FFT|values below1e-10), the whole spectrum collapses onto the floor: the result is a uniformly flat image at −200 dB, carrying no information at all.Proposed fix
Reuse the
_to_decibellogic introduced on the 1D side: floor atpeak * np.finfo(float).eps.To be decided at implementation time:
-inf, which is questionable for an image meant to be displayed).Impact
Origin
Found during the pre-1.1.6 audit, deliberately left out of the scope of #50 because it changes published 2D values.