Answer the question
In order to leave comments, you need to log in
How to use 5x5, 7x7, ... matrix in Sobel filtering?
Good afternoon!
I can't figure out where the coefficients in the matrices come from:
www.cim.mcgill.ca/~image529/TA529/Image529_99/assi...
please explain.
And how to expand the matrix to the size of 7x7 9x9 and so on?
Answer the question
In order to leave comments, you need to log in
In Wikipedia, it is beautifully painted: the Sobel operator is an ordinary gradient with weight coefficients. Obtained by convolution of two matrices: gradient in the desired direction (say, [-1/2 0 1/2] - Dx_{x,y} = (M_{x+1,y} - M_{x-1,y})/ 2) and weight coefficients (say, [1; 2; 1]/4 = [1/4;1/2;1/4]) → [-1/8 0 1/8; -1/4 0 1/4; -1/8 0 1/8]. Naturally, there is no strict gradient here - you are free to choose any weight coefficients you like.
You can also expand the gradient matrix. If we take a 5x1 kernel, we get: Dx_{x,y} = [(M_{x+1,y} - M_{x-1,y})/2) + (M_{x+2,y} - M_ {x-2,y})/4)]/2 → [-1/8 -1/4 0 1/4 1/8]. By weights we can take, for example, the matrix [1;2;4;2;1].
Similarly for matrices 7x7, 9x9 and more.
This is called the convolution kernel. https://ru.wikipedia.org/wiki/%D0%A1%D0%B2%D1%91%D...
Understand how the convolution of two functions works (or in the context of image processing - convolution of sequences) - no questions will.
In general, the Sobel operator, as far as I remember, uses only 3x3 kernels.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question