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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hwc_chw_ndarray_conversion-0.1.0a0.tar.gz.
File metadata
- Download URL: hwc_chw_ndarray_conversion-0.1.0a0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac8c2553a114df73ffc753b707c4b8dd46b6e7f2b7997ec98679a1c802999add
|
|
| MD5 |
b2f61e6a29376f39d9f3a57eb6ab10d0
|
|
| BLAKE2b-256 |
0895f99263ef4cc357e4efe6b4dbd2146cdf58e6aa9913fc90176424807246a0
|
File details
Details for the file hwc_chw_ndarray_conversion-0.1.0a0-py2.py3-none-any.whl.
File metadata
- Download URL: hwc_chw_ndarray_conversion-0.1.0a0-py2.py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78c03c6521de22245e2949cb46c633c8936dd9b100f221dbbd15bc3bcf408784
|
|
| MD5 |
039bf119653e12eda71340df24375aa7
|
|
| BLAKE2b-256 |
e93be01f1864db2933740c86a851a5018590b390961fe1a79193e2ee716bb9dc
|