Skip to main content

Spatial and Bilateral filtering using Gaussian KDTree data structures

Project description

GuasKDTreeFiltering

PyPI version License: MIT Python 3.9+

A high-performance Python library for efficient spatial and bilateral filtering using Gaussian KDTree data structures. This implementation is based on the research paper "Gaussian KD-Trees for Fast High-Dimensional Filtering" from Stanford Graphics Lab.

🚀 Features

  • Spatial Filtering: Efficient spatial smoothing using KDTree and Gaussian kernels
  • Bilateral Filtering: Edge-preserving smoothing for high-quality image processing
  • High-Dimensional Support: Optimized for multidimensional data processing
  • Fast Performance: Leverages KD-tree data structures for efficient neighborhood queries
  • Easy Integration: Simple API for quick integration into existing workflows

📦 Installation

From PyPI (Recommended)

pip install GuasKDTreeFiltering

From Source

git clone https://github.com/enugalamanideepreddy/GuasianKDTreeFiltering.git
cd GuasianKDTreeFiltering
pip install -e .

🎯 Quick Start

Basic Usage

import numpy as np
from GuasKD import BilateralFiltering

# Create a bilateral filter instance
bf = BilateralFiltering(
    sigma_spatial=1.0,    # Spatial sigma
    sigma_color=0.1,      # Color sigma
    sigma_b=0.05,         # Blur sigma
    samples=32,           # Number of samples
    leaf_size=10          # KDTree leaf size
)

# Create test image (H, W, C format)
image = np.random.rand(100, 100, 3).astype(np.float32)

# Apply bilateral filtering
filtered_image = bf(image, image, mode='Bilateral')

Advanced Usage

from GuasKD import BilateralFiltering
import numpy as np

# Create filter with custom parameters
bf = BilateralFiltering(
    sigma_spatial=2.0,    # Larger spatial smoothing
    sigma_color=0.2,      # More color smoothing
    sigma_b=0.1,          # More blur
    samples=64,           # More samples for better quality
    leaf_size=8,          # Smaller leaves for precision
    fallback_mode='nearest'  # Fallback for edge cases
)

# Process different image types
image = np.random.rand(64, 64, 3).astype(np.float32)

# Bilateral filtering (preserves edges)
bilateral_result = bf(image, image, mode='Bilateral')

# Spatial filtering (smooths everything)
spatial_result = bf(image, image, mode='Spatial')

📚 API Reference

BilateralFiltering Class

Constructor Parameters

Parameter Type Default Description
sigma_spatial float 1.0 Spatial smoothing parameter
sigma_color float 0.1 Color/intensity smoothing parameter
sigma_b float 0.0 Blur parameter in KDTrees High Dimensional Filtering
samples int 32 Number of samples for filtering
leaf_size int 10 KDTree leaf node size
fallback_mode str 'nearest' Fallback strategy for edge cases
min_samples int 4 Minimum samples per query

Methods

__call__(image, values, mode)

Main filtering method.

Parameters:

  • image (np.ndarray): Input image in (H, W, C) format
  • values (np.ndarray): Values to filter (usually same as image)
  • mode (str): Either 'Bilateral' or 'Spatial'

Returns:

  • np.ndarray: Filtered image with same shape as input

🔬 Research Background

This implementation is based on the research paper:

"Gaussian KD-Trees for Fast High-Dimensional Filtering"

The library provides an efficient implementation of the Gaussian KDTree approach for high-dimensional filtering operations, making it suitable for:

  • Image denoising
  • Edge-preserving smoothing
  • High-dimensional data processing
  • Real-time filtering applications

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Stanford Graphics Lab for the original research
  • The open-source community for inspiration and feedback

📞 Support

If you encounter any issues or have questions:

  • Issues: GitHub Issues
  • Documentation: Check the docstrings and examples above
  • Research: Refer to the original paper for theoretical background

Made with ❤️ for the computer vision and image processing community

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

guaskdtreefiltering-0.1.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

guaskdtreefiltering-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: guaskdtreefiltering-0.1.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for guaskdtreefiltering-0.1.1.tar.gz
Algorithm Hash digest
SHA256 870d5a7286969c9218f7094d6cc310a1953a4ce7cd037dc8b8cb2746561cfb99
MD5 c97c7966bc5986ba7209063d8ac3dfbc
BLAKE2b-256 5c7cd5477150ef1c729964ac2db19c955719cd298e46e814c79c32ec932f722b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for guaskdtreefiltering-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b94b5af37238fa1b0a2b484885e123376f37ff15a3952e06c68b7a2ff22f3fde
MD5 604d0af6e9d6562c3e023fbc0f8f5b58
BLAKE2b-256 14067743ba788ff714d9358cd162c0739f3bad20f040bfb93d248cba9a3a1da0

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