improvement/modification of convolution and its application
This commit is contained in:
parent
f104287921
commit
4cd58e04d4
2 changed files with 734 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue