Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Image FFT decibel floor is absolute (1e-10) instead of peak-relative #52

Copy link
Copy link

Description

@PierreRaybaut
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.