How to calculate the delta of filter matrix

{moderator edit - quiz question and answers removed}

I found the delta value matrix as below:
37 6 16
-6 -2 -2
8 -12 -20
How to decide what kind of edge it detects?Did’t see obvious high value on any axis? If it detects horizontal edge, how come some values in third row are lower?

Anyone elaborate? Many thanks.

That filter is a vertical edge detector. This was the example that Prof Ng used in the lectures to explain how convolutions work. I’m not sure what you mean by the “delta matrix” that you calculated. The point is what the output of the filter looks like when you process an input image containing a vertical edge with it. Rather than have me try to explain it again here, I recommend you go watch that lecture again. He also discusses filters for edges with other orientations to generalize the idea.


I used the above method and the same input matix,
the filter matrix from the question, hyperparameters as (f=4, s=1, p=0)
0 1 -1 0
1 3 -3 -1
1 3 -3 -1
0 1 -1 0
Then I get the output matix below:
37 6 16
-6 -2 -2
8 -12 -20
My question is I didn’t see a vertical edge pattern from the output matrix. If we use the filter to find edges, how do we see what kind of edge we get from the output matrix?

That input matrix does not contain a vertical edge. You have to watch the lecture all the way through to find the relevant example. The vertical edge example starts at about 8:10 into that video.

If change the input matrix to this (having vertical edge):
10 10 10 0 0 0
10 10 10 0 0 0
10 10 10 0 0 0
10 10 10 0 0 0
10 10 10 0 0 0
10 10 10 0 0 0
then the output is
20 100 20
20 100 20
20 100 20
Now it does look like a vertical edge.
If the input matrix looks like this (having horizontal edge):
10 10 10 10 10 10 10
10 10 10 10 10 10 10
10 10 10 10 10 10 10
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
then the ouput matrix is all zero.
If the filter is symmetic with respect to the y axis then it will cancel out the values which are also symmetric with respect to the y axis.

Kind of get it. Thank you.

A horizontal edge could also look like:

0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10

And you’d need a different filter to detect that. Try taking the transpose of the vertical filter and watch what happens. It’s been a while since I watched these lectures, but I’m pretty sure I remember Prof Ng talking about how to generalize this.

1 Like