Skip to main content

Dithering algorithms for e-paper/e-ink displays

Project description

epaper-dithering

Dithering algorithms optimized for e-ink/e-paper displays with limited color palettes.

Installation

pip install epaper-dithering

Quick Start

from PIL import Image
from epaper_dithering import dither_image, ColorScheme, DitherMode

# Load your image
image = Image.open("photo.jpg")

# Apply dithering for a black/white/red display
dithered = dither_image(image, ColorScheme.BWR, DitherMode.FLOYD_STEINBERG)

# Save result
dithered.save("output.png")

Supported Color Schemes

  • MONO - Black and white (1-bit)
  • BWR - Black, white, red (3-color)
  • BWY - Black, white, yellow (3-color)
  • BWRY - Black, white, red, yellow (4-color)
  • BWGBRY - Black, white, green, blue, red, yellow (6-color Spectra)
  • GRAYSCALE_4 - 4-level grayscale

Dithering Algorithms

Algorithm Quality Speed Best For
NONE Lowest Fastest Testing, simple graphics
ORDERED Low Very Fast Patterns, textures
SIERRA_LITE Medium Fast Quick results
BURKES Good Medium General purpose (default)
FLOYD_STEINBERG Good Medium Popular standard
SIERRA High Medium Balanced quality
ATKINSON Good Medium High contrast, artistic
STUCKI Very High Slow Maximum quality
JARVIS_JUDICE_NINKE Highest Slowest Smooth gradients

Usage Examples

Basic Usage

from PIL import Image
from epaper_dithering import dither_image, ColorScheme, DitherMode

# Load image
img = Image.open("photo.jpg")

# Apply Floyd-Steinberg dithering for BWR display
result = dither_image(img, ColorScheme.BWR, DitherMode.FLOYD_STEINBERG)
result.save("dithered.png")

All Color Schemes

from epaper_dithering import ColorScheme

# Black and white only
dithered = dither_image(img, ColorScheme.MONO)

# Black, white, and red (common for e-paper tags)
dithered = dither_image(img, ColorScheme.BWR)

# Grayscale (4 levels)
dithered = dither_image(img, ColorScheme.GRAYSCALE_4)

# 6-color display (Spectra)
dithered = dither_image(img, ColorScheme.BWGBRY)

Development

# Install with dev dependencies
uv sync --all-extras

# Run tests
uv run pytest tests/ -v

# Run tests with coverage
uv run pytest tests/ --cov=src/epaper_dithering

# Lint
uv run ruff check src/ tests/

# Type check
uv run mypy src/epaper_dithering

Credits

Originally developed as part of py-opendisplay. Extracted to enable reuse across multiple e-paper display projects.

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

epaper_dithering-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

epaper_dithering-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for epaper_dithering-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3efd08de01f4284e380ed0d19e46fe306cbdd9dcd075a50538c99cd15ae279d1
MD5 4a831f8797e90fcd1c077ff19ee1d82e
BLAKE2b-256 a2745485e3a27721d39507c975ee34a75f3ce2df7e87361f4703dede6ade38ed

See more details on using hashes here.

Provenance

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

Publisher: release.yml on OpenDisplay-org/epaper-dithering

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

File details

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

File metadata

File hashes

Hashes for epaper_dithering-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 575af806a813f02d687123a5aeb2181af6e0d9f942194af053f4f7e3a93d2982
MD5 e29526c50caf50c9ed596547bde05cc4
BLAKE2b-256 4ea1b611811b3d62a97757c1f0a332e0386f4df36b1293bdd4880b9bbaae78fe

See more details on using hashes here.

Provenance

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

Publisher: release.yml on OpenDisplay-org/epaper-dithering

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