Skip to main content

Learn image processing by building it. A NumPy-based library that exposes both naive and optimized algorithms for side-by-side understanding.

Project description

Pixelate

Python 3.10+

Pixelate is an educational image processing library built to compare naive loop-based algorithms with their vectorized NumPy counterparts. Each operation has a slow and fast implementation so you can explore the performance and readability differences between the two styles.

Features

  • Pixel Operations: invert colors, convert to grayscale, and adjust brightness.
  • Geometric Transformations: horizontal flip and nearest-neighbor resize.
  • Convolution Filters for applying arbitrary kernels.
  • Utilities for loading and saving images via Pillow.
  • Ready-to-run benchmarks and tests demonstrating correctness and speed differences.

The modules are organized so that every function has a matching fast (vectorized) and slow (naive) version:

pixelate/
  fast/
    filters.py
    pixel_ops.py
    transformations.py
  slow/
    filters.py
    pixel_ops.py
    transformations.py
  utils/
    helpers.py
    image_io.py

Installation

Clone the repository and install the requirements:

pip install -r requirements.txt

You can also install the package directly:

pip install pixelate

The project requires Python 3.10 or newer.

Usage Example

import numpy as np
from pixelate.fast.pixel_ops import invert_color_fast
from pixelate.slow.pixel_ops import invert_color_slow
from pixelate.utils.image_io import load_image, save_image

img = load_image("path/to/image.png")

# Compare slow and fast implementations
slow_result = invert_color_slow(img)
fast_result = invert_color_fast(img)

save_image(fast_result, "out_fast.png")

Check the benchmarks/ folder for scripts that measure execution time for the slow and fast versions of each operation.

Running Tests

Use pytest to run the unit tests:

pytest

License

Pixelate is distributed under the MIT License. See the LICENSE file for details.

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

pixelatelib-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

pixelatelib-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pixelatelib-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for pixelatelib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 016c9b2d346b359cc341d5db61d3d7da6246591b583fc70da9c0959f575b0802
MD5 a0f41f0377eb4935cd99be4188ef853b
BLAKE2b-256 91e1540e015825b35f685a13c9cbaec74a394b308b5e72b42daf74e6f8df2f7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pixelatelib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.18

File hashes

Hashes for pixelatelib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05ca6d14f80fed7182d9197ab7fdc7950f26f480c7ecf0b19d1f732f1014acfe
MD5 6afd29fef30619c58fbee2094c8c8075
BLAKE2b-256 7381a4f41004e5353a81e25913602ff6bbab83e8b4411af2b90b5e34ac2f5014

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