Skip to main content

Fourier-Bessel wavelet scattering transforms

Project description

fbscatnet

PyPI version Python Versions License: MIT CI Code style: ruff

fbscatnet is a high-performance Python library for computing Fourier-Bessel wavelet scattering transforms. It generates robust, feature embeddings from 2D images, making it an ideal feature extractor for computer vision, biomedical imaging, and physics-based machine learning. This is a brand new project of mine that I have been working on for some time. I would love any criticism, improvements, corrections to both the code and the maths.

Features

  • Novel Wavelet: New wavelet relying on Bessel basis functions.
  • Hardware Accelerated: Seamlessly switch between multi-core CPU execution (scipy/joblib) and GPU acceleration (cupy).
  • Highly Optimized: Vectorised filtering in the frequency domain for maximum throughput across large image batches.
  • ML-Ready: Outputs flattened feature arrays directly compatible with scikit-learn, xgboost, or pytorch.

Installation

Install the base package (CPU-only) via pip:

pip install fbscatnet

To enable GPU acceleration, install with the gpu extra (requires a CUDA-compatible GPU):

pip install fbscatnet[gpu]

Quickstart

Extracting features from a dataset takes just a few lines of code:

import numpy as np
import logging
from fbscatnet import FourierBesselWaveletBank, FourierBesselScatNet, logger_config
logger_config.enable_colored_logs(logging.DEBUG) # IMPORTANT: SET TO SEE LOGS

# 1. Create some dummy image data (e.g., 10 grayscale images of size 64x64)
images = np.random.rand(10, 64, 64)

# 2. Instantiate a Fourier-Bessel Wavelet Bank
# size: spatial dimension (64x64), m: angular order, k: radial roots
bank = FourierBesselWaveletBank(size=64, m=2, k=2, sigma=0.1)

# 3. Initialize the Scattering Network
# Use backend="gpu" if you installed with CuPy
net = FourierBesselScatNet(bank=bank, backend="cpu")

# 4. Generate feature embeddings
# downsize: spatial pooling factor (must evenly divide the image size)
features = net.generate_embeddings(images, downsize=4, use_multiprocessing=True)

print(f"Generated embeddings shape: {features.shape}")
# Output: (10, feature_dimension)

Visualising Wavelet Maps

If you want to inspect how the wavelet filters are interacting with your image at the first scattering order, fbscatnet includes a built-in plotting tool:

# Pass a single 2D image to visualize
single_image = images[0]
net.visualise_maps(single_image, downsize=4)

API Overview

Sphinx documentation at: https://smee18.github.io/FourierBesselWavelets/

The example folder also contains a full pipeline, classifying MNIST using the library The pdf of my notes taken along this project contains an in-depth explanation of the mathematics behind these wavelets. Here you can find all derivations, proofs and useful information. Some stuff might seem trivial but my goal is to really expose all aspects so anyone new to wavelet theory can understand the mathematics behind these Fourier Bessel wavelets.

License

This project is licensed under the MIT License.

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

fbscatnet-1.0.0.tar.gz (264.1 kB view details)

Uploaded Source

Built Distribution

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

fbscatnet-1.0.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file fbscatnet-1.0.0.tar.gz.

File metadata

  • Download URL: fbscatnet-1.0.0.tar.gz
  • Upload date:
  • Size: 264.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fbscatnet-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3c67f84a0c41389982e9ed6103aa615f0d1fdb1914ccca081ab92c2ef5e54766
MD5 b4fe838f332c9aa8c50cc2be066f068a
BLAKE2b-256 680964b34150e930e8eda264806c17b2c864a043307c47b32b16b394c782690d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fbscatnet-1.0.0.tar.gz:

Publisher: publish.yaml on Smee18/FourierBesselWavelets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fbscatnet-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fbscatnet-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fbscatnet-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 84d144441706a3fb0df7fe8e9798f07ae9821baa1229b37845c417a4e6d8b019
MD5 7b36b72526a6a5d962d8481849f3ce79
BLAKE2b-256 64fce32ade16076bc20e43eb1f1f2dbccc9faa6b3f5b63aff530627be36942db

See more details on using hashes here.

Provenance

The following attestation bundles were made for fbscatnet-1.0.0-py3-none-any.whl:

Publisher: publish.yaml on Smee18/FourierBesselWavelets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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