The algorithm is just a straight-up implementation of the filtering formula.
[M, N, C] = size(image);
[m, n] = size(filter);
xpadding = (m - 1) / 2;
ypadding = (n - 1) / 2;
padded = padarray(image, [xpadding, ypadding]);
output = zeros(M, N, C);
for c = 1:C
for i = 1:M
for j = 1:N
output(i, j, c) = sum(sum(padded(i:(i + m - 1), j:(j + n - 1), c) .* filter));
end
end
end
Low frequencies of the dog picture
High frequencies of the cat picture
Hybrid image of a cat and a dog (𝞼 = 7)
Hybrid image of Einstein and Marilyn Monrow (𝞼 = 5). Here I had to replace the mean with a weighted sum and give a higher weight to Marilyn Monroe, because otherwise she was overshadowed by sharp Einstein (65% Monroe, 35% Einstein).
Hybrid image of a submarine and a fish (𝞼 = 5). This one required a weight sum as well (60% submarine, 40% fish).
Hybrid image of a bird and a plane (𝞼 = 7)
Hybrid image of a bicycle and a motorcycle (𝞼 = 5)
Hybrid image of me and my girlfriend (𝞼 = 7)