{"id":19382588,"url":"https://github.com/neuro-ml/imops","last_synced_at":"2025-09-16T12:19:53.795Z","repository":{"id":60555692,"uuid":"523360089","full_name":"neuro-ml/imops","owner":"neuro-ml","description":"Efficient parallelizable algorithms for multidimensional arrays to speed up your data pipelines","archived":false,"fork":false,"pushed_at":"2025-04-09T09:20:19.000Z","size":10271,"stargazers_count":22,"open_issues_count":15,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T14:08:45.156Z","etag":null,"topics":["image-processing","parallel-computing","python"],"latest_commit_sha":null,"homepage":"https://neuro-ml.github.io/imops/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neuro-ml.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-10T13:44:10.000Z","updated_at":"2024-12-30T22:27:13.000Z","dependencies_parsed_at":"2023-10-15T23:35:58.793Z","dependency_job_id":"4cbcd8d9-6c02-4fcf-aeb8-d2bc2b0c0ce9","html_url":"https://github.com/neuro-ml/imops","commit_stats":{"total_commits":456,"total_committers":6,"mean_commits":76.0,"dds":"0.14035087719298245","last_synced_commit":"48ac786908b9e4ebbeb046ad27fe478ce857b9f1"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuro-ml%2Fimops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuro-ml%2Fimops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuro-ml%2Fimops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neuro-ml%2Fimops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neuro-ml","download_url":"https://codeload.github.com/neuro-ml/imops/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250509826,"owners_count":21442507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-processing","parallel-computing","python"],"created_at":"2024-11-10T09:22:17.770Z","updated_at":"2025-09-16T12:19:48.721Z","avatar_url":"https://github.com/neuro-ml.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![codecov](https://codecov.io/gh/neuro-ml/imops/branch/master/graph/badge.svg)](https://codecov.io/gh/neuro-ml/imops)\n[![pypi](https://img.shields.io/pypi/v/imops?logo=pypi\u0026label=PyPi)](https://pypi.org/project/imops/)\n![License](https://img.shields.io/github/license/neuro-ml/imops)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/imops)](https://pypi.org/project/imops/)\n\n# Imops\n\nEfficient parallelizable algorithms for multidimensional arrays to speed up your data pipelines.\n- [Documentation](https://neuro-ml.github.io/imops/)\n- [Benchmarks](https://neuro-ml.github.io/imops/benchmarks/)\n\n# Install\n\n```shell\npip install imops  # default install with Cython backend\npip install imops[numba]  # additionally install Numba backend\n```\n\n# How fast is it?\n\nTime 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.\n| function / backend   |  Scipy()  |  Cython(fast=False)  |  Cython(fast=True)  |  Numba()  |\n|:----------------------:|:-----------:|:----------------------:|:---------------------:|:-----------:|\n| `zoom(..., order=0)` |   2072    |         1114         |         **867**         |   3590    |\n| `zoom(..., order=1)` |   6527    |         596          |         **575**         |   3757    |\n| `interp1d`           |    780    |         149          |         **146**         |    420    |\n| `radon`              |   59711   |         5982         |        **4837**         |      -     |\n| `inverse_radon`      |   52928   |         8254         |        **6535**         |         -  |\n| `binary_dilation`    |   2207    |         310          |         **298**         |        -   |\n| `binary_erosion`     |   2296    |         326          |         **304**         |        -   |\n| `binary_closing`     |   4158    |         544          |         **469**         |        -   |\n| `binary_opening`     |   4410    |         567          |         **522**         |        -   |\n| `center_of_mass`     |   2237    |          **64**          |         **64**          |        -   |\n\nWe use [`airspeed velocity`](https://asv.readthedocs.io/en/stable/) to benchmark our code. For detailed results visit [benchmark page](https://neuro-ml.github.io/imops/benchmarks/).\n\n# Features\n\n### Fast Radon transform\n\n```python\nfrom imops import radon, inverse_radon\n```\n\n### Fast 0/1-order zoom\n\n```python\nfrom imops import zoom, zoom_to_shape\n\n# fast zoom with optional fallback to scipy's implementation\ny = zoom(x, 2, axis=[0, 1])\n# a handy function to zoom the array to a given shape \n# without the need to compute the scale factor\nz = zoom_to_shape(x, (4, 120, 67))\n```\nWorks faster only for `ndim\u003c=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`\n### Fast 1d linear interpolation\n\n```python\nfrom imops import interp1d  # same as `scipy.interpolate.interp1d`\n```\nWorks faster only for `ndim\u003c=3, dtype=float32 or float64, order=1`\n\n### Fast 2d linear interpolation\n```python\nimport numpy as np\nfrom imops.interp2d import Linear2DInterpolator\nn, m = 1024, 2\npoints = np.random.randint(low=0, high=1024, size=(n, m))\npoints = np.unique(points, axis=0)\nx_points = points[: n // 2]\nvalues = np.random.uniform(low=0.0, high=1.0, size=(len(x_points),))\ninterp_points = points[n // 2:]\nnum_threads = -1 # will be equal to num of CPU cores\n# 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\ninterpolator = Linear2DInterpolator(x_points, values, num_threads=num_threads, triangles=None)\n# Also you can pass values to __call__ and rewrite the ones that were passed to __init__\ninterp_values = interpolator(interp_points, values + 1.0, fill_value=0.0)\n```\n\n### Fast binary morphology\n\n```python\nfrom imops import binary_dilation, binary_erosion, binary_opening, binary_closing\n```\nThese functions mimic `scikit-image` counterparts\n### Padding\n\n```python\nfrom imops import pad, pad_to_shape\n\ny = pad(x, 10, axis=[0, 1])\n# `ratio` controls how much padding is applied to left side:\n# 0 - pad from right\n# 1 - pad from left\n# 0.5 - distribute the padding equally\nz = pad_to_shape(x, (4, 120, 67), ratio=0.25)\n```\n\n### Cropping\n\n```python\nfrom imops import crop_to_shape\n\n# `ratio` controls the position of the crop\n# 0 - crop from right\n# 1 - crop from left\n# 0.5 - crop from the middle\nz = crop_to_shape(x, (4, 120, 67), ratio=0.25)\n```\n\n### Labeling\n\n```python\nfrom imops import label\n\n# same as `skimage.measure.label`\nlabeled, num_components = label(x, background=1, return_num=True)\n```\n\n# Backends\nFor 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:\n```python\nfrom imops import Cython, Numba, Scipy, zoom\n\ny = zoom(x, 2, backend='Cython')\ny = zoom(x, 2, backend=Cython(fast=False))  # same as previous\ny = zoom(x, 2, backend=Cython(fast=True))  # -ffast-math compiled cython backend\ny = zoom(x, 2, backend=Scipy())  # use scipy original implementation\ny = zoom(x, 2, backend='Numba')\ny = zoom(x, 2, backend=Numba(parallel=True, nogil=True, cache=True))  # same as previous\n```\nAlso backend can be specified globally or locally:\n```python\nfrom imops import imops_backend, set_backend, zoom\n\nset_backend('Numba')  # sets Numba as default backend\nwith imops_backend('Cython'):  # sets Cython backend via context manager\n    zoom(x, 2)\n```\nNote that for `Numba` backend setting `num_threads` argument has no effect for now and you should use `NUMBA_NUM_THREADS` environment variable.\nAvailable backends:\n|         function / backend            | Scipy   | Cython  | Numba   |\n|:-------------------:|:---------:|:---------:|:---------:|\n| `zoom`            | \u0026check; | \u0026check; | \u0026check; |\n| `interp1d`        | \u0026check; | \u0026check; | \u0026check; |\n| `radon`           | \u0026cross; | \u0026check; | \u0026cross; |\n| `inverse_radon`   | \u0026cross; | \u0026check; | \u0026cross; |\n| `binary_dilation` | \u0026check; | \u0026check; | \u0026cross; |\n| `binary_erosion`  | \u0026check; | \u0026check; | \u0026cross; |\n| `binary_closing`  | \u0026check; | \u0026check; | \u0026cross; |\n| `binary_opening`  | \u0026check; | \u0026check; | \u0026cross; |\n| `center_of_mass`  | \u0026check; | \u0026check; | \u0026cross; |\n\n# Acknowledgements\n\nSome parts of our code for radon/inverse radon transform as well as the code for linear interpolation are inspired by\nthe implementations from [`scikit-image`](https://github.com/scikit-image/scikit-image) and [`scipy`](https://github.com/scipy/scipy).\nAlso we used [`fastremap`](https://github.com/seung-lab/fastremap), [`edt`](https://github.com/seung-lab/euclidean-distance-transform-3d) and [`cc3d`](https://github.com/seung-lab/connected-components-3d) out of the box.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuro-ml%2Fimops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneuro-ml%2Fimops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneuro-ml%2Fimops/lists"}