Skip to main content

Digital image processing in PyTorch

Project description

diptorch

Install

pip install diptorch

Hello, World!

import matplotlib.pyplot as plt

from diptorch.filters import gaussian_filter
from diptorch.utils import astronaut, imshow
# Zero-th order Gaussian filter (smoothing)
img = astronaut()
img_filtered = gaussian_filter(img, sigma=2.5)
imshow(img, img_filtered)
plt.show()

# First-order Gaussian filter
img = astronaut()
img_filtered = gaussian_filter(img, sigma=2.5, order=1)
imshow(img, img_filtered)
plt.show()

# 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()

Hessian matrix

from diptorch.filters import hessian, hessian_eigenvalues
from einops import rearrange
# 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()

# 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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diptorch-0.0.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

diptorch-0.0.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file diptorch-0.0.1.tar.gz.

File metadata

  • Download URL: diptorch-0.0.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for diptorch-0.0.1.tar.gz
Algorithm Hash digest
SHA256 01cb823e7ef783577c245e3d1bde8a5a4dbcc6b51becd5f60a350ed039124937
MD5 7021a5d069418edc655a30d587f62667
BLAKE2b-256 56bbbe27f171e96c61655c7ef087169672949a2a814426b06f7f97df2127a081

See more details on using hashes here.

File details

Details for the file diptorch-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: diptorch-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for diptorch-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c03e51d076f594e49170c4f79265ed324afffb0ec888547937c16c9151384b3
MD5 b10b6e228eddbcc025a3d153e486d82e
BLAKE2b-256 13d492cc1bc39a51652f61099534f372ba6b32bec87c1b1529f30d7373c3c9d6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page