4. Implement convolving a kernel with an image in code (you can implement this as a function,
or just as a script, whatever works for you). Specifically your code should takes two inputs:
an array representing an image of size M X N and an array representing a kernel of size
k × k where k is odd. Your code should pad your input image with the appropriate amount
of zeros, perform the convolution, and output the resulting image.
(a) Use your code to verify your answer to 2(a).
(b) Use your code on the image hw2img4.tif using a box kernel, defined as
$w(s,t) = \frac{1}{k^2}$,
of size k x k for k = 3, 11, and 21. Show each resulting image. Discuss the impact of
the choice of k on the output image. Discuss the impact of using zero padding.
(c) Repeat (b) using a Gaussian kernel, defined as
$w_G(s,t) = Ke^{-\frac{s^2+t^2}{2\sigma^2}}$,
of size 43 × 43 where $\sigma$ = 2, and 7. Use $K = \frac{1}{2\pi\sigma^2}$. Show each resulting image. Discuss
the impact of the choice of $\sigma$ on the output image. Discuss the impact of using zero
padding.
5. Propose another method for padding an image (other than zero padding) to combat the impact
seen in parts 4(b) and 4(c). You do not need to implement it in your code, just describe your
proposed method and explain why you think it would prevent the issue seen in 4(b) and 4(c).