Skip to main content

codecov pypi License PyPI - Downloads

Imops

Efficient parallelizable algorithms for multidimensional arrays to speed up your data pipelines.

Install

pip install imops  # default install with Cython backend

Wheels pick the kernels for the CPU at import: x86-64-v3 (AVX2) where the CPU has it, x86-64-v2 elsewhere. To build for your own CPU only, use -march=native:

IMOPS_NATIVE=1 pip install --no-binary imops imops

How fast is it?

Time comparisons (ms) for Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz using 8 threads. All inputs are C-contiguous NumPy arrays. For morphology functions bool dtype is used and float64 for all others.

function / backend Scipy() Cython()
zoom(..., order=0) 2072 1114
zoom(..., order=1) 6527 596
interp1d 780 149
radon 59711 5982
inverse_radon 52928 8254
binary_dilation 2207 310
binary_erosion 2296 326
binary_closing 4158 544
binary_opening 4410 567
center_of_mass 2237 64

We use airspeed velocity to benchmark our code. For detailed results visit benchmark page.

Features

Fast Radon transform

from imops import radon, inverse_radon

Fast 0/1-order zoom

from imops import zoom, zoom_to_shape

# fast zoom with optional fallback to scipy's implementation
y = zoom(x, 2, axis=[0, 1])
# a handy function to zoom the array to a given shape 
# without the need to compute the scale factor
z = zoom_to_shape(x, (4, 120, 67))

Works faster only for ndim<=4, dtype=float32 or float64 (and bool-int16-32-64-uint8-16-32 if order == 0), output=None, order=0 or 1, mode='constant', grid_mode=False

Fast 0/1-order rotate

from imops import rotate

# rotate every plane parallel to axes 1 and 2 by 30 degrees
y = rotate(x, 30, axes=(1, 2))
# a bool mask answers what `rotate(mask.astype('float32')) >= 0.5` answers, without building that array
m = rotate(mask, 30, axes=(1, 2))

Works faster only for order=0 or 1, dtype=bool-float16-float32-uint8-uint16-int16-int32, mode='constant'. Unlike scipy.ndimage.rotate it also accepts float16, copies the input only if it is not C-contiguous or is float16, and always returns a C-contiguous array.

Fast 1d linear interpolation

from imops import interp1d  # same as `scipy.interpolate.interp1d`

Works faster only for ndim<=3, dtype=float32 or float64, order=1

Fast 2d linear interpolation

import numpy as np
from imops.interp2d import Linear2DInterpolator
n, m = 1024, 2
points = np.random.randint(low=0, high=1024, size=(n, m))
points = np.unique(points, axis=0)
x_points = points[: n // 2]
values = np.random.uniform(low=0.0, high=1.0, size=(len(x_points),))
interp_points = points[n // 2:]
num_threads = -1 # will be equal to num of CPU cores
# You can optionally pass your own triangulation as an np.array of shape [num_triangles, 3], element at (i, j) position is an index of a point from x_points
interpolator = Linear2DInterpolator(x_points, values, num_threads=num_threads, triangles=None)
# Also you can pass values to __call__ and rewrite the ones that were passed to __init__
interp_values = interpolator(interp_points, values + 1.0, fill_value=0.0)

Fast binary morphology

from imops import binary_dilation, binary_erosion, binary_opening, binary_closing

These functions mimic scikit-image counterparts

Padding

from imops import pad, pad_to_shape

y = pad(x, 10, axis=[0, 1])
# `ratio` controls how much padding is applied to left side:
# 0 - pad from right
# 1 - pad from left
# 0.5 - distribute the padding equally
z = pad_to_shape(x, (4, 120, 67), ratio=0.25)

Cropping

from imops import crop_to_shape

# `ratio` controls the position of the crop
# 0 - crop from right
# 1 - crop from left
# 0.5 - crop from the middle
z = crop_to_shape(x, (4, 120, 67), ratio=0.25)

Labeling

from imops import label

# same components as `skimage.measure.label`, possibly numbered in another order
labeled, num_components = label(x, background=1, return_num=True)

Backends

For all heavy image routines except label you can specify which backend to use. Backend can be specified by a string or by an instance of Backend class. The latter allows you to customize some backend options:

from imops import Cython, Scipy, zoom

y = zoom(x, 2, backend='Cython')
y = zoom(x, 2, backend=Cython())  # same as previous
y = zoom(x, 2, backend=Scipy())  # use scipy original implementation

Also backend can be specified globally or locally:

from imops import imops_backend, set_backend, zoom

set_backend('Scipy')  # sets Scipy as default backend
with imops_backend('Cython'):  # sets Cython backend via context manager
    zoom(x, 2)

Available backends:

function / backend Scipy Cython
zoom ✓ ✓
interp1d ✓ ✓
radon ✗ ✓
inverse_radon ✗ ✓
binary_dilation ✓ ✓
binary_erosion ✓ ✓
binary_closing ✓ ✓
binary_opening ✓ ✓
center_of_mass ✓ ✓

Acknowledgements

Some parts of our code for radon/inverse radon transform as well as the code for linear interpolation are inspired by the implementations from scikit-image and scipy. Also we used fastremap, edt and cc3d out of the box.

Building from source

Building needs GCC 11+ or clang 12+, which know -march=x86-64-v2 and -march=x86-64-v3, or MSVC. IMOPS_NATIVE=1 has no effect with MSVC, which has no -march=native.

Metadata

Release files for imops 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imops 0.13.0
File Size Uploaded Provenance Actions
imops-0.13.0.tar.gz 60.6 kB Without provenance Details for imops-0.13.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for imops 0.13.0
File Actions
imops-0.13.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for imops-0.13.0-cp314-cp314-win_amd64.whl
imops-0.13.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for imops-0.13.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
imops-0.13.0-cp314-cp314-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 macOS 15.0+ ARM64 Details for imops-0.13.0-cp314-cp314-macosx_15_0_arm64.whl
imops-0.13.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for imops-0.13.0-cp313-cp313-win_amd64.whl
imops-0.13.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for imops-0.13.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
imops-0.13.0-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details for imops-0.13.0-cp313-cp313-macosx_15_0_arm64.whl
imops-0.13.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for imops-0.13.0-cp312-cp312-win_amd64.whl
imops-0.13.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for imops-0.13.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
imops-0.13.0-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details for imops-0.13.0-cp312-cp312-macosx_15_0_arm64.whl
imops-0.13.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for imops-0.13.0-cp311-cp311-win_amd64.whl
imops-0.13.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for imops-0.13.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
imops-0.13.0-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details for imops-0.13.0-cp311-cp311-macosx_15_0_arm64.whl
imops-0.13.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for imops-0.13.0-cp310-cp310-win_amd64.whl
imops-0.13.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for imops-0.13.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
imops-0.13.0-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details for imops-0.13.0-cp310-cp310-macosx_15_0_arm64.whl

Total release size: 155.1 MB

Release files / imops-0.13.0.tar.gz

Download URL imops-0.13.0.tar.gz
Size 60.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bc7e219e118bd32400db2eb21f971c748c49ee09fec9d27c91c9b11b4ec0f9b0
BLAKE2b-256 checksum
How to use checksums
836bcc2957bf58e0aea84c5d6b3958c3ef3fbc20bbc520be9ca5e0fe1d9a5510
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp314-cp314-win_amd64.whl

Download URL imops-0.13.0-cp314-cp314-win_amd64.whl
Size 6.3 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
e94e23e371a666c0162d0aa32e51ec97259de3b08186c2b71a423b70876212d5
BLAKE2b-256 checksum
How to use checksums
d1c419c9f932ba6f8f08b578822ac3d275c80c68fdaf5329ee94f0bf6fbe2ace
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL imops-0.13.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 21.0 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9ff075553fff784f0681594af884439307ad7fc4135a8955e16f6acc4b2426e6
BLAKE2b-256 checksum
How to use checksums
d08c62de011266860608ccf4cb5d740944c4ce54005dd07803f9cabeec4e037a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp314-cp314-macosx_15_0_arm64.whl

Download URL imops-0.13.0-cp314-cp314-macosx_15_0_arm64.whl
Size 3.6 MB
Tags CPython 3.14 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
059e0ccd7bf76075239985928981c89a87a1a5781cc56b36cd6fc69d86e44d62
BLAKE2b-256 checksum
How to use checksums
abdd54012cac3be2bd48a27ba208e30ba3d0cdb3fa88d4e8eb66138aee95e76b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp313-cp313-win_amd64.whl

Download URL imops-0.13.0-cp313-cp313-win_amd64.whl
Size 6.3 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
ad8aeaf0693bf331327642f6f0643e5402cc641eef7dcb641d5e8fb8f5e2c721
BLAKE2b-256 checksum
How to use checksums
3c09b506603f8d7a160b1c875f698601bb984aa210ea0d3c3b46adf14d49301b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL imops-0.13.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 21.2 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7ad9874bfcb9c2a6809f256a6157d5527eb2f11eb2bb795663488d75010dc747
BLAKE2b-256 checksum
How to use checksums
7e2eb05806314c91632f1186c39ec60c57367155ddca5a6bfb583197c496b9b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp313-cp313-macosx_15_0_arm64.whl

Download URL imops-0.13.0-cp313-cp313-macosx_15_0_arm64.whl
Size 3.6 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
26b3346267474ce873b5496238ec8b7d29ef3c0c88e9b6eb9f7bfc1c07057e1c
BLAKE2b-256 checksum
How to use checksums
9436c6e07bbbf7dc6ee2e47bfe6aa0379296f2803b7567529db107ab6856ec56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp312-cp312-win_amd64.whl

Download URL imops-0.13.0-cp312-cp312-win_amd64.whl
Size 6.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
cf3e409b9a44ec74e4ecc1ddba3147048d8c96cc4b0d60efeeb1fda855444558
BLAKE2b-256 checksum
How to use checksums
035c3d85de8f7d664d26de5fe76552df96a0d37cb5f3c6c1534c0fccf384926b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL imops-0.13.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 21.4 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
353083e260ee68844dc4029efcd00f4b3cae730f99fddb9c9dc206b5afe9747f
BLAKE2b-256 checksum
How to use checksums
89fa02f35316ef3e58a6c8d023b89d89313a87378a7f73067bfaf17d38bdae43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp312-cp312-macosx_15_0_arm64.whl

Download URL imops-0.13.0-cp312-cp312-macosx_15_0_arm64.whl
Size 3.6 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
81bb2015fb463f284efa63584766b3f4704733bd14e69f1d1f5d31d685f8245b
BLAKE2b-256 checksum
How to use checksums
e590fcb4cb083646dd59de21279793c85438273ec6d21d681f27557be827a5ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp311-cp311-win_amd64.whl

Download URL imops-0.13.0-cp311-cp311-win_amd64.whl
Size 6.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
2eb8463910847e62b3da307ff4a7c2cc3c6bf7a3c801b9d42b5fabf72981a589
BLAKE2b-256 checksum
How to use checksums
21ccfb20c2218c0e431f53211b14a93e85acdbd47eba2afb10785b7723dabeec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL imops-0.13.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 21.3 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d51dda85b1a84dd55045594a657a2661adf17e43cab7573bd767d771fdc598b9
BLAKE2b-256 checksum
How to use checksums
265d4df24eb136c31fb93e37365a961a52bc196c6ec7a78661ea8087b1d2d00d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp311-cp311-macosx_15_0_arm64.whl

Download URL imops-0.13.0-cp311-cp311-macosx_15_0_arm64.whl
Size 3.6 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
73d418285a3c949ac25f00698702fffb9df07cb8ca85c5402715a0bd9387b4a2
BLAKE2b-256 checksum
How to use checksums
7b670d093fc12ae9cbbeaef17d345193dc41515629df369ed36ea13516616b29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp310-cp310-win_amd64.whl

Download URL imops-0.13.0-cp310-cp310-win_amd64.whl
Size 6.3 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
8b54becc702f24fcd28182b272f04422f28f1ba8293767616a3fed12429ef28a
BLAKE2b-256 checksum
How to use checksums
c6f3ce8ec1c3a4ff4f1529e21e5655afa420fb87f761f6cfb89fd35ae3a40170
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL imops-0.13.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 20.7 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
5d836d4abfafb4a43659046f441839bccb73f8c55833ff7edc5f8fcc349ba3cb
BLAKE2b-256 checksum
How to use checksums
8eff3334cff9abda5eb3f5ff1d3df0d65b06b21d0f946f339ea882ebeb8cae90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / imops-0.13.0-cp310-cp310-macosx_15_0_arm64.whl

Download URL imops-0.13.0-cp310-cp310-macosx_15_0_arm64.whl
Size 3.6 MB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
645a69596c652f0fc1366a43402085054b11e9ddba3aa6163c7f827f6d928e55
BLAKE2b-256 checksum
How to use checksums
8e29e4397d02f2468d88fdba4cbb8bc3d9ffa623658ce905e6c693a60646a4d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for imops 0.13.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page