Expand description
Image processing operations using 2D FFTs.
This module provides common image processing tasks that leverage 2D FFTs for efficient computation:
- Convolution and correlation
- Spatial filtering (low-pass, high-pass, band-pass)
- Edge detection in frequency domain
- Image sharpening and blurring
§Performance
FFT-based convolution is faster than spatial convolution for large kernels (typically > 7x7), due to the convolution theorem: multiplication in the frequency domain is equivalent to convolution in the spatial domain.
§Examples
use spectrograms::image_ops::{gaussian_kernel_2d, convolve_fft};
use spectrograms::nzu;
use ndarray::Array2;
// Create a 256x256 image
let image = Array2::<f64>::zeros((256, 256));
// Apply Gaussian blur
let kernel = gaussian_kernel_2d(nzu!(9), 2.0).unwrap();
let blurred = convolve_fft(&image.view(), &kernel.view()).unwrap();Functions§
- bandpass_
filter - Apply band-pass filter (keep frequencies in a specific range).
- convolve_
fft - Convolve 2D image with kernel using FFT (faster for large kernels).
- detect_
edges_ fft - Detect edges in an image using high-pass filtering.
- gaussian_
kernel_ 2d - Create 2D Gaussian kernel for blurring.
- highpass_
filter - Apply high-pass filter (suppress low frequencies).
- lowpass_
filter - Apply low-pass filter (suppress high frequencies).
- sharpen_
fft - Sharpen an image by enhancing high frequencies.