File: spectrum2d_unit_test.py

package info (click to toggle)
python-sigima 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 25,608 kB
  • sloc: python: 35,251; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file.

"""
Image spectrum unit test.
"""

# pylint: disable=invalid-name  # Allows short reference names like x, y, ...
# pylint: disable=duplicate-code

import pytest

import sigima.tools.image
from sigima.tests import guiutils
from sigima.tests.data import get_test_image


@pytest.mark.gui
def test_image_spectrum_interactive():
    """Interactive test of the magnitude/phase/power spectrum of an image."""
    with guiutils.lazy_qt_app_context(force=True):
        # pylint: disable=import-outside-toplevel
        from sigima.viz import view_images_side_by_side

        obj = get_test_image("NF 180338201.scor-data")
        data = obj.data
        ms = sigima.tools.image.magnitude_spectrum(data, log_scale=True)
        ps = sigima.tools.image.phase_spectrum(data)
        psd = sigima.tools.image.psd(data, log_scale=True)
        images = [data, ms, ps, psd]
        titles = [
            "Original",
            "Magnitude spectrum",
            "Phase spectrum",
            "Power spectral density",
        ]
        view_images_side_by_side(images, titles, rows=2, title="Image spectrum")


if __name__ == "__main__":
    test_image_spectrum_interactive()