% % Optical Imaging and Spectroscopy % % David J. Brady % Duke University % www.opticalimaging.org % % function cc=circConv(a,b) %circular convolution of equal size square matrices if size(a)==size(b) leng=size(a,1); cc=zeros(leng); for i=1:leng xv=mod(i:(leng+i-1),leng)+1; for j=1:leng yv=mod(j:(leng+j-1),leng)+1; ar=a(xv,yv); cc(i,j)=sum(sum(ar.*b)); end end else error('matrices must be the same size') end