Starting from:

$30

ECE532-Homework 2 JJR Edge Detector Solved

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

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

 

   ?      ?      ?      ?      ?

 

   ?      ?      ?      ?      ?

 

   ?      ?      ?      ?      ?

 

   ?      ?      ?      ?      ?

More products