JAX implementation of the probabilistic Hough transform for lines
Project description
JAX implementation of probabilistic_hough_line
This is a JAX implementation of the skimage.transform.probabilistic_hough_line function.
Installation
uv add hough-jax
or if you don't have uv:
pip install hough-jax
Usage
import jax
import jax.numpy as jnp
import numpy as np
from hough_jax import probabilistic_hough_line
# Create a simple image with a horizontal line
image = np.zeros((100, 100), dtype=np.float32)
image[50, 20:80] = 1.0
# Detect lines
lines, nlines = probabilistic_hough_line(
jnp.array(image),
threshold=10,
line_length=30,
line_gap=3,
rng=jax.random.PRNGKey(0),
)
# lines: Array of shape (lines_max, 2, 2) with endpoints [[x0, y0], [x1, y1]]
# nlines: Number of valid lines detected
print(f"Detected {int(nlines)} line(s)")
print(f"First line endpoints: {lines[0]}")
Converting to skimage format
To get the same output format as skimage.transform.probabilistic_hough_line:
def to_skimage_format(lines, nlines):
"""Convert JAX output to list of ((x0, y0), (x1, y1)) tuples."""
n = int(nlines)
return [
((int(lines[i, 0, 0]), int(lines[i, 0, 1])), (int(lines[i, 1, 0]), int(lines[i, 1, 1])))
for i in range(n)
]
skimage_lines = to_skimage_format(lines, nlines)
# [((79, 50), (20, 50))]
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
hough_jax-0.2.tar.gz
(42.8 kB
view details)
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 hough_jax-0.2.tar.gz.
File metadata
- Download URL: hough_jax-0.2.tar.gz
- Upload date:
- Size: 42.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d5c013c201ebff4f334046124f8378bcc10bbae194d17777365e1525e61fa82
|
|
| MD5 |
4cc3a902f70b97978b0256485e755a04
|
|
| BLAKE2b-256 |
7a196a40e1b2a5d3513d5b1131fec6f00c35a1496bfac642fffc1db23019baf7
|
File details
Details for the file hough_jax-0.2-py3-none-any.whl.
File metadata
- Download URL: hough_jax-0.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d6738f191c52fc919cc10e09a4c3eec662820062393613466adc4ee0d7bc36f
|
|
| MD5 |
fcb110db60016b422acad635450bd92f
|
|
| BLAKE2b-256 |
13679b242eb72e9529d76a5d56a09e199347086e7a4116bdbeb5e001010d53b0
|