The setup involves a few simple steps. First, created a padded version of the original image. Second, create an output matrix of the same size as the original image.
For the actual filtering, I iterated over the entires in the padded matrix which contained a value from the original image as my center pixel. Then, I did elementwise multiplicatoin between an array the same size as the filter centered at my iteration pixel and the filter. Then, I took the sum along both dimensions which gave me the sum of the entire elementwise multiplication. This became the value of the center pixel's position in the new result matrix.The following are a few examples of filtering with the respective filters, ones, Gaussian, high pass and Sobel filter.
![]() ![]() ![]() ![]() |
![]() ![]() ![]() ![]() |
The leftmost image is created by filtering image1 with a Gaussian (blur) filter. The second image is created by subtracting image2 from the the blurred version of itself (image2 also filtered with Gaussian (blur) filter.) The third image is adding the two images together.
The results are more clearly demonstrated in the rightmost image which is the image pyramid. As you can see, in the larger images it looks like a cat, while in the smaller image it looks like a dog. The following are several other results.
![]() ![]() ![]() ![]() |
![]() ![]() ![]() ![]() |
![]() ![]() ![]() ![]() |
![]() ![]() ![]() ![]() |