Code covered by the BSD License  

Highlights from
Separable N-Dimensional Convolution

from Separable N-Dimensional Convolution by Igor Solovey
N-dimensional convolution for separable kernels, similar to functionality of "conv2(hcol, hrow, A)"

test01.m
clc
close all
clear

%normalized gaussian kernel
a=[.0003 .1065 .7866 .1065 .0003]; 
n=length(a);

%make a 4D kernel

b=a;
for d=2:4
    b=kron(b,a');
end
H=reshape(b,n*ones(1,4));

%make a test matrix
A = randn(64,64,64,64);

%compare execution times
tic
B = convn(H,A);
toc

tic
B2 = convnsep({a,a,a,a},A);
toc

%compare error to size of the result of convn
norm(B(:)-B2(:))
norm(B(:))

Contact us