Skip to main content

GaussianBlur

Continuous Integration coverage license

GaussianBlur provide a high-performance interface to the underlying LibGaussianBlur C++ library, enabling efficient Gaussian blur image processing through a simple Python API.

Overview

LibGaussianBlur is a C++ library designed to apply Gaussian blur to images using the Fast Fourier Transform (FFT) multi-threaded for tiles. The Python bindings expose this powerful functionality in a user-friendly way, integrating with popular Python imaging libraries such as Pillow and numpy.

Key features include:

  • FFT-based Gaussian Blur: Apply precise Gaussian blur using FFT techniques.
  • Optimized Performance: Leverages parallel tile processing and multi-threading.
  • Cross-Platform Support: Efficiently processes images on multiple operating systems.
  • Flexible API: Easily integrate with existing Python image processing workflows.

Example Requirements

Note: The following packages are only required for running the usage example and are not mandatory dependencies of the module itself.

  • Python >= 3.11
  • Pillow – for image loading and saving
  • numpy – for numerical operations

Installation

Install the module from PyPI:

pip install gaussianblur

Alternatively, you can build it from source if needed. Make sure the underlying C++ library and its dependencies are correctly configured.

Usage Example

Below is a simple example demonstrating how to use the gaussianblur module:

from PIL import Image as PILImage
import numpy as np
import gaussianblur

# This is a simple example of how to use the gaussianblur module in Python.
def main():
    input_file = "input.png"
    output_file = "output.png"
    
    # Load image using Pillow
    pil_img = PILImage.open(input_file)
    
    # Create an instance of the gaussianblur.Image object
    img = gaussianblur.Image()
    img.geom.rows = pil_img.size[1]
    img.geom.cols = pil_img.size[0]
    img.geom.channels = len(pil_img.getbands())
    img.data = np.array(pil_img).flatten().tolist()
    
    # Set the sigma value for the Gaussian blur
    sigma = 7.5
    
    # If True, the alpha channel will be blurred as well (if present)
    apply_to_alpha_channel = True
    
    # Apply Gaussian blur
    gaussianblur.gaussianblur(img, sigma, apply_to_alpha_channel)
    print("Gaussian blur applied.")
    
    # Save the output image
    out_np_img = np.array(img.data, dtype=np.uint8).reshape(img.geom.rows, img.geom.cols, img.geom.channels)
    PILImage.fromarray(out_np_img, pil_img.mode).save(output_file)
    print("Output written to", output_file)

if __name__ == "__main__":
    main()

How It Works

The Python module leverages the robust and efficient algorithms implemented in the underlying C++ library:

  • Centered Kernel Generation: Automatically generates a centered Gaussian kernel to avoid circular convolution artifacts.
  • FFT-based Convolution: Performs FFT on both the kernel and image tiles to achieve efficient, high-performance convolution in each dimension and for each tile.
  • Multi-threading & SIMD Optimizations: Ensures speedy processing without fearing any large images, thanks to FFT and parallel processing.

Additional Information

For more details about the underlying C++ library and its capabilities, please refer to the LibGaussianBlur repository.

Contributing

Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the Apache-2.0 License. See the LICENSE file for details.

Metadata

Release files for gaussianblur 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for gaussianblur 1.1.2
File Interpreter ABI Platform
gaussianblur-1.1.2-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details
gaussianblur-1.1.2-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details

Total release size: 260.5 kB

Release files / gaussianblur-1.1.2-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL gaussianblur-1.1.2-cp311-cp311-manylinux_2_34_x86_64.whl
Size 145.7 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
ce38046e9d0dbe038b9e48fdb81952a3bebdca5d0dae769daa837fce4534a3db
BLAKE2b-256 checksum
How to use checksums
4759e87bca8a64d33b9d5adda19cc6e5bec874a59aa44a3be06a0400dbc83527
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.10

Release files / gaussianblur-1.1.2-cp311-cp311-macosx_15_0_arm64.whl

Download URL gaussianblur-1.1.2-cp311-cp311-macosx_15_0_arm64.whl
Size 114.8 kB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
bffebbd70dd5c12cba37e91819b1270752df78b6e678f19fead7d811cd11436c
BLAKE2b-256 checksum
How to use checksums
a8f4915cee910715781c6a2c772e6e859df7ce6e24355a603c283a5e7616be8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.10

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page