Overall, the code for this project was fairly simple. Once my_imfilter was written, proj1.m was easy. All I had to do was call my_imfilter with the provided filter, and do a single subtraction and addition
my_imfilter was marginally more complex. The first step was to find the sizes of the image and filter. I then need to process each channel. I pull it out, pad it with zeros, and then go through each pixel location in the original channel. I pull out a filter-sized section of the padded layer centered on the location of the original pixel, multiply the elements of that with the filter, sum the result, and put the result back into the right location on the original image. When I've done that for each layer, I return the image. The nice thing is that a 2 dimensional array can be treated as a 3 dimensional array where the third dimension is 1, so I don't need to do anything special to handle greyscale images.
original high-frequency image |
![]() |
original low-frequency image |
![]() |
generated high frequencies image |
![]() |
generated low frequencies image |
![]() |
final hybrid image |
![]() |
scaled versions of hybrid image |
![]() |
You can see the effects of padding in the intermediate images -- the low frequency image is darker around the edges. The high frequency image is lighter around the edges because the darker edges from the filtered image were subtracted from the original image. Other than that, everything looks pretty much how it is supposed to.