I implemented my filtering algorithm using the following steps:
My filter function code was as follows:
%filter function
function output = my_imfilter(image, filter)
vert = floor(size(filter, 1)/2);
horz = floor(size(filter, 2)/2);
res = size(image);
padded(:,:,:) = padarray(image(:,:,:), [vert horz]);
new = zeros(res);
for i=vert+1:res(1)+vert
for j=horz+1:res(2)+horz
for k=1:res(3)
dotted = padded(i-vert:i+vert, j-horz:j+horz, k) .* filter;
new(i-vert,j-horz,k) = sum(dotted(:));
end
end
end
output = new;
My implementation did not run as quickly as the standard Matlab standard implentation, but the run time was still acceptable. It was able to apply the six filters in the test script in around 25 seconds, making it around 5 times slower than the Matlab standard implementation. Here are the outputs from the test script:
I constructed the hybrid image with the following steps:
The code was as follows:
%construct hybrid image
low_frequencies = my_imfilter(image1, filter);
high_frequencies = image2 - my_imfilter(image2, filter);
hybrid_image = low_frequencies + high_frequencies;
I ran this with a few of the image pairs to see the results. I found that tinkering with the standard deviation of the Gaussian blur filter had a great effect on the image. When the blur is smaller, the blurred (lower frequency image) shows more clearly. When the blur is larger, the high frequency image is clearer. This is an intuitive result, but it was still interesting to play with it and see the effects. The results are below: