Skip to main content

Explicit, contiguous HWC <-> CHW ndarray conversion.

Project description

hwc-chw-ndarray-conversion

Explicit, contiguous HWC <-> CHW ndarray conversion.

Usage

# coding=utf-8
import numpy as np
from hwc_chw_ndarray_conversion import (
    hwc_ndarray_to_chw_ndarray,
    chw_ndarray_to_hwc_ndarray
)

# An example image in HWC layout
hwc_ndarray = np.random.rand(64, 128, 10)  # shape: (height, width, channel)

# Convert to CHW layout
chw_ndarray = hwc_ndarray_to_chw_ndarray(hwc_ndarray)  # shape: (channel, height, width)
assert chw_ndarray.flags.c_contiguous

# Convert back to HWC layout
assert np.array_equal(chw_ndarray_to_hwc_ndarray(chw_ndarray), hwc_ndarray)

Installation

pip install hwc-chw-ndarray-conversion

Why this package?

Many libraries assume or demand a specific image channel ordering. hwc-chw-ndarray-conversion makes these assumptions explicit and self-documenting while providing best-practice array interop: always contiguous, always unambiguous.

Contributing

Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.

License

This project is licensed under the MIT License.

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

hwc_chw_ndarray_conversion-0.1.0a0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

hwc_chw_ndarray_conversion-0.1.0a0-py2.py3-none-any.whl (3.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file hwc_chw_ndarray_conversion-0.1.0a0.tar.gz.

File metadata

File hashes

Hashes for hwc_chw_ndarray_conversion-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 ac8c2553a114df73ffc753b707c4b8dd46b6e7f2b7997ec98679a1c802999add
MD5 b2f61e6a29376f39d9f3a57eb6ab10d0
BLAKE2b-256 0895f99263ef4cc357e4efe6b4dbd2146cdf58e6aa9913fc90176424807246a0

See more details on using hashes here.

File details

Details for the file hwc_chw_ndarray_conversion-0.1.0a0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for hwc_chw_ndarray_conversion-0.1.0a0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 78c03c6521de22245e2949cb46c633c8936dd9b100f221dbbd15bc3bcf408784
MD5 039bf119653e12eda71340df24375aa7
BLAKE2b-256 e93be01f1864db2933740c86a851a5018590b390961fe1a79193e2ee716bb9dc

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