Skip to main content

A lightweight NumPy array image viewer for Spyder

Project description

Spyder Image Viewer Plugin

A lightweight image viewer plugin for Spyder focused on fast NumPy array inspection.

Notice

This plugin was generated almost entirely (nearly 100%) with GitHub Copilot.

Highlights

  • Fast rendering at high zoom levels using viewport-only drawing.
  • Docked viewer integrated with Spyder Variable Explorer.
  • Optional popup viewers from Variable Explorer context menu.
  • Nearest-neighbor scaling (no blur) for pixel-accurate inspection.
  • Zoom range from 10% to 3000%.
  • Pixel grid and value overlay at 3000% (Show Pixels).
  • Hover tooltip with coordinate and value/intensity.
  • Channel selector for 3D images (full, or per-channel grayscale view).

Supported Input

The plugin accepts NumPy arrays with:

  • H x W (2D)
  • H x W x C (3D, C >= 1)

There is no fixed channel-count restriction in 3D mode. For example, H x W x 10 is supported.

Accepted dtypes include integer and floating-point arrays. Arrays are normalized to uint8 for display.

Float normalization behavior:

  • [0, 1] -> scaled to [0, 255]
  • [0, 255] -> used as-is
  • other ranges -> min-max normalized to [0, 255]

Requirements

  • Python >= 3.7
  • Spyder >= 5.0
  • NumPy >= 1.19
  • QtPy >= 2.0

Installation

Option 1: Install from PyPI (recommended)

pip install spyder-image-viewer

After installation, restart Spyder to load the plugin.

Option 2: Editable install (for local development)

cd spyder_image_viewer
pip install -e .

This allows you to edit the source code and see changes reflected immediately.

Option 3: Standard install from source

cd spyder_image_viewer
pip install .

Verify installation

After installation, restart Spyder and check:

Tools → Preferences → Plugins

Confirm Image Viewer is listed and enabled.

Usage

  1. Start Spyder.
  2. Create an image-like NumPy array:
import numpy as np

img = np.random.randint(0, 256, (1080, 1920, 3), dtype=np.uint8)
  1. In Variable Explorer, select img.
  2. The image appears in the Image Viewer dock.

You can also right-click a variable and choose Open in Image Viewer to open an independent popup window.

Controls

  • Zoom slider: 10% to 3000%
  • Mouse wheel: normal scrolling
  • Ctrl + wheel: nonlinear zoom
  • Zoom anchor: cursor-centered when over image, otherwise viewport-centered
  • Show Pixels: jump to 3000% temporarily and restore previous zoom when toggled off
  • Channel combo (3D images):
    • full shows color image
    • numeric channels show single-channel grayscale

Pixel Overlay and Tooltip

At 3000%, the viewer can render:

  • pixel grid
  • per-pixel values (in single-channel mode)

Hover tooltip:

  • Coord: (x, y)
  • Intensity: ... for scalar views
  • Value: (...) for multi-channel views

Project Structure

spyder_image_viewer/
├── setup.py
├── setup.cfg
├── README.md
├── README.ja.md
├── docs/
│   ├── quickstart.md
│   ├── development_guide.md
│   └── ja/
│       ├── quickstart.ja.md
│       └── development_guide.ja.md
├── spyder_image_viewer/
│   ├── plugin.py
│   ├── widgets/
│   │   └── image_viewer.py
│   └── utils/
│       └── array_validator.py
└── tests/
    └── manual_test_image_viewer.py

Development

Run the test script:

python tests/manual_test_image_viewer.py

Or in a Spyder console:

exec(open('tests/manual_test_image_viewer.py').read())

Troubleshooting

Plugin not found

  1. Reinstall in editable mode:
pip uninstall spyder-image-viewer
pip install -e .
  1. Restart Spyder completely.

  2. If needed, clear Spyder cache:

rm -rf ~/.spyder-py3/

Dock is hidden

Open in Spyder:

View → Docks → Image Viewer

"Not a valid image array"

Verify array shape:

from spyder_image_viewer.utils import is_image_array
print(is_image_array(your_array))

Supported shapes:

  • 2D: (H, W)
  • 3D: (H, W, C) where C >= 1

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spyder_image_viewer-0.1.2.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spyder_image_viewer-0.1.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file spyder_image_viewer-0.1.2.tar.gz.

File metadata

  • Download URL: spyder_image_viewer-0.1.2.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for spyder_image_viewer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b6dfbe51fa4c8df10dbf1f604b8910cfbc25450c367fa62cb94bf6e2e5e6c1e5
MD5 ad77f3ded3b58552e0041edaa7f0cd60
BLAKE2b-256 45c07776be592885bb28762ac699298cf5830980382c63ddde99c9770a9ed309

See more details on using hashes here.

File details

Details for the file spyder_image_viewer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for spyder_image_viewer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bb5b3e3b71e77456b72e10a5191145eef43202e12b18a6e55ebfbf26ff6bb769
MD5 3d2a1439a39ca2a61050833ec845629a
BLAKE2b-256 f4dfa8eed8156497dab3182b4149d9409b78e8cdb0d241f4273d9df94d265d01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page