In this project, I implenment a image filter, then use it to create hybrid images.
%my_imfilter
[m,n,o]=size(image);
[a,b]=size(filter);
a=(a-1)/2;
b=(b-1)/2;
A=padarray(image,[a,b],'symmetric');
output=zeros(size(A));
for k=1:o
for i=a+1:a+m
for j=b+1:b+n
output(i,j,k)=sum(sum(A(i-a:i+a,j-b:j+b,k).*filter));
end
end
end
output=output(a+1:a+m,b+1:b+n,:);
inner two loops to compute each elements in the result matrix by summing the dot product of filter with same size of image matrix centered at correasponding entry. For boraders, I pad the orginal image with symmetric padding with width related to filter size.
the outer loop computes the image in different color channels then combine them to produce a new image.
orginal image |
identity filter |
blur filter |
1d Gaussian Filter |
sobel_filter |
laplacian_filter |
orginal-blur |
%my_imfilter
cutoff_frequency = 7
low_frequencies = my_imfilter(image1,filter);
high_frequencies = image2-my_imfilter(image2,filter);
hybrid_image = low_frequencies+high_frequencies;
low frequency image is the result of applying Gaussian filter to image1
high frequency image is the result of image2
subtract Gaussian filtered image2
hybrid_image is the sum of two filtered images.
low_frequencies |
high_frequencies | hybrid_image |
hybrid_image_scales |
low_frequencies |
high_frequencies | hybrid_image |
hybrid_image_scales |
low_frequencies |
high_frequencies | hybrid_image |
hybrid_image_scales |