Prewitt Edge Filter (Operator)
- Practical Electron Microscopy and Database -
- An Online Book -
Microanalysis | EM Book                                                                                   http://www.globalsino.com/EM/

=================================================================================

Similar to Sobel Edge Filter, the Prewitt Edge Filter is an operator used in image processing, particularly within edge detection algorithms (approximations of the derivatives). It computes a discrete approximation of the gradient of the image intensity function, and consists of a horizontal filter and a verticle filter and is used to detect edges of images. Both Sobel and Prewitt Filters are used extensively for detecting edges in image processing.

In the Prewitt Edge Filter case, both horizontal and verticle filters are applied to the same image and then summed to form the final image as a final filter. The two filters are basic convolution filters in the form in Figure 1006a.

 1 1 1 0 0 0 -1 -1 -1
 -1 0 1 -1 0 1 -1 0 1
(a)
(b)

Figure 1006a. Prewitt edge filter: (a) horizontal filter and (b) verticle filter.

Figure 1006b shows an filter example. The filter is centered at pixel p5 here. Based on Figures 1006a and 1006b, the value of the resulting new pixel p5 is then given by,
[x][y] = (p1+p2+p3-p7-p8-p9)+(p3+p6+p9-p1-p4-p7) ---------------- [1006a]
This filter identifies the areas of high slope in the input image through the calculation of slopes in the x and y directions. The value of p5 is finally scaled to the 0-255 range.

 p1 p2 p3 p4 p5 p6 p7 p8 p9
 [x-1][y-1] [x][y-1] [x+1][y-1] [x-1][y] [x][y] [x+1][y] [x-1][y+1] [x][y+1] [x+1][y+1]
(a)
(b)
 Figure 1006b. Prewitt edge filter: (a) filter with a 3×3 window, and (b) coordinates of the filter with the 3×3 window.

The actual forumla uses the horizontal and verticle components to obtain the the final form,
[x][y] = sqrt((X*X)+(Y*Y)) ---------------- [1006b]
where,
X = (p1+p2+p3-p7-p8-p9)  ---------------- [1006c]
Y = (p3+p6+p9-p1-p4-p7) ---------------- [1006d]

Therefore, the Prewitt edge filter estimates the maximum gradient of the edges, and can be used to find edge directions. In DM, the Prewitt edge filter can be programmed with scripts as shown in Table 1006.

Table 1006. Prewitt edge filter in DM.

 Script Note ◆ Script code in .s format ◆ The signs in the script are reversed from the ones in Figure 1006b since the image shifts caused by offset() are opposite to the signs in Equations 1006c and 1006d. Example  Original image  (fuel cell nanoparticles on carbon film)   Processed image with the Prewitt edge filter above

=================================================================================