Skip to main content

The canon for pixel data topology. A cross-language specification to define the logical layout of images.

Project description

Pixel-Canon

PyPI Homepage | GitHub Repository | Specification


The canon for pixel data topology. A cross-language specification to define the logical layout of images (axis order, orientation, and memory order).

Pixel-Canon is a cross-language project aimed at solving a common and frustrating problem in computer vision, image processing, and machine learning: the ambiguity of image data layouts. When you receive an N-dimensional array, what do the axes mean? Is it (Height, Width, Channels) or (Channels, Height, Width)? Does the Y-axis point up or down?

This project provides a simple, declarative specification and a set of tools to describe this information explicitly, eliminating guesswork and making data pipelines more robust and reliable.

Python Implementation

This package contains the Python implementation of the Pixel-Canon spec.

Installation

pip install pixel-canon

To include support for numpy arrays:

pip install "pixel-canon[numpy]"

Quick Example

import numpy as np
from pixel_canon import CommonLayouts
from pixel_canon.backends.numpy_backend import convert_numpy

# Your image from a source like OpenCV
image_from_opencv = np.zeros((480, 640, 3), dtype=np.uint8)
layout_from_opencv = CommonLayouts.HWC_ROW_MAJOR_RGB

# The layout required by a library like PyTorch
layout_for_pytorch = CommonLayouts.CHW_ROW_MAJOR_RGB

# Convert the image layout safely and explicitly
prepared_image = convert_numpy(
    image_from_opencv,
    src=layout_from_opencv,
    dst=layout_for_pytorch
)

print(f"Original shape: {image_from_opencv.shape}")
print(f"Converted shape: {prepared_image.shape}")
# Original shape: (480, 640, 3)
# Converted shape: (3, 480, 640)

For full documentation, source code for other languages, and to contribute, please visit our main GitHub Repository.

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

pixel_canon-0.1.3.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

pixel_canon-0.1.3-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file pixel_canon-0.1.3.tar.gz.

File metadata

  • Download URL: pixel_canon-0.1.3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for pixel_canon-0.1.3.tar.gz
Algorithm Hash digest
SHA256 762cfb3090065384f78bef88bac35d99155ff7f9d57454b8a4c8cd13377ea760
MD5 662e1a46179ed7206550c8a4fd558659
BLAKE2b-256 9701ee6f52d1e5bc1fa2fef10d9b55edda59e5449c5f67585c5e65f9f90d4c38

See more details on using hashes here.

File details

Details for the file pixel_canon-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pixel_canon-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for pixel_canon-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 591e3154cd62e4d2dd6b196f88dff0dd84085b43d05d60afc11fc0c8f2be830f
MD5 b6c1cf1196e5fa5f2868135ea2ffe126
BLAKE2b-256 e58d1ed6b20134486b4de95c4586a632832f0b9bfab7af5b5a056d9a19ca5e19

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