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 avaialble 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.0.0.tar.gz (55.4 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.0.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ti_plm-1.0.0.tar.gz
  • Upload date:
  • Size: 55.4 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.0.0.tar.gz
Algorithm Hash digest
SHA256 b28efd45c8b1b59ece054c0597045439fe45642bfca4ede2643b8c966810bfb4
MD5 17a48e77ca0d795c385183e271c83659
BLAKE2b-256 3e6e1377680df6e241de4657e147846222bf5f82e7b5bc88804d4e366e3194db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ti_plm-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3c54f3d718304ffdd46566de96ab80182b78601e936d830415fa90a5ed40c65
MD5 526dbc8eedc3f5e653c96bcd8c00249b
BLAKE2b-256 f7c84ad91c8d3d917287172705954be1c3bdebce2bebde4e64447e67e0022a86

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