Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eigenvivek/diptorch
Digital image processing in PyTorch
https://github.com/eigenvivek/diptorch
filtering frangi-filter hessian image-processing pytorch
Last synced: 9 days ago
JSON representation
Digital image processing in PyTorch
- Host: GitHub
- URL: https://github.com/eigenvivek/diptorch
- Owner: eigenvivek
- License: mit
- Created: 2024-08-08T10:52:12.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-30T16:47:31.000Z (20 days ago)
- Last Synced: 2024-10-30T16:51:44.406Z (20 days ago)
- Topics: filtering, frangi-filter, hessian, image-processing, pytorch
- Language: Python
- Homepage: http://vivekg.dev/diptorch/
- Size: 2.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# diptorch
## Install
``` sh
pip install diptorch
```## Hello, World!
``` python
import matplotlib.pyplot as pltfrom diptorch.filters import gaussian_filter
from diptorch.utils import astronaut, imshow
`````` python
# Zero-th order Gaussian filter (smoothing)
img = astronaut()
img_filtered = gaussian_filter(img, sigma=2.5)
imshow(img, img_filtered)
plt.show()
```![](index_files/figure-commonmark/cell-3-output-1.png)
``` python
# First-order Gaussian filter
img = astronaut()
img_filtered = gaussian_filter(img, sigma=2.5, order=1)
imshow(img, img_filtered)
plt.show()
```![](index_files/figure-commonmark/cell-4-output-1.png)
``` python
# Second-order Gaussian filter on the height dimension (y-axis)
img = astronaut()
img_filtered = gaussian_filter(img, sigma=2.5, order=[2, 0])
imshow(img, img_filtered)
plt.show()
```![](index_files/figure-commonmark/cell-5-output-1.png)
## Hessian matrix
``` python
from diptorch.filters import hessian, hessian_eigenvalues
from einops import rearrange
`````` python
# Hessian matrix of an image (all second-order partial derivatives)
img = astronaut()
H = hessian(img, sigma=2.5, as_matrix=True)
H = rearrange(H, "B C1 C2 H W -> B (C1 H) (C2 W)").squeeze()plt.imshow(H, cmap="gray")
plt.axis("off")
plt.show()
```![](index_files/figure-commonmark/cell-7-output-1.png)
``` python
# Eigenvalues of the Hessian matrix of an image
# sorted by the magnitude of the eigenvalues
img = astronaut()
eig = hessian_eigenvalues(img, sigma=2.5)
_, axs = imshow(img, *eig.split(1, 1))
axs[1].set(title="Smallest magnitude\neigenvalue")
axs[2].set(title="Largest magnitude\neigenvalue")
plt.show()
```![](index_files/figure-commonmark/cell-8-output-1.png)