Skip to content

Convolution Operators

GPU-accelerated convolution operations.

gaussianBlur

cpp
GpuImage gaussianBlur(const GpuImage& input, int kernelSize, float sigma);

Applies Gaussian blur with specified kernel size and sigma.

Parameters:

  • input: Input image
  • kernelSize: Kernel size (must be odd, ≥3)
  • sigma: Standard deviation (>0)

Optimization: Uses shared memory tiling for efficient memory access.

sobelEdgeDetection

cpp
GpuImage sobelEdgeDetection(const GpuImage& input);

Detects edges using Sobel operator.

Returns: Edge magnitude image.

customConvolution

cpp
GpuImage convolve(const GpuImage& input, const float* kernel, int kernelSize);

Applies custom convolution kernel.

Parameters:

  • kernel: Flattened kernel weights (size × size elements)
  • kernelSize: Kernel dimension

Performance

Kernel4K ImageSpeedup vs CPU
5×5 Gaussian1.2 ms37.7×
3×3 Sobel0.9 ms42.3×
7×7 Custom2.1 ms31.1×

Back to API

Released under the MIT License.