Auto Stretch
Automatically stretch linear astronomical images for easy visualization.
Auto Stretch applies a PixInsight-style Screen Transfer Function (STF) midtones transfer to linear astronomical images stored as numpy arrays. It automatically computes the optimal stretch parameters from the image data so that faint detail becomes visible without manual histogram adjustment.
| linear (no stretch) | arcsin stretch | auto-stretch (using this library) |
|---|---|---|
Installation
pip install auto-stretch
Quickstart
import numpy as np
from auto_stretch import apply_stretch, Stretch
image = np.array([[0.1, 0.25], [0.8, 0.3]], dtype=np.float64)
stretched = apply_stretch(image)
# or with custom parameters:
stretched = Stretch(target_bkg=0.25, shadows_clip=-1.25).stretch(image)
Input contract
- Input must be a 2D numpy array. 1D and 3D arrays raise
ValueError. - Input is coerced to float64 internally; the caller's array is never mutated.
- NaN pixels propagate through the stretch unchanged.
- Output is float64 with values clamped to
[0, 1].
Parameters
| Parameter | Default | Description |
|---|---|---|
target_bkg |
0.25 | Target median brightness after stretch |
shadows_clip |
-1.25 | Shadow clipping point in units of median absolute deviation below the median |
The underlying algorithm follows the PixInsight Histogram Transformation STF method.
Dependencies
- Python >= 3.10
- numpy >= 1.20
Credit
Based on the PixInsight Screen Transfer Function (STF) algorithm developed by Pleiades Astrophoto.
License
MIT — see LICENSE.
Release files for auto-stretch 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| auto_stretch-1.1.0.tar.gz | 1.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| auto_stretch-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / auto_stretch-1.1.0.tar.gz
| Download URL | auto_stretch-1.1.0.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8c91dbb1c32914d64f9ec065df5abe274f9b5f707f4497deba8fcb05acc4ab9
|
|
BLAKE2b-256 checksum How to use checksums |
577a7a44e43ef7e76cc186ae8cc7792978eeac31e272386c7bc617c231999a20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.
Transparency logRelease files / auto_stretch-1.1.0-py3-none-any.whl
| Download URL | auto_stretch-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5029de2771f5de667a6663c4f21ac7d1fc8c6d23e4293789892955651dbca4e4
|
|
BLAKE2b-256 checksum How to use checksums |
4d16af03a65d260bd3d8634d8e3bb6423cbae5b9c52f4b9709611d2592177da4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.
Transparency log