Skip to main content

Interactive image and video sequence viewer

Project description

twxtools

twxtools is an interactive image and video sequence viewer built on top of matplotlib. It provides a convenient twx() function for quickly displaying, comparing, and navigating through images and video sequences in Python.

Features

  • Display single images or compare multiple images side-by-side
  • Navigate video sequences frame-by-frame with keyboard shortcuts
  • Automatic intensity range detection (with optional percentile clipping)
  • Support for grayscale and RGB data
  • Flexible data layout modes: HW, HWC, CHW, NHW, NHWC, NCHW
  • Interactive colormap switching
  • Accepts NumPy arrays, lists, tuples, or dicts

Installation

pip install twxtools

Quick Start

import numpy as np
from twxtools import twx

# Display a single grayscale image
img = np.random.rand(256, 256)
twx(img)

# Compare two images
img1 = np.random.rand(256, 256)
img2 = np.random.rand(256, 256)
twx([img1, img2])

# Display a grayscale video sequence (N x H x W)
video = np.random.rand(30, 256, 256)
twx(video)

# Use a dict to label images automatically
twx({'original': img1, 'processed': img2})

API Reference

twx(data, dataRange=[], cmap='gray', mode=None, titles=None)

Parameters:

Parameter Type Description
data ndarray, list, tuple, or dict Image(s) or video sequence(s) to display. Each item can be a NumPy array of up to 4 dimensions.
dataRange list Intensity range(s) for display. See details below.
cmap str Colormap for grayscale data (default: 'gray'). Ignored for RGB data.
mode str or None Dimension layout of the input data. Auto-detected if None.
titles list of str or None Labels for each input. Auto-generated as '1', '2', … if not provided. When data is a dict, keys are used as titles.

dataRange options

  • [] — use [min(data), max(data)]
  • [P] — use [percentile(data, P), percentile(data, 100-P)]
  • [low, high] — use the given fixed range

mode options

Mode Shape Description
'HW' H × W Grayscale image
'HWC' H × W × C RGB image (channels last)
'CHW' C × H × W RGB image (channels first)
'NHW' N × H × W Grayscale video sequence
'NHWC' N × H × W × C RGB video sequence (channels last)
'NCHW' N × C × H × W RGB video sequence (channels first)

If mode is not provided, it is auto-detected from the array shape.

Keyboard Controls

Key Action
19, 0 Switch to the corresponding input (1–10)
/ Previous / next frame in a video
a Toggle colorbar
m Cycle through colormaps

Requirements

License

MIT

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

twxtools-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

twxtools-0.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file twxtools-0.1.0.tar.gz.

File metadata

  • Download URL: twxtools-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for twxtools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42756e26a5cdf2c37b56521b57bfc6d2c3d2e1dcaba97e932f6d2f5670dde55b
MD5 2aeb08bed04e7f0289168cb5d7ccfb34
BLAKE2b-256 1bfd46468a0ee92976ff5c006c6c0c2b18c380cc3d42008c40c32da177e44eb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for twxtools-0.1.0.tar.gz:

Publisher: python-publish.yml on aram-danielyan/twx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file twxtools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: twxtools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for twxtools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d2a0e498a0e2f12fe6bf34e2a040ae165d2289b20a9fef4bea573bf1196cb8d
MD5 e27380bfacc79955eac710e42634c982
BLAKE2b-256 e64b34f97244db1f96061ddef41d3d688405b31512df43b832cb04950b94d96d

See more details on using hashes here.

Provenance

The following attestation bundles were made for twxtools-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on aram-danielyan/twx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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