A pixel is turned brighter based on the rate of change of it and its neighbors.
A higher rate of change (this happens on an edge) is colored brighter
than a low rate of change (not an edge)
1. Copy the image file:
- Use Gimp or a browser to view fig1.pgm
- This is a "pgm" format image file
- Here's the data file for fig1.pgm, this is a P2 format file with 97 columns, 128 rows, and max pixel value 255 (white)
2. Perform the following edge detection routines:
A. Horizontal differencing:
Image2[i,j] = abs(Image[i,j+1] - Image[i,j])
Set the pixels in the last column equal to 0
Your result should look like: edge detection image, horizontal differencing
B. Vertical differencing:
Image2[i,j] = abs(Image[i+1,j] - Image[i,j])
Set the pixels in the last row equal to 0
Your result should look like: edge detection image, vertical differencing
C. Robert's cross with sqrt:
Image2[i,j] = sqrt (sqr (image1[i,j] - image1[i+1, j+1]) +
sqr (image1[i,j+1] - image1[i+1, j]))
Use (floor x) to truncate the result
Also set the pixels in the last row and last column to 0.
(Note - Here are two variations on the Robert's cross pattern:
Variation 1: Robert's cross using absolute value:
Image2[i,j] = (abs (image1[i,j] - image1[i+1, j+1])) +
(abs (image1[i,j+1] - image1[i+1, j]))
Variation 2: A slightly different version of the cross pattern:
Image2[i,j] = abs(image1[i,j-1] - image1[i, col+1]) +
abs(image1[i-1, j] - image1[i+1, j])
Set the first and last rows and cols to 0.
)
Your result should look like: edge detection image, Roberts differencing
D. Sobel operator:
For this pattern around pixel e:
a b c
d e f
g h i
dx = c + 2f + i - a - 2d - g
dy = a + 2b + c - g - 2h - i
Image[i,j] = sqrt (sqr(dx) + sqr(dy))
Use (floor x) to truncate the sqrt.
If the value is > 255, reset it to 255 so that 255 is the max value
Set the first and last rows and cols to 0
Your result should look like: edge detection image, Sobel differencing
3. Save each of the previous edge detected images under different file names.
Fig1HDiff.pgm - Horizontal Differencing
Fig1VDiff.pgm - Vertical Differencing
Fig1Roberts.pgm - application of the Robert's cross pattern
Fig1Sobel.pgm - application of the Sobel operator pattern
Compare the strength of each edge detection algorithm.
4. Try one or more of these edge detection methods using parallel processes.