ECE532 Homework 2-JJR edge detector Solved

30.00 $

Category:

Description

Rate this product

Write a computer program to implement the JJR edge detector, which is a modified 3 x 3 gradient operator that computes an edge map 𝐸𝐸(𝑟𝑟, 𝑐𝑐) from a grayscale input image 𝐼𝐼(𝑟𝑟, 𝑐𝑐) as follows:

𝐼𝐼𝑦𝑦(𝑟𝑟, 𝑐𝑐) = median{𝐼𝐼(𝑟𝑟, 𝑐𝑐 − 1), 𝐼𝐼(𝑟𝑟, 𝑐𝑐 + 1), 𝐼𝐼(𝑟𝑟 − 1, 𝑐𝑐 − 1), 𝐼𝐼(𝑟𝑟 − 1, 𝑐𝑐), 𝐼𝐼(𝑟𝑟 − 1, 𝑐𝑐 + 1)}

− median{𝐼𝐼(𝑟𝑟, 𝑐𝑐 − 1), 𝐼𝐼(𝑟𝑟, 𝑐𝑐 + 1), 𝐼𝐼(𝑟𝑟 + 1, 𝑐𝑐 − 1), 𝐼𝐼(𝑟𝑟 + 1, 𝑐𝑐), 𝐼𝐼(𝑟𝑟 + 1, 𝑐𝑐 + 1)}

𝐼𝐼𝑥𝑥(𝑟𝑟, 𝑐𝑐) = median{𝐼𝐼(𝑟𝑟 − 1, 𝑐𝑐), 𝐼𝐼(𝑟𝑟 − 1, 𝑐𝑐 + 1), 𝐼𝐼(𝑟𝑟, 𝑐𝑐 + 1), 𝐼𝐼(𝑟𝑟 + 1, 𝑐𝑐), 𝐼𝐼(𝑟𝑟 + 1, 𝑐𝑐 + 1)}

− median{𝐼𝐼(𝑟𝑟 − 1, 𝑐𝑐 − 1), 𝐼𝐼(𝑟𝑟 − 1, 𝑐𝑐), 𝐼𝐼(𝑟𝑟, 𝑐𝑐 − 1), 𝐼𝐼(𝑟𝑟 + 1, 𝑐𝑐 − 1), 𝐼𝐼(𝑟𝑟 + 1, 𝑐𝑐)}

median{𝑆𝑆} = middle value after sorting the elements of S in numerical order

𝐺𝐺 = ∇⃗𝐼𝐼 = 𝐼𝐼𝑥𝑥2 + 𝐼𝐼𝑦𝑦2  𝟐𝟐

edge,          if 𝐺𝐺(𝑟𝑟, 𝑐𝑐) ≥ thresh

𝐸𝐸(𝑟𝑟, 𝑐𝑐) =

non-edge,    otherwise

Note that the scaling factor would normally be omitted, but let’s include it so that we can do a fair comparison with the Sobel operator. Although each partial neighborhood has an odd shape whose centroid is between pixels, the median value will be one of the actual pixel values at a pixel center, so we should arguably just divide by a pixel displacement of 2.

For the median calculation, you may use a built-in function or library function, or you may implement your own bubble sort or other sorting algorithm. For example, if you’re using C, then you may want to use the qsort() function.

Also implement the Sobel edge detector for comparison; be sure to include the 1/8 scaling factor in the Sobel gradient magnitude calculation, so that we can use the same threshold for both edge detectors.

Do not perform non-maximum suppression.

Run the program on the horse.png image, using thresh = 60 for both the JJR edge detector and the Sobel edge detector. (A better way to compare would be to adjust the threshold for each detector so that the total number of edge pixels is equal, but let’s keep it simple and just use the same fixed threshold.)

Turn in the following:

  1. the source code in a format that the grader can compile and run it
  2. the output edge map as an image or PDF file
  3. the numerical values of the JJR gradient magnitude and edge map for the region defined by 𝟑𝟑𝟑𝟑𝟑𝟑 ≤ 𝒓𝒓 ≤ 𝟑𝟑𝟑𝟑𝟑𝟑, 𝟑𝟑𝟑𝟑𝟑𝟑 ≤ 𝒄𝒄 ≤ 𝟑𝟑𝟑𝟑𝟑𝟑 (assuming 𝑟𝑟 and 𝑐𝑐 start at 0), and the Sobel gradient magnitude and edge map for same region
  4. Notes

The horizontal derivative involves subtracting the medians of the following two partial neighborhoods:

 

A B  

 

 

B C
D F
G H H I

 

The vertical derivative involves subtracting the medians of the following two partial neighborhoods:

A B C
D F

 

D F
G H I

 

Output Values

JJR gradient magnitude values:

1.58     ?      ?      ?    74.95

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

JJR edge map:

  • ? ?      ?     edge

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

Sobel gradient magnitude values:

0.73    ?      ?      ?    78.51

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

Sobel edge map:

  • ? ?      ?     edge

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

?      ?      ?      ?      ?

  • hw2-p6gild.zip