Presentation is loading. Please wait.

Presentation is loading. Please wait.

Edge Detection (with implementation on a GPU) And Text Recognition (if time permits) Jared Barnes Chris Jackson.

Similar presentations


Presentation on theme: "Edge Detection (with implementation on a GPU) And Text Recognition (if time permits) Jared Barnes Chris Jackson."— Presentation transcript:

1 Edge Detection (with implementation on a GPU) And Text Recognition (if time permits) Jared Barnes Chris Jackson

2  Edge Detection ◦ Wikipedia: Identifying points in a digital image at which the image has discontinuities.

3 http://4.bp.blogspot.com/-p_9w91wC_Rc/TbBgF7dQYhI/AAAAAAAAACM/DQTrM_a7Apg/s1600/edge-example-c.png

4  John Canny  “A Computational Approach to Edge Detection”  1986 http://ieeexplore.ieee.org.libproxy.mst.edu/stamp/stamp.jsp?tp=&arnumber=4767851

5 1. Noise Removal 2. Image Gradient Computation 3. Non-Maximum Suppression 4. Hysteresis Thresholding

6  Gaussian Smoothing or Blurring  A pixel is changed based on a weighted average of itself and its neighbors  The number of neighbors (3x3, 5x5) and the relative weights can vary 3D Gaussian Distribution Normalized 2D Gaussian Approximation http://www.librow.com/content/common/im ages/articles/article-9/2d_distribution.gif http://homepage.cs.uiowa.edu/~cwyman/classe s/spring08-22C251/homework/canny.pdf

7 Too much About right http://media.tumblr.com/ccd6945141b46e5e2f5c36168f6a 8037/tumblr_inline_mhcv1l0EZB1qz4rgp.png http://www.eversparkinteractive.com/wp- content/uploads/2013/03/gaussian-blur-thumbnail.jpg SpottySmooth

8 http://homepage.cs.uiowa.edu/~cwyman/classes/spring08-22C251/homework/canny.pdf GxGx GyGy Sobel Operator (2 kernels) Then round to: 0° =←→ 90°=↑↓ 45°=↗↙ 135°=↘↖

9 http://suraj.lums.edu.pk/~cs436a02/CannyImplementation.htm X Gradient (Horizontal Edges) Y Gradient (Vertical Edges)

10  Make edges exactly one pixel thick  Look at the gradient magnitude of your 2 neighbors in the direction of your angle 808590 808590 808590 35 50 355040 5040 Example 2 Angle = 0° ←→ Example 1 Angle = 135° ↘↖ 808590 808590 808590 35 50 355040 5040 808590 80090 808590 35 50 355040 5040 Keep it! Kill it!

11 http://suraj.lums.edu.pk/~cs436a02/CannyImplementation.htm Thick Edges (Gradient Magnitude) Thin Edges (Gradient Magnitude)

12  Two thresholds are better than one!  If a pixel’s value is above T high, it’s an edge.  If a pixel’s value is below T low, it’s not an edge.  If a pixel’s value is between T high and T low, it might be an edge (provided it is connected to an actual edge) 0000000 050 0 000 000 000 000 0360500400 3900500039 0380500430 00050000 040 5040 0 0000000 T high = 45T low = 35 0000000 050 0 000 000 000 000 0360500400 3900500039 0380500430 00050000 040 5040 0 0000000 0000000 050 0 000 000 000 000 0360500400 3900500039 0380500430 00050000 040 5040 0 0000000 0000000 0255 0 000 000 000 000 000 000 000 000 000 000 000 000 0 0 0000000

13 1. Smooth image to reduce noise 2. Calculate X & Y derivatives to get edges 3. Thin all edge widths to 1 pixel 4. Remove weak, unconnected edges (ta da!)

14  How do we parallelize the Canny Edge Detector?

15  Convolution – Independent of order 555 10 20 222 422 222 ImageKernel 222 422 222 10 4020 40 Element-wise Multiplication 230 Sum All Values 11 Divide by Kernel Sum 11

16  Convolve a Gaussian Kernel with the image  Each GPU core can convolve each pixel in the image individually with the Gaussian Kernel  One thread per pixel, each performing 9 multiplies, 9 adds, and 1 division  Embarrassingly Parallel with huge speedup

17  Convolve two Sobel Kernels with the image  Wait, convolution again?  Same as previous step – we can even reuse the convolution function!

18  Comparing 3 pixel gradient magnitudes and clearing the middle pixel or leaving it alone  Similar to convolution… but simpler!  Each GPU thread owns a pixel: 1.Check gradient angle of pixel 2.Compare this pixel’s magnitude with two neighbors in the direction of its angle 3.If I’m greater than those neighbors, leave me alone; otherwise, mark me as “not an edge”  Less speedup than steps 1 and 2

19  Mark pixels > T high as strong edges  Mark pixels < T low as not edges  Mark remaining pixels as weak edges if they connect to a strong edge  Typically implemented with recursion  Each thread with a weak-edge pixel looks at nearest 2 neighbors to find a strong-edge pixel  With identical algorithms on CPU and GPU, speedup is marginal (memory accesses, not much processing)

20 http://www.flacom.com/content/uploads/2013/09/hello-world.jpg Wikipedia: The mechanical or electronic conversion of images of printed text into computer-readable text. http://hackadaycom.files.wordpress.com/2010/09/helloworldconsole.png

21  Label Connected Components  Look For Letters  Adjust for disconnected letters HELLO WORLD HELLOWORLDHELLOWORLD E F ? ü j i

22  Create a list of components in the image  A component is simply a set of connected edges 1. Label each edge pixel with a unique component ID 2. Examine each pixel’s 8 touching neighbors and set that pixel’s ID to the smallest neighbor ID 3. Repeat step 2 until no pixel IDs are changed

23  Uhh… what’s a letter?  How do we know it’s a letter?  How does the computer know it’s a letter?

24  Letters are represented by a vector of numbers indicating the ratio of black pixels to white pixels in each division of the letter-image. A 040000604060555515550010751000150

25  Compute how closely each labelled component matches each letter in your alphabet  The component is then marked with whichever letter it most closely matches

26  Letters like ‘i’ and ‘j’ have floating parts  Sometimes edge detection may accidentally break up a letter  A letter vector should then get an additional property indicating vertical discontinuity T E R V EL EO R………C T 0/1


Download ppt "Edge Detection (with implementation on a GPU) And Text Recognition (if time permits) Jared Barnes Chris Jackson."

Similar presentations


Ads by Google