Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

trim-hwc-ndarray

A simple utility for trimming borders from images represented as HWC ndarrays, based on the color value of a specified corner.

Features

  • Trim uniform borders from an HWC ndarray in which the border pixels match the color of a specified corner.
  • Flexible selection of which corner to use as the background color.
  • Preserves image channels and returns a trimmed copy.

Installation

pip install trim-hwc-ndarray

Usage

# coding=utf-8
from __future__ import print_function
from trim_hwc_ndarray import trim_hwc_ndarray, Corner
import numpy as np

# Example: Trim a border from a 3x3 RGB image
img = np.array([
    [[255, 255, 255], [255, 255, 255], [255, 255, 255]],
    [[255, 255, 255], [0, 0, 0], [255, 255, 255]],
    [[255, 255, 255], [255, 255, 255], [255, 255, 255]]
])
trimmed_img = trim_hwc_ndarray(img, Corner.TOP_LEFT)
print(trimmed_img.shape)  # Output: (1, 1, 3)

Contributing

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

License

This project is licensed under the MIT License.

Release files for trim-hwc-ndarray 0.1.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trim-hwc-ndarray 0.1.0a0
File Size Uploaded
trim_hwc_ndarray-0.1.0a0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trim-hwc-ndarray 0.1.0a0
File Interpreter ABI Platform
trim_hwc_ndarray-0.1.0a0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 7.0 kB

Release files / trim_hwc_ndarray-0.1.0a0.tar.gz

Download URL trim_hwc_ndarray-0.1.0a0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eb6b4467ddce95ed424bf3a8bb9a5c6d0665730e0b9cacbaf616e7d75651e3e1
BLAKE2b-256 checksum
How to use checksums
35ee340d494a8331d5c001ae750e3aa88d3ec066a5c25ff1af7188b61207f892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release files / trim_hwc_ndarray-0.1.0a0-py2.py3-none-any.whl

Download URL trim_hwc_ndarray-0.1.0a0-py2.py3-none-any.whl
Size 3.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
90ea1135b9a9621484a3309e2ed970ac336272e6cb2aa89449392a116bc8495d
BLAKE2b-256 checksum
How to use checksums
eb092b24715609f1725cd1ff86a474eff0c92a31db8637bc4514838327ff0a71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.0a0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page