ECE532 Homework 2-JJR edge detector Solved

30.00 $ 15.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . zip solution files instantly, after Payment

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