# necessity of patch size in edge detection algorithms

I have recently started learning about the image edge detection methods. I studied few of these methods including Sobel and Canny. I observed that edge detection is performed using patch/kernel size as 3x3.

My question is, Is it necessary to fix the patch size as 3x3? OR can we take it as 5x5, 7x7, 9x9 etc.

I have already studied few technical papers that says that patch size is taken as low as possible in order to make computational complexity as low as possible

Let's start to given some information.

We now that the sobel operator perform a aproximmation of the image gradient using convolution ( $*$ ).

Then,

Being $\mathbf{A}$ an image of $n \times m$ size.

The operator $\mathbf{K}$, commonly, uses two $3 \times 3$ kernels which are convolved with the original image. Thus we have

$\mathbf{G_x} = \mathbf{K_x} * \mathbf{A}$

$\mathbf{G_y} = \mathbf{K_y} * \mathbf{A}$

Being $$\mathbf{K_x} = \left[ {\begin{array}{cc} -1 & 0 & +1\\ -2 & 0 & +2\\ -1 & 0 & +1\\ \end{array} } \right]$$

And,

$$\mathbf{K_y} = \left[ {\begin{array}{cc} -1 & -2 & -1\\ 0 & 0 & 0\\ +1 & +2 & +1\\ \end{array} } \right]$$

So, an extension of this kernel is a $5 \times 5$ matrix

$$\mathbf{K_y} = \left[ {\begin{array}{cc} -1 & -4 & -6 & -4 & -1\\ -2 & -8 & -12 & -8 & -2\\ 0 & 0 & 0 & 0 & 0\\ +2 & +8 & +12 & 8 & 2\\ +1 & +4 & +6 & +4 & +1\\ \end{array} } \right]$$

$$\mathbf{K_x} = \left[ {\begin{array}{cc} +1 & +2 & 0 & -2 & -1\\ +4 & +8 & 0 & -8 & -4\\ +6 & +12 & 0 & -12 & -6\\ +4 & +8 & 0 & -8 & -4\\ +1 & +2 & 0 & -2 & -1\\ \end{array} } \right]$$

This article demonstrates how to get Sobel gradient operators analytically. For that was using linear approximation of brightness in window 3x3. Every pixel in window has its own weight. Special weight matrix selection gives Sobel gradient operator.