Edge Detection

How the convolution operation works

Suppose you have an input matrix (image) of dimensions 6x6x1 (not rgb), we construct another 3x3 matrix which is called a filter (also called the kernel). This matrix is then convolved ("$*$") with the input matrix.

The first element of the output matrix will be the sum of the element-wise multiplication of the filter and image.

We repeat the operation for the next elements too by shifting the filter by one stride. A 6x6 input matrix with 3x3 filter gives a 4x4 matrix as output.

Vertical Edge Detection

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/909f8de3-fa0b-4714-81e5-b49297034814/Untitled.png

More Edge Detection

If we flip the input image, with the same filter, we get a negative (very dark) output.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e9327f49-4148-4bb2-ac5b-a148ff072c8e/Untitled.png

Vertical vs Horizontal Edge Detector

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/aed8a4a6-7fe0-4412-a799-d617a9af48e0/Untitled.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b098f112-4f0b-4e5c-9e3f-533adf8fc6a0/Untitled.png

The elements in the kernel are parameters that are learned by the model using backpropagation.

Padding

General formula for determining the dimension of the output matrix

$n-f+1$ where,

There are certain downsides to this method