A very simple implementation of Bresenham algorithm implementations
Project description
Simple Bresenham implementation
This is a very simple Bresenham implementation for enumerating pixels along a line including a very simple anti aliased version. It's the felt infinite implementation out there and has been implemented during enhancement of a tomography reconstruction library for personal use.
Dependencies
numpy >= 1.25
Installation
pip install pybresenham-tspspi
Usage
Simple lines
import matplotlib.pyplot as plt
import numpy as np
from bresenham import trace_line
fig, ax = plt.subplots()
img = np.zeros((51, 21))
for pt in trace_line((-25,-10),(10,10)):
img[int(pt[0]) + 25, int(pt[1]) + 10] = 1
ax.imshow(img)
Simple lines using callbacks
from bresenham import trace_line
def mycallback(point):
print(f"Point at {point[0]} x {point[1]}")
trace_line((-25,-10),(10,10),mycallback)
Antialiased lines
import matplotlib.pyplot as plt
import numpy as np
from bresenham import trace_line_antialiased_it
fig, ax = plt.subplots()
imgaa = np.zeros((51, 21))
for pt, weight in trace_line_antialiased_it((-25,-10),(10,10)):
imgaa[int(pt[0]) + 25, int(pt[1]) + 10] = weight
ax.imshow(imgaa)
Antialiased lines using callbacks
from bresenham import trace_line_antialiased
def mycallback(point, weight):
print(f"Point at {point[0]} x {point[1]} with weight {weight}")
trace_line_antialiased((-25,-10),(10,10),mycallback)
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
File details
Details for the file pybresenham-tspspi-0.0.1.tar.gz
.
File metadata
- Download URL: pybresenham-tspspi-0.0.1.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8654b4da7c59d42714362d1500c6834873854cba1543cd04d3b50d8150b9b244 |
|
MD5 | 800f930b66bc01c1ab26c422b9884588 |
|
BLAKE2b-256 | a8d62e7e74b25ab3d2e10d7843746a4870e2a22083b376468e96521802c45776 |
File details
Details for the file pybresenham_tspspi-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pybresenham_tspspi-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e3b1dc4bf30030ca388b9a85cc0965e2151d00367823635286e882f1069c17a |
|
MD5 | ec241ca0c7ec15bc4de7532ce105b635 |
|
BLAKE2b-256 | 4a9afe53dc822f11d22011b018f8f4505e9be96504117e2375525efbc4e9a03b |