Reputation: 1157
A isthe kernel and B is an image. How do you find a convolution matrix out of this equation?
A(x,y) = B(x,y) + 4B(x+1,y-1) + 2B(x,y+1) + 5B(x-1,y)
And directions are as below
(x-1,y-1) (x-1,y) (x-1,y+1)
(x,y-1) (x,y) (x,y+1)
(x+1,y-1) (x+1,y) (x+1,y+1)
is the matrix below?
0 5 0
0 1 2
4 0 0
Upvotes: 0
Views: 308
Reputation: 8215
It depends on how you define your pixel coordinates. If the origin is at the right (!) bottom of the image, x
runs from bottom to top and y
from right to left, your matrix is correct. However this is quite an uncommon choice.
If your origin is at the bottom left, x
runs from left to right and y
runs from bottom to top, the matrix would be:
4 0 0
0 1 5
0 2 0
Note that the directions are inverted: For example, the matrix coefficient on the right of the center is applied to the picel on the left.
By the way, it is not correct that A
is the kernel for arbitrary B
. This is only the case for B[0,0] == 1
and B[x,y] == 0
for all other values of x
and y
.
Update:
So your x
runs from top to bottom and your y
from left to right. Then the convolution matrix is:
0 0 4
2 1 0
0 5 0
Upvotes: 1