Project 1: Image Filtering and Hybrid Images

My hybrid cat dog image.

When implementing my_imfilter I wrote a separate method that would handle extracting the square from the image matrix. This way I could perform the actual filtering using simple matlab matrix operations. When creating the method to extract the square from the matrix I decided to go with the wrap around method for handling edge cases. Specifically, I have the wrap around stay within the size of the filter. So, instead of having the image wrap from the left side of the image to the right I simply have it grab valid values that are already in the square of the filter. I did this instead of complete boundary wrapping to prevent the color bleed from opposite sides of the image that the professor mentioned in class.


%code snippet I used for handling wrapping at the left boundary
x = r - floor(filterDim(1)/2) + i - 1;
if x <= 0
    x = width - (x + 1);
end
y = c - floor(filterDim(2)/2);
if y <= 0 
    section(i, 1:(1-y)) = Image(x, 1:(1-y), color);
    section(i, (1-y)+1:length) = Image(x, 1:(y+length-1), color);
end

Results

I used a cutoff_frequency of 8 for the bird plane image and 10 for the fish sub image. I chose those values because they seemed to give the most color to the image while still having the hybrid image properties. Thats also why I picked the sub and bird to use as the low frequencies. I also obtained an image of the moon and some swiss cheese to create a hybrid image of my own which is shown in the 3rd row.