Skip to content

Commit

Permalink
Add Gaussian filtering tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenvivek committed Aug 8, 2024
1 parent 010314f commit 01226f6
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 2 deletions.
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# diptorch

diptorch
================

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

Expand All @@ -8,3 +8,66 @@
``` sh
pip install diptorch
```

## Hello, World!

``` python
import matplotlib.pyplot as plt

from diptorch.filters import gaussian_filter
from diptorch.utils import astronaut
```

``` python
# Zero-th order Gaussian filter (smoothing)
img = astronaut()
img_filtered = gaussian_filter(img, sigma=2.5)

plt.figure(figsize=(6, 3))
plt.subplot(121)
plt.imshow(img.squeeze(), cmap="gray")
plt.axis("off")
plt.subplot(122)
plt.imshow(img_filtered.squeeze(), cmap="gray")
plt.axis("off")
plt.tight_layout()
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)

plt.figure(figsize=(6, 3))
plt.subplot(121)
plt.imshow(img.squeeze(), cmap="gray")
plt.axis("off")
plt.subplot(122)
plt.imshow(img_filtered.squeeze(), cmap="gray")
plt.axis("off")
plt.tight_layout()
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])

plt.figure(figsize=(6, 3))
plt.subplot(121)
plt.imshow(img.squeeze(), cmap="gray")
plt.axis("off")
plt.subplot(122)
plt.imshow(img_filtered.squeeze(), cmap="gray")
plt.axis("off")
plt.tight_layout()
plt.show()
```

![](index_files/figure-commonmark/cell-5-output-1.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 115 additions & 0 deletions notebooks/index.ipynb

Large diffs are not rendered by default.

0 comments on commit 01226f6

Please sign in to comment.