Metadata-Version: 2.1
Name: diptorch
Version: 0.0.1
Summary: Digital image processing in PyTorch
Home-page: https://github.com/eigenvivek/diptorch
Author: Vivek Gopalakrishnan
Author-email: vivekg@mit.edu
License: MIT License
Keywords: nbdev jupyter notebook python
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: einops
Requires-Dist: matplotlib
Requires-Dist: scikit-image
Requires-Dist: torch
Provides-Extra: dev
Requires-Dist: nbdev ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: ipykernel ; extra == 'dev'
Requires-Dist: ipywidgets ; extra == 'dev'
Requires-Dist: jupyterlab ; extra == 'dev'
Requires-Dist: jupyterlab-execute-time ; extra == 'dev'
Requires-Dist: jupyterlab-code-formatter ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'

# diptorch


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Install

``` sh
pip install diptorch
```

## Hello, World!

``` python
import matplotlib.pyplot as plt

from 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)
