Skip to main content

Easy TI PLM data formatting and phase processing in Python

Project description

TI PLM (Phase Light Modulator)

Easy TI PLM data formatting and phase processing in Python.

This library provides utilities designed to make it easy to work with TI PLM technology. It addresses challenges associated with:

  • PLM device parameters (resolution, phase displacements, bit layout, etc.) - See PLM database
  • Formatting phase data correctly for different TI PLM devices (quantization, bit packing, data flip, etc.)
  • Displaying CGHs on PLM EVMs over external video (HDMI, DP)

Installation

Recommended: use conda, venv, uv, etc. to set up a dedicated Python environment to avoid dependency conflicts.

  • pip install ti-plm
    • Core functionality only
  • pip install "ti-plm[display]"
    • Installs optional dependencies needed by display module (pygame, screeninfo, pillow, etc.)

Usage

This library provides a PLM class that keeps track of PLM device parameters and provides functions to process data in a way specific to that device. PLM functions support n-dimensional arrays by default, as long as the last 2 dimensions are rows, columns. This means you can easily and efficiently process phase data for RGB images (color channel being the outermost dimension), or time-series data (time being the outermost dimension).

from ti_plm import PLM

# Typically PLM parameters will be loaded from the database
print(PLM.get_device_list())  # print a list of all available devices in the database
plm = PLM.from_db('p67')  # load p67 data from database into a new `plm` object

# Alternatively, PLM parameters can be specified manually
# See PLM class documentation for required parameters,
# or look at example json files in src/ti_plm/db
plm = PLM(
    name=...,
    shape=...,
    pitch=...,
    displacement_ratios=...,
    memory_lut=...,
    electrode_layout=...,
    data_flip=...
)

# Once the plm object is instantiated, you can use its class methods to process phase data
# This will take care of quantizing to appropriate displacement levels and mapping data to
# the electrode layout specific to this device. In this case phase_map would contain floating
# point phase data between 0 and 2pi
bmp = plm.process_phase_map(phase_map)

# This process can also be broken down into individual steps:
# 1. Quantize continuous phase data into buckets corresponding to available mirror levels
state_index = plm.quantize(phase_map)
# 2. Map state_index values to electrodes
bmp = plm.electrode_map(state_index)
# 3. Replicate bits across the full 8 bits of the bmp
bmp *= 255

# If phase_map data has additional dimensions for color channel or time-series, make sure the last
# 2 dimensions are rows, columns. See examples/p67.py for a demo of this.

See examples and tests for more usage examples.

CLI

A simple CLI is included in this library that wraps the display module to enable image display from the command line. After installing the library with display dependencies, you can run ti_plm display <path/to/image> on your command line to render images fullscreen on an external monitor. For full usage information, run ti_plm display --help.

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

ti_plm-1.1.0.tar.gz (56.0 kB view details)

Uploaded Source

Built Distribution

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

ti_plm-1.1.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file ti_plm-1.1.0.tar.gz.

File metadata

  • Download URL: ti_plm-1.1.0.tar.gz
  • Upload date:
  • Size: 56.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for ti_plm-1.1.0.tar.gz
Algorithm Hash digest
SHA256 c72d27b5ed6671af0a63d400ec0676af8c323e9029d57a86982d036ff8795782
MD5 2b92c36e5c3d7c8f08d593e1f1ccca05
BLAKE2b-256 56bca6ff4dac97c601b76739fea2ce7f169c2b39ab32e7c6cf91f4a03b14211c

See more details on using hashes here.

File details

Details for the file ti_plm-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: ti_plm-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for ti_plm-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68c6f7fb705aeab2e814658bc14dbfdda6fe1562198d1f9e352b743ed2024795
MD5 6e21eb3a182d77cb6c6905c89f0da885
BLAKE2b-256 81358c07b9a72726fbf8268b296c42afc120afd432efb39a4b6e329f599320ce

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