std1.0.0-beta-7 SafeC docs

Module dsp::imaging

#include <std/dsp/imaging.h> source

2D DSP (imaging)

The 2D analogues of std/dsp's 1D building blocks: conv2d is 2D convolution with zero-padded ("same" size) boundaries; fft2d/ifft2d are the row-column-decomposition 2D FFT (apply the existing 1D fft.h transform to every row, then to every column — the standard way to get a 2D FFT from a 1D one, exact because the 2D DFT is separable); the kernel generators are the handful of convolution kernels almost every image pipeline needs (Gaussian blur, Sobel edge gradients).

Functions

conv2d'img' is hw row-major; 'kernel' is khkw row-major (kh, kw should be odd so the kernel has a well-defined center tap); 'out' must have room for h*w doubles (same size as 'img' — out-of-bounds kernel taps read as zero, i.e. zero-padded boundary handling).
fft2dIn-place 2D FFT/IFFT via row-column decomposition. Both h and w must be powers of two (see fft.h).
ifft2d
gaussian_kernelFills a size*size buffer (size should be odd) with a normalized (sums to 1) 2D Gaussian kernel of standard deviation 'sigma'.
sobel_x_kernelFixed 3x3 Sobel gradient kernels (horizontal/vertical edge response); 'kernel' must have room for 9 doubles, row-major.
sobel_y_kernel
conv2d_f32Single precision: conv2d / fft2d / ifft2d on float and Complex32, same contracts (kernels can come from the double helpers above, rounded).
fft2d_f32
ifft2d_f32