Worksheet #9B
Image Processing and Edge Detection
Name ______________
1. Copy the image file: /home/atlas1/ai/fig1.pgm.
Copy the Lisp starter file: /home/atlas1/ai/edgeDetect.lsp.
Use xv to view fig1.pgm. You should see a picture of a camera tripod.
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
B. Vertical differencing:
Image2[i,j] = abs(Image[i+1,j] - Image[i,j])
Set the pixels in the last row equal to 0
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.
)
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
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.