Name | torch-distmap JSON |
Version |
0.2.0
JSON |
| download |
home_page | None |
Summary | Euclidean distance transform in PyTorch |
upload_time | 2024-04-18 11:14:06 |
maintainer | None |
docs_url | None |
author | Yael Balbastre |
requires_python | >=3.6 |
license | MIT |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# torch-distmap
Euclidean distance transform in PyTorch.
This is an implementation of the algorithm from the paper
> [**"Distance Transforms of Sampled Functions"**](https://www.theoryofcomputing.org/articles/v008a019/v008a019.pdf) <br />
> Pedro F. Felzenszwalb & Daniel P. Huttenlocher <br />
> _Theory of Computing_ (2012)
Although it is in PyTorch, our implementation performs loops across
voxels and hence quite slow. Moreover, it takes masks as an input
and therefore does not allow backpropagation.
## Installation
### Dependency
- `torch >= 1.3`
### Conda
```shell
conda install torch-distmap -c balbasty -c pytorch
```
### Pip
```shell
pip install torch-distmap
```
## API
```python
euclidean_distance_transform(x, ndim=None, vx=1)
"""Compute the Euclidean distance transform of a binary image
Parameters
----------
x : (..., *spatial) tensor
Input tensor. Zeros will stay zero, and the distance will
be propagated into nonzero voxels.
ndim : int, default=`x.dim()`
Number of spatial dimensions
vx : [sequence of] float, default=1
Voxel size
Returns
-------
d : (..., *spatial) tensor
Distance map
"""
```
```python
euclidean_signed_transform(x, ndim=None, vx=1)
"""Compute the signed Euclidean distance transform of a binary image
Parameters
----------
x : (..., *spatial) tensor
Input tensor.
A negative distance will propagate into zero voxels and
a positive distance will propagate into nonzero voxels.
ndim : int, default=`x.dim()`
Number of spatial dimensions
vx : [sequence of] float, default=1
Voxel size
Returns
-------
d : (..., *spatial) tensor
Signed distance map
"""
```
```python
l1_distance_transform(x, ndim=None, vx=1)
"""Compute the L1 distance transform of a binary image
Parameters
----------
x : (..., *spatial) tensor
Input tensor. Zeros will stay zero, and the distance will
be propagated into nonzero voxels.
ndim : int, default=`x.dim()`
Number of spatial dimensions
vx : [sequence of] float, default=1
Voxel size
Returns
-------
d : (..., *spatial) tensor
Distance map
"""
```
```python
l1_signed_transform(x, ndim=None, vx=1)
"""Compute the signed L1 distance transform of a binary image
Parameters
----------
x : (..., *spatial) tensor
Input tensor.
A negative distance will propagate into zero voxels and
a positive distance will propagate into nonzero voxels.
ndim : int, default=`x.dim()`
Number of spatial dimensions
vx : [sequence of] float, default=1
Voxel size
Returns
-------
d : (..., *spatial) tensor
Signed distance map
"""
```
## Related packages
- [edt](https://github.com/seung-lab/euclidean-distance-transform-3d) :
a very fast CPU implementation of the same algorithm, written in C.
- [scipy.ndimage.distance_transform_edt](https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.distance_transform_edt.html) :
reference implementation, written in C, based on the paper
> **"A linear time algorithm for computing exact euclidean distance
> transforms of binary images in arbitrary dimensions"** <br />
> C. R. Maurer, Jr., R. Qi, V. Raghavan <br />
> IEEE Trans. PAMI 25, 265-270, (2003) <br />
Raw data
{
"_id": null,
"home_page": null,
"name": "torch-distmap",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Yael Balbastre",
"author_email": "yael.balbastre@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/87/da/d20f54f2d1a2f7890e12214cb68cd98bb4de0ec1af18827b9179940179d2/torch-distmap-0.2.0.tar.gz",
"platform": "OS Independent",
"description": "# torch-distmap\n\nEuclidean distance transform in PyTorch.\n\nThis is an implementation of the algorithm from the paper\n\n> [**\"Distance Transforms of Sampled Functions\"**](https://www.theoryofcomputing.org/articles/v008a019/v008a019.pdf) <br />\n> Pedro F. Felzenszwalb & Daniel P. Huttenlocher <br />\n> _Theory of Computing_ (2012)\n\nAlthough it is in PyTorch, our implementation performs loops across \nvoxels and hence quite slow. Moreover, it takes masks as an input \nand therefore does not allow backpropagation.\n\n## Installation\n\n### Dependency\n\n- `torch >= 1.3`\n\n### Conda\n\n```shell\nconda install torch-distmap -c balbasty -c pytorch\n```\n\n### Pip\n\n```shell\npip install torch-distmap\n```\n\n## API\n\n```python\neuclidean_distance_transform(x, ndim=None, vx=1)\n\"\"\"Compute the Euclidean distance transform of a binary image\n\nParameters\n----------\nx : (..., *spatial) tensor\n Input tensor. Zeros will stay zero, and the distance will\n be propagated into nonzero voxels.\nndim : int, default=`x.dim()`\n Number of spatial dimensions\nvx : [sequence of] float, default=1\n Voxel size\n\nReturns\n-------\nd : (..., *spatial) tensor\n Distance map\n\"\"\"\n```\n\n```python\neuclidean_signed_transform(x, ndim=None, vx=1)\n\"\"\"Compute the signed Euclidean distance transform of a binary image\n\nParameters\n----------\nx : (..., *spatial) tensor\n Input tensor.\n A negative distance will propagate into zero voxels and\n a positive distance will propagate into nonzero voxels.\nndim : int, default=`x.dim()`\n Number of spatial dimensions\nvx : [sequence of] float, default=1\n Voxel size\n\nReturns\n-------\nd : (..., *spatial) tensor\n Signed distance map\n\"\"\"\n```\n\n```python\nl1_distance_transform(x, ndim=None, vx=1)\n\"\"\"Compute the L1 distance transform of a binary image\n\nParameters\n----------\nx : (..., *spatial) tensor\n Input tensor. Zeros will stay zero, and the distance will\n be propagated into nonzero voxels.\nndim : int, default=`x.dim()`\n Number of spatial dimensions\nvx : [sequence of] float, default=1\n Voxel size\n\nReturns\n-------\nd : (..., *spatial) tensor\n Distance map\n\"\"\"\n```\n\n```python\nl1_signed_transform(x, ndim=None, vx=1)\n\"\"\"Compute the signed L1 distance transform of a binary image\n\nParameters\n----------\nx : (..., *spatial) tensor\n Input tensor.\n A negative distance will propagate into zero voxels and\n a positive distance will propagate into nonzero voxels.\nndim : int, default=`x.dim()`\n Number of spatial dimensions\nvx : [sequence of] float, default=1\n Voxel size\n\nReturns\n-------\nd : (..., *spatial) tensor\n Signed distance map\n\"\"\"\n```\n\n## Related packages\n\n- [edt](https://github.com/seung-lab/euclidean-distance-transform-3d) : \n a very fast CPU implementation of the same algorithm, written in C.\n\n\n- [scipy.ndimage.distance_transform_edt](https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.distance_transform_edt.html) :\nreference implementation, written in C, based on the paper\n> **\"A linear time algorithm for computing exact euclidean distance \n> transforms of binary images in arbitrary dimensions\"** <br />\n> C. R. Maurer, Jr., R. Qi, V. Raghavan <br />\n> IEEE Trans. PAMI 25, 265-270, (2003) <br />\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Euclidean distance transform in PyTorch",
"version": "0.2.0",
"project_urls": {
"Source Code": "https://github.com/balbasty/torch-distmap"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "42f59d0f7e1ea7fb62af5fd6445cd1600521ae9ab69b8697f4263957f8458af2",
"md5": "92729f5c8c71ae4ec1d18f97cd5d210f",
"sha256": "094c78e85bb0ed1c91c81a69dc2756d8c63fcbea0dd3540aa779390582a947b8"
},
"downloads": -1,
"filename": "torch_distmap-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "92729f5c8c71ae4ec1d18f97cd5d210f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 12384,
"upload_time": "2024-04-18T11:13:57",
"upload_time_iso_8601": "2024-04-18T11:13:57.995917Z",
"url": "https://files.pythonhosted.org/packages/42/f5/9d0f7e1ea7fb62af5fd6445cd1600521ae9ab69b8697f4263957f8458af2/torch_distmap-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "87dad20f54f2d1a2f7890e12214cb68cd98bb4de0ec1af18827b9179940179d2",
"md5": "580ac376853ac302f66542a37b13979b",
"sha256": "634ed0d63c2f096fa9b2ac6a57d1e2cc4528eef11ee75488265d8cce9a27b574"
},
"downloads": -1,
"filename": "torch-distmap-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "580ac376853ac302f66542a37b13979b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 26890,
"upload_time": "2024-04-18T11:14:06",
"upload_time_iso_8601": "2024-04-18T11:14:06.358487Z",
"url": "https://files.pythonhosted.org/packages/87/da/d20f54f2d1a2f7890e12214cb68cd98bb4de0ec1af18827b9179940179d2/torch-distmap-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-18 11:14:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "balbasty",
"github_project": "torch-distmap",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "torch-distmap"
}