Skip to main content

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

examples:

import torch
from preprocess 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


Download files

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

Source Distribution

image_lowpass_filters-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

image_lowpass_filters-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file image_lowpass_filters-0.1.0.tar.gz.

File metadata

  • Download URL: image_lowpass_filters-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for image_lowpass_filters-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c297f9c2079c2d5ed7215c83ee7c3905765810bd2a098e2a6fd0b9bced59ea19
MD5 4d2d9244d31c4dbfae3527e12ea7ef23
BLAKE2b-256 36e9226f2c8ffdac0a99dab9ff4aecb63b385d20be2e7da96ea8e17d7ebfe2f5

See more details on using hashes here.

File details

Details for the file image_lowpass_filters-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for image_lowpass_filters-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a65f4e465cc6951d9afa4cadbf2cf868a759bf677237b02ccdbf9934beadd8a2
MD5 a5e5726b3648adcee9a59adfe703a8da
BLAKE2b-256 1254b8713c22b97db60d7e011ab931ccc0f91027f992a402859fd11dee6be9f6

See more details on using hashes here.

Supported by

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