improvement/modification of convolution and its application

This commit is contained in:
raymond 2025-09-09 08:42:37 +00:00
parent f104287921
commit 4cd58e04d4
2 changed files with 734 additions and 2 deletions

View file

@ -107,7 +107,7 @@ export function convolve1D(
validateArray(signal, 'Signal');
validateArray(kernel, 'Kernel');
const { mode = 'full', boundary = 'zero' } = options;
const { mode = 'same', boundary = 'reflect' } = options;
// Flip kernel for convolution (not correlation)
const flippedKernel = [...kernel].reverse();
@ -167,7 +167,7 @@ export function convolve2D(
validateMatrix(matrix, 'Matrix');
validateMatrix(kernel, 'Kernel');
const { mode = 'full', boundary = 'zero' } = options;
const { mode = 'same', boundary = 'reflect' } = options;
// Flip kernel for convolution
const flippedKernel = kernel.map(row => [...row].reverse()).reverse();