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.1.tar.gz (11.7 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.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for twxtools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 794d39cf54b4941fbad93d8a1480b699d3da674b95e62f25b837de4e3e69e10f
MD5 73891da59a2dc8c9e3ec2c2e7c58c338
BLAKE2b-256 be3238ca68ab3f1bfa490efc4a8bd6ac7dbf9b70839186d7c7c1bcca47aff902

See more details on using hashes here.

Provenance

The following attestation bundles were made for twxtools-0.1.1.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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for twxtools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0016cce3c78b93bf9a582bdd49799a75b7a6c51829812b63bd242246b17bd3c
MD5 e20a0afd3f308e3e18703523a6febfef
BLAKE2b-256 c8977383e9e06c455e86385cdf0d4932e9ba26e0a3783111fca1544931799ab6

See more details on using hashes here.

Provenance

The following attestation bundles were made for twxtools-0.1.1-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