Ideal, Butterworth and Gaussian frequency‐domain filters for PyTorch
Project description
Low-pass filters
Assume there is an image in spatial domain $f(u, v)\in\mathbb{R}^{m\times n}$, and its representation in shifted frequency domain $F(u, v)$, therefore the low-pass filtering is $H(u,v)*F(u, v)$, where
Ideal
$$H(u, v)=\begin{cases} 1, D(u, v) < D_0 \ 0, D(u, v) > D_0 \end{cases}$$
where $D(u,v)$ is the distance to the matrix center for each pixel, and $D_0$ is the cutoff frequency.
Butterworth
$$H(u, v)=\frac{1}{1+[D(u, v)/D_0]^{2n}}$$
Gaussian
$$H(u, v)=e^{-D^2(u, v)/2{D_0}^2}$$
Usage
Install from pypi:
pip install image-lowpass-filters
examples:
import torch
from image_lowpass_filters import ideal_bandpass, butterworth, gaussian
cutoff = 20
img_tensor = torch.randn((1, 3, 224, 224))
img_lowpass = ideal_bandpass(img_tensor, cutoff)
img_lowpass = butterworth(img_tensor, cutoff, 10)
img_lowpass = gaussian(img_tensor, cutoff)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file image_lowpass_filters-0.1.2.tar.gz.
File metadata
- Download URL: image_lowpass_filters-0.1.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09e7d5a2809884cf16641bcca9de4f9e467c19b5893b49754c934ca0717b031a
|
|
| MD5 |
4e2a646b207c08179ef5e417236d7799
|
|
| BLAKE2b-256 |
bf1552d1f8c653196083b84bdaa5396415016d398b0682dea2d5c835648f32f2
|
File details
Details for the file image_lowpass_filters-0.1.2-py3-none-any.whl.
File metadata
- Download URL: image_lowpass_filters-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a2af84e37eb40a1eb0a01cbf4adffcf128023856a056019098c34f2fbda8e49
|
|
| MD5 |
5417558958b490054df6d378035e1a6c
|
|
| BLAKE2b-256 |
ec1f59ecbcdb5cecc54c242729216ec0b40817c780bb30a19c4775f9a48fc8aa
|