Project 1: Image Filtering and Hybrid Images

Algorithm Description

I'll first just give you a summary of the code. From lines 40 - 47 I check for color channels and make set the number of colors (numColors) appropiately. In these line I also initialize dimVector which contains the result of size called on the image. From lines 49 - 64 I initiliaze all the variables needed for the for loop. This includes padding the array with m/2, and n/2 zeroes (with a m * n filter), and initiliazing the output matrix. Lines 72- 95 I do the actual iteration neccesary for applying the filter to each neighborhood in the image. This involves getting the correct subsection/neighborhood of the padded array and then multiplying that term by term with the filter. Then the actual activation is the sum of the term by term multiplication between the subsection and the padded array.

I did the multiplication of the filter and the current subsection by just multiplying the matrices to avoid having another two nested loops. I tried to add enough comments so that anyone could easily read and understand my code step by step.

Filter Results

Below are the results from the applying the filters to the cat image. These results (using my_imfilter) all match the result from using matlab's built-in imfilter.

Notice how difficult it is to see the laplacian filter (fourth from the left) which would be essentially black without adding .5 to all pixels. The high pass filters (3 and 4 from the left) both show reduced color since colors usually have lower spatial frequency. The first image and the last are both blurs with the last one having a stronger blurring effect. The second image is the sobel filter which acts as an edge detector.

Hybrid Images Results

Below are the results from the hybrid images. The first column is the low frequency components of each image. The second column is the high frequency component. The third column is the hybrid image. The scaled images are shown separately below as well since they need to be large enough in order to see the scaling well.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.