Skip to main content

Module image_ops

Module image_ops 

Source
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.