Predefined Gradient Kernels
The following tables list the predefined gradient 3 × 3 kernels.
Prewitt Filters
The Prewitt filters have the following kernels. The notations West (W), South (S), East (E), and North (N) indicate which edges of bright regions they outline.
#0 W/Edge | #1 W/Image | #2 SW/Edge | #3 SW/Image |
-1 0 1 -1 0 1 -1 0 1 |
-1 0 1 -1 1 1 -1 0 1 |
0 1 1 -1 0 1 -1-1 0 |
0 1 1 -1 1 1 -1-1 0 |
#4 S/Edge | #5 S/Image | #6 SE/Edge | #7 SE/Image |
1 1 1 0 0 0 -1-1-1 |
1 1 1 0 1 0 -1-1-1 |
1 1 0 1 0-1 0-1-1 |
1 1 0 1 1-1 0-1-1 |
#8 E/Edge | #9 E/Image | #10 NE/Edge | #11 NE/Image |
1 0-1 1 0-1 1 0-1 |
1 0-1 1 1-1 1 0-1 |
0-1-1 1-0 1 1 1 0 |
0-1-1 1 1-1 1 1 0 |
#12 N/Edge | #13 N/Image | #14 NW/Edge | #15 NW/Image |
-1-1-1 0 0 0 1 1 1 |
-1-1-1 0 1 0 1 1 1 |
-1-1 0 -1 0 1 0 1 1 |
-1-1 0 -1 1 1 0 1 1 |
Sobel Filters
The Sobel filters are very similar to the Prewitt filters except that they highlight light intensity variations along a particular axis that is assigned a stronger weight. The Sobel filters have the following kernels. The notations West (W), South (S), East (E), and North (N) indicate which edges of bright regions they outline.
#16 W/Edge | #17 W/Image | #18 SW/Edge | #19 SW/Image |
-1 0 1 -2 0 2 -1 0 1 |
-1 0 1 -2 1 2 -1 0 1 |
0 1 2 -1 0 1 -2-1 0 |
0 1 2 -1 1 1 -2 1 0 |
#20 S/Edge | #21 S/Image | #22 SE/Edge | #23 SE/Image |
1 2 1 0 0 0 -1-2-1 |
1 2 1 0 1 0 -1-2-1 |
2 1 0 1 0-1 0-1-2 |
2 1 0 1 1-1 0-1-2 |
#24 E/Edge | #25 E/Image | #26 NE/Edge | #27 NE/Image |
1 0-1 2 0-2 1 0-1 |
1 0-1 2 1-2 1 0-1 |
0-1-2 1 0-1 2 1 0 |
0-1-2 1 1-1 2 1 0 |
#28 N/Edge | #29 N/Image | #30 NW/Edge | #31 NW/Image |
-1-2-1 0 0 0 1 2 1 |
-1-2-1 0 1 0 1 2 1 |
-2-1 0 -1 0 1 0 1 2 |
-2-1 0 -1 1 1 0 1 2 |
Other Kernels
The following table lists the predefined gradient 5 × 5 kernels.
#0 W/Edge | #1 W/Image | #2 SW/Edge | #3 SW/Image |
0 -1 0 1 0 -1 -2 0 2 1 -1 -2 0 2 1 -1 -2 0 2 1 0 -1 0 1 0 |
0 -1 0 1 0 -1 -2 0 2 1 -1 -2 1 2 1 -1 -2 0 2 1 0 -1 0 1 0 |
0 0 1 1 1 0 0 2 2 1 -1 -2 0 2 1 -1 -2 -2 0 0 -1 -1 -1 0 0 |
0 0 1 1 1 0 0 2 2 1 -1 -2 1 2 1 -1 -2 -2 0 0 -1 -1 -1 0 0 |
#4 S/Edge | #5 S/Image | #6 SE/Edge | #7 SE/Image |
0 1 1 1 0 1 2 2 2 1 0 0 0 0 0 -1 -2 -2 -2 -1 0 -1 -1 -1 0 |
0 1 1 1 0 1 2 2 2 1 0 0 1 0 0 -1 -2 -2 -2 -1 0 -1 -1 -1 0 |
1 1 1 0 0 1 2 2 0 0 1 2 0 -2 -1 0 0 -2 -2 -1 0 0 -1 -1 -1 |
1 1 1 0 0 1 2 2 0 0 1 2 1 -2 -1 0 0 -2 -2 -1 0 0 -1 -1 -1 |
#8 E/Edge | #9 E/Image | #10 NE/Edge | #11 NE/Image |
0 1 0 -1 0 1 2 0 -2 -1 1 2 0 -2 -1 1 2 0 -2 -1 0 1 0 -1 0 |
0 1 0 -1 0 1 2 0 -2 -1 1 2 1 -2 -1 1 2 0 -2 -1 0 1 0 -1 0 |
0 0 -1 -1 -1 0 0 -2 -2 -1 1 2 0 -2 -1 1 2 2 0 0 1 1 1 0 0 |
0 0 -1 -1 -1 0 0 -2 -2 -1 1 2 1 -2 -1 1 2 2 0 0 1 1 1 0 0 |
#12 N/Edge |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