Project 1: Image Filtering and Hybrid Images

Example of a generated Hybrid Image

This assignment focuses on implementing image filtering(using various filters like low pass, high pass, identity etc.) and creating hybrid images(images that seem different based on distance/angle of perception) using two different filtered images.

  1. Image filtering : The images are padded with mirroring(which is better than padding with zeros) based the dimensions of the filter and the dimensions of the image. Then the filter is applied looping through all the pixeles of the image. The filtering is done on all 3 color channels (R,G,B) independent of eachother. After the filtering is done, the padding pixels are removed from the image and the output is returned. The results of applying vaarious filters to a cat image is shown in the first section of images below.
  2. Hybrid images : Hybrid images are obtained by overlaying (or adding corresponding pixel values) two images, one that has been filtered by a low pass filter and another by a high pass filter. The cutoff frequency is adjusted based on every pair of images so as to obtain best reults. The cutoff frequency decides how much high frequncy to remove and how much low frequency to leave correspondingly. The appearence of the image formed by addition of the two (hybrid) is percieved differently from different distances. Downsampling and scaling is done to show this effect (see last column in resulting images).

Image Filtering code snippet

						
for dim=1:size(img,3)
    
    for m=(filter_size_1+1)/2:size(img,1)-(filter_size_1-1)/2
        
        for n=(filter_size_2+1)/2:size(img,2)-(filter_size_2-1)/2
            
            output(m-(filter_size_1-1)/2,n-(filter_size_2-1)/2,dim)=
				sum(sum(filter.*img(m-(filter_size_1-1)/2:m
						+(filter_size_1-1)/2,n-(filter_size_2-1)/2:n+(filter_size_2-1)/2,dim)));         
        end
    end
end																

Generating Hybrid Images

						
low_frequencies = my_imfilter(image1,filter);

high_frequencies = image2-my_imfilter(image2,filter);

hybrid_image = low_frequencies + high_frequencies;

Image Filtering

Identity Image Laplacian Image High Pass Image Blur Image Sobel Image

Hybrid Images

Image 1 after LPF Image 2 after HPF Hybrid Image Downsampled to different scales