Courses‎ > ‎Introduction to Computer Science 1‎ > ‎Konstantinovich‎ > ‎ML1 9/2012‎ > ‎labs‎ > ‎

Lab 11: Edge Detection

posted Dec 19, 2012, 5:56 AM by Samuel Konstantinovich   [ updated Dec 20, 2012, 10:10 AM ]
Critical: You should add this lab to lab 10, so that you reuse the image loading features.

Edge Detection overview: A pixel of an image is considered an 'edge' if there are vastly different shades of colors on either side of the patch. We will just look at the brightness of the patches for this (the ones digit) 

Whenever the term "brightness" is used, we are talking about the ones place. The brightness of the color 52 is just 2. The brightness of the color 97 is 7.

Simple EdgeDetect algorithm: 
1. Patches will have a variable edge_value
2. For all patches:
   Calculate the brightness difference by subtracting the brightness from the patch on the left from the patch on the right. Then take the absolute value this is the edge_value. The bigger this number the more likely it is an edge. 
3. For all patches:
   If the edge_value > some sensitivity value (slider from 0 to 10) then change the patch to black (it is an edge) otherwise make it white.  

1. Same as before
2. Average the up/down and left/right brightness difference (see step 2 from above). If the up/down difference is 2, and the left/right difference is 8, make the edge value 5 (the average of 2 and 8 is 5).
3. Same as before

1,2: Same as before
3. Set the pcolor to the edge_value

Challenge: Reverse the black/white on shadedEdges, remember that numbers ending in 0 are hard to reverse.