Parent Topic: Filter
This filter uses two 3x3 templates to calculate the Prewitt gradient value as shown below:
Templates:
-1 0 1 -1 0 1 X -1 0 1 1 1 1 0 0 0 Y -1 -1 -1 Apply the templates to a 3x3 filter window. a1 a2 a3 a4 a5 a6 3x3 filter window a7 a8 a9where a1 .. a9 are grey levels of each pixel in the filter window.
X = -1*a1 + 1*a3 - 1*a4 + 1*a6 - 1*a7 + 1*a9
Y = 1*a1 + 1*a2 + 1*a3 - 1*a7 - 1*a8 - 1*a9
Prewitt Gradient = sqrt(X*X + Y*Y)
NOTE: In order to filter pixels located near the edges of the image, edge pixel values are replicated to give sufficient data.