Made by: Pranjal Gulati
Implement the convolution operation and image processing kernels from scratch. The following three kernels need to implemented:
- Sobel X Kernel: for gradients in X direction
- Sobel Y Kernel: for gradients in Y direction
-
Gaussian Kernel (with
$\sigma = 1.4$ ): for smoothing
The code skeleton is as below:
def conv(image, kernel):
# implement conv operation here
raise NotImplementedError
def get_kernel(name):
# return the kernel based on the name
raise NotImplementedError
Use this image for the following steps:
- Apply the Gaussian filter on the image. Call the output
smoothened
- Apply the Sobel X and Sobel Y filters on
smoothened
. Call themsobel_x
andsobel_y
respectively. - Calculate the gradient magnitude:
$I_{xy} = \sqrt{I_x(x,y)^2 + I_y(x,y)^2}$ where$I_x$ issobel_x
,$I_y$ issobel_y
and$(x, y)$ represents a particular pixel. - Display this gradient magnitude
Read this article to understand how we backprop through conv layers efficiently.