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

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


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.1.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.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: image_lowpass_filters-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2cbc4778b9952e34c3cbeb32cb1875547b68ef45af8e9788d0fac550e1e8f379
MD5 4690559765aa06feb781661a8ffe4aa4
BLAKE2b-256 0937d4c84a65b10c5e7c8456a204f3e3fbb0a927b389e6440a05c28fd9c7d8ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for image_lowpass_filters-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4e5e652af1d93527eed00a461ae352343fdef0c11db0c97d889877e792bdc48
MD5 613743b83157c0caba232e8d93c022c7
BLAKE2b-256 4543dd8692e2154a8c453597a8d98d80ff402c32ac7d813732c6363f60f9cb04

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