Skip to main content

poisson disk implementation in python

Project description

https://img.shields.io/pypi/v/poisson-d.svg

Poisson disk implementation in python

  • Free software: MIT license

Features

  • Generate poisson disk coordinates on a grid

  • Generate points with charactoristics of poisson disk from an image

  • Generate points with charactoristics of poisson disk from CMYK channels of an image

Usage examples

  • Use poisson-d module, from Grasshoper Python Script Component, to generate points of poisson disk

# requirements: poisson-d==latest
import rhinoscriptsyntax as rs
import imageio.v3 as iio
from poisson_d import poisson_d as p

# remove the follow two lines if you want take these two parameters as input variables
max_points = 30000
white_threshold = 0.8

# input variables: img_path, radius_min, radius_max
# output variables: coordinates (list of Point3D), greys (list of floats)

image = iio.imread(img_path)

result = p.poisson_d_variant(
    img=image,
    radius_min_max=(radius_min, radius_max),
    max_points=max_points,
)

print(f"generated {len(result)} points")

result = p.filter_out_white(result, white_threshold)

coordinates = [rs.CreatePoint(pn.x, -pn.y, 0) for pn in result]
greys = [x.grey for x in result]
  • Use poisson-d module, from Grasshoper Python Script Component, to generate points of poisson disk on C, M, Y, K channels

# requirements: poisson-d==latest
import rhinoscriptsyntax as rs
import imageio.v3 as iio
from poisson_d import poisson_d as p

# remove the follow two lines if you want take these two parameters as input variables
max_points = 30000
white_threshold = 0.9

# input variables: img_path, radius_min, radius_max
# output variables: c_points, m_points, y_points, k_points for coordinates; c, m, y, k for greyscales

image = iio.imread(img_path)

((c_points, m_points, y_points, k_points), (c, m, y, k)) = poisson_d_cmyk(
    img=image,
    r=(radius_min, radius_max),
    cnt=max_points,
    th=white_threshold,
)
  • Generate points of poisson disk from an image

install the poisson-d module

python3 -m pip install poisson-d --upgrade

now generate an image

python3 -m poisson_d.cli image --image input/sample.png
  • Generate points of poisson disk in text format, from an image

python3 -m poisson_d.cli points --image input/sample.png

Credits

This package was initialized with Cookiecutter.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poisson_d-0.5.0.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

poisson_d-0.5.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file poisson_d-0.5.0.tar.gz.

File metadata

  • Download URL: poisson_d-0.5.0.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for poisson_d-0.5.0.tar.gz
Algorithm Hash digest
SHA256 6c778e7016b0147b065aefd8d7da91a4697472a12dd7df1d11359322f47ca554
MD5 7b2405ed286d8b0ed606ed0278793950
BLAKE2b-256 f83fa0c9a34cc46215a44939e8abcbe1a4e84888ac35b1518a86fdbc9c13c479

See more details on using hashes here.

File details

Details for the file poisson_d-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: poisson_d-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for poisson_d-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfe8f5233b5da5eff3f1db8c5fe2db9fd9397b74a30d32c122cb5914f2d3a96b
MD5 8ca6a0e3f21a3e05987866f538741a01
BLAKE2b-256 b935d33b47b76af43440c1e3d9fb376575895be3b489eb57da5419c9a41e5c0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page