A minimal Line Integral Convolution extension for NumPy, written in Rust
Project description
rLIC
Line Integral Convolution for Python, written in Rust
rLIC (pronounced 'relic') is a highly optimized, minimal implementation of the
Line Integral
Convolution algorithm
for in-memory numpy arrays, written in Rust.
Development status
rLIC is currently in beta. As of version 0.5.0, the only public API,
rlic.convolve, is considered feature complete and stable. However, minor
behavior changes may still happen, particularly where performance can be
improved as a result. The library as a whole may still grow additional APIs,
which wouldn't immediately be marked as stable.
Free-threading support
rlic.convolve is trivially thread-safe, because it does not mutate any external
data. As of version 0.5.1, Wheels are not yet distributed for free-threaded
CPython, but this build target is still supported and tested.
Installation
python -m pip install rLIC
Examples
rLIC consists in a single Python function, rlic.convolve, that convolves a
texture image (usually noise) with a 2D vector field described by its
components u and v, via a 1D kernel array. The result is an image where
pixel intensity is strongly correlated along field lines.
Let's see an example. We'll use matplotlib to visualize inputs and outputs.
import matplotlib.pyplot as plt
import numpy as np
import rlic
SHAPE = NX, NY = (256, 256)
prng = np.random.default_rng(0)
texture = prng.random(SHAPE)
x = np.linspace(0, np.pi, NY)
U = np.broadcast_to(np.cos(2 * x), SHAPE)
V = np.broadcast_to(np.sin(x).T, SHAPE)
fig, axs = plt.subplots(ncols=2, sharex=True, sharey=True, figsize=(10, 5))
for ax in axs:
ax.set(aspect="equal", xticks=[], yticks=[])
ax = axs[0]
ax.set_title("Input texture (noise)")
ax.imshow(texture)
ax = axs[1]
ax.set_title("Input vector field")
Y, X = np.mgrid[0:NY, 0:NX]
ax.streamplot(X, Y, U, V)
Now let's compute some convolutions, varying the number of iterations
kernel = 1 - np.abs(np.linspace(-1, 1, 65))
fig_out, axs_out = plt.subplots(ncols=3, figsize=(15, 5))
for ax in axs_out:
ax.set(aspect="equal", xticks=[], yticks=[])
for n, ax in zip((1, 5, 100), axs_out, strict=True):
image = rlic.convolve(
texture,
U,
V,
kernel=kernel,
boundaries="periodic",
iterations=n,
)
ax.set_title(f"Convolution result ({n} iteration(s))")
ax.imshow(image)
Polarization mode
By default, the direction of the vector field affects the result. That is, the
sign of each component matters. Such a vector field is analogous to a velocity
field. However, the sign of u or v may sometimes be irrelevant, and only
their absolute directions should be taken into account. Such a vector field is
analogous to a polarization field. rLIC supports this use case via an
additional keyword argument, uv_mode, which can be either 'velocity'
(default), or 'polarization'. In practice, the difference between these two
modes in only visible around sharps changes in sign in either u or v, and
with certain kernels.
Let's illustrate one such case
import matplotlib.pyplot as plt
import numpy as np
import rlic
SHAPE = NX, NY = (256, 256)
prng = np.random.default_rng(0)
texture = prng.random(SHAPE)
kernel = 1 - np.abs(np.linspace(-1, 1, 65, dtype="float64"))
U0 = np.ones(SHAPE)
ii = np.broadcast_to(np.arange(NX), SHAPE)
U = np.where(ii<NX/2, -U0, U0)
V = np.zeros((NX, NX))
fig, axs = plt.subplots(ncols=3, sharex=True, sharey=True, figsize=(15, 5))
for ax in axs:
ax.set(aspect="equal", xticks=[], yticks=[])
ax = axs[0]
ax.set_title("Input vector field")
Y, X = np.mgrid[0:NY, 0:NX]
ax.streamplot(X, Y, U, V)
for uv_mode, ax in zip(("velocity", "polarization"), axs[1:], strict=True):
image = rlic.convolve(
texture,
U,
V,
kernel=kernel,
uv_mode=uv_mode,
boundaries={"x": "periodic", "y": "closed"},
)
ax.set_title(f"{uv_mode=!r}")
ax.imshow(image)
Memory Usage
rLIC.convolve allocates exactly two buffers with the same size as texture,
u and v, regardless of the number of iterations performed, one of which is
discarded when the function returns. This means that peak usage is about 5/3 of
the amount needed to hold input data in memory, and usage drops to 4/3 on
return.
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 Distributions
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 rlic-0.5.3.tar.gz.
File metadata
- Download URL: rlic-0.5.3.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5a249df38d3cf9203a6cd5ff4e585db1a2c95ea0e2e5f8365025f348ada96e9
|
|
| MD5 |
3b4d361166024a900bb69c9367d4c520
|
|
| BLAKE2b-256 |
fc9a7c37806970a53e3421f5929a68b60567424ee9685e99c07a7edfc1ff61ea
|
Provenance
The following attestation bundles were made for rlic-0.5.3.tar.gz:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3.tar.gz -
Subject digest:
a5a249df38d3cf9203a6cd5ff4e585db1a2c95ea0e2e5f8365025f348ada96e9 - Sigstore transparency entry: 702122617
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 121.3 kB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0654a6bb757302eb6123c4b36d6dc31835b1fc7f918e0d8cbd1912e38552afdf
|
|
| MD5 |
6ad9007fa5db9b3879058ad0ce732efe
|
|
| BLAKE2b-256 |
6c55157397a815686121f2016b994e53c96f8454553fa1b7798051c4f8ef3ad4
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-win_arm64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-win_arm64.whl -
Subject digest:
0654a6bb757302eb6123c4b36d6dc31835b1fc7f918e0d8cbd1912e38552afdf - Sigstore transparency entry: 702122623
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 129.2 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ae650e7f90c8671a466e33b2715611454957766539baa7e4aa6cd46e886cd74
|
|
| MD5 |
bb1a5e6a93248f0bd5a7d403c96fbccb
|
|
| BLAKE2b-256 |
7837a5fad43f7ff580514f6258a7bb14e32df631656bf8bf011659f86eef6af5
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-win_amd64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-win_amd64.whl -
Subject digest:
2ae650e7f90c8671a466e33b2715611454957766539baa7e4aa6cd46e886cd74 - Sigstore transparency entry: 702122630
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-win32.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-win32.whl
- Upload date:
- Size: 123.7 kB
- Tags: CPython 3.10+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85704ae73d536b4fc9d50408b16ed630d5273a36f7c946c5f51e80e5808bdbb0
|
|
| MD5 |
58a5dfad695a2c51cf723a962faed20a
|
|
| BLAKE2b-256 |
652176ebfdd2d333a2e754baa0dc06bada53ebae3751cff3a869318c0dc82fee
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-win32.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-win32.whl -
Subject digest:
85704ae73d536b4fc9d50408b16ed630d5273a36f7c946c5f51e80e5808bdbb0 - Sigstore transparency entry: 702122627
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 406.6 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82ae5459cc44ad092db472bdd87b25eaffedca3cb37716fdde09a22c91405f47
|
|
| MD5 |
6076623df3bdabed7676209fae96dfe0
|
|
| BLAKE2b-256 |
61f1fa7d10f609d8016b435f159bd9a6c821996af02af8d84bcb47e006142176
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-musllinux_1_2_x86_64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
82ae5459cc44ad092db472bdd87b25eaffedca3cb37716fdde09a22c91405f47 - Sigstore transparency entry: 702122624
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 402.3 kB
- Tags: CPython 3.10+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6389e148a999c4259e3229bf2ca656cfd4e2d44fa34c41b90e85ae70708e3c51
|
|
| MD5 |
188cfc507526771da0a7c1690fbd189b
|
|
| BLAKE2b-256 |
7556b436b544d2ae4969b19bb018a4c7b4bbdc4877ab8bcfd9d8538bbffb31e2
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-musllinux_1_2_aarch64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
6389e148a999c4259e3229bf2ca656cfd4e2d44fa34c41b90e85ae70708e3c51 - Sigstore transparency entry: 702122618
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 231.0 kB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e601092ff0cfd652974b6ffe7dcf2c4f8548dc0fc24a4726218b8e135bf842
|
|
| MD5 |
11bcccaec888151f50d74bc57b253eec
|
|
| BLAKE2b-256 |
93e6630935cf03764ccd7beb594213434b0766769e05e88c93172049ce78ad7d
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-manylinux_2_28_x86_64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
f7e601092ff0cfd652974b6ffe7dcf2c4f8548dc0fc24a4726218b8e135bf842 - Sigstore transparency entry: 702122622
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 219.6 kB
- Tags: CPython 3.10+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af3ab82e7b21f31fe538a7fbb72c8f53e4e6b38b43ad4f1c8497632918c2b3e8
|
|
| MD5 |
fbe4650bcd05ba0bdd1564f19d1e145d
|
|
| BLAKE2b-256 |
6fccaa184fb921632b4613e5b12e66248110e217f8f096a6de88c1958e3d145f
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-manylinux_2_28_aarch64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
af3ab82e7b21f31fe538a7fbb72c8f53e4e6b38b43ad4f1c8497632918c2b3e8 - Sigstore transparency entry: 702122619
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 202.7 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e6cd4fd2ee1104221a6b92c7a283fbbe4b9cf94209a5a4b42055f722ffd5e24
|
|
| MD5 |
c432cd1355d762e8c21f3dbe194e0e6e
|
|
| BLAKE2b-256 |
72750df89b25c7129bcbf31208f8fa911177e2392334a69152dc59c0d41466b1
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
9e6cd4fd2ee1104221a6b92c7a283fbbe4b9cf94209a5a4b42055f722ffd5e24 - Sigstore transparency entry: 702122620
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rlic-0.5.3-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rlic-0.5.3-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 212.5 kB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
badad56ff96f0a77846da41d9f9badb26cc8a7439e7600b7b35b777afec9a46e
|
|
| MD5 |
324c7fd94a5721a91e6eae4b19c279d7
|
|
| BLAKE2b-256 |
7de72c91817eae45c9a250d6b9d5b8005f0c2fc1e062c93e872cea4311c3c27e
|
Provenance
The following attestation bundles were made for rlic-0.5.3-cp310-abi3-macosx_10_12_x86_64.whl:
Publisher:
cd.yml on neutrinoceros/rlic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rlic-0.5.3-cp310-abi3-macosx_10_12_x86_64.whl -
Subject digest:
badad56ff96f0a77846da41d9f9badb26cc8a7439e7600b7b35b777afec9a46e - Sigstore transparency entry: 702122621
- Sigstore integration time:
-
Permalink:
neutrinoceros/rlic@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Branch / Tag:
refs/tags/v0.5.3 - Owner: https://github.com/neutrinoceros
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@e33fcd273f2a412b9e1868647d220509ad0433c4 -
Trigger Event:
push
-
Statement type: