Last active
January 13, 2016 09:39
-
-
Save jvlmdr/bf88afc66afe66f80bfc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Computes circulant covariance of a and then multiplies x by covariance. | |
% Both images are of size (m1, m2) with k channels. | |
% | |
% size(a) is [m1, m2, k] | |
% size(x) is [m1, m2, k] | |
function b = mul_circ_covar(a, x) | |
[m1, m2, k] = size(x); | |
% compute circulant covariance from shifts of a | |
% sf(u1,u2,p,q) = conj(af(u1,u2,q)) * af(u1,u2,p) | |
af = fft2(a); | |
sf = bsxfun(@times, permute(conj(af), [1, 2, 4, 3]), af); | |
% multiply x by covariance | |
% bf(u1,u2,p) = sum_q sf(u1,u2,p,q) * xf(u1,u2,q) | |
xf = fft2(x); | |
bf = sum(bsxfun(@times, sf, permute(xf, [1, 2, 4, 3])), 4); | |
b = ifft2(bf, 'symmetric'); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment