EE 355 OCR Explanation Mark Redekopp 2 Make Your Own Image Note: - - PowerPoint PPT Presentation

ee 355 ocr explanation
SMART_READER_LITE
LIVE PREVIEW

EE 355 OCR Explanation Mark Redekopp 2 Make Your Own Image Note: - - PowerPoint PPT Presentation

1 EE 355 OCR Explanation Mark Redekopp 2 Make Your Own Image Note: You can make your own images by: Using the "Verdana" font and writing some text in a word processor Using the Windows "snipping" tool to capture


slide-1
SLIDE 1

1

EE 355 OCR Explanation

Mark Redekopp

slide-2
SLIDE 2

2

Make Your Own Image

  • Note: You can make your own images by:

– Using the "Verdana" font and writing some text in a word processor – Using the Windows "snipping" tool to capture a section of the screen – Paste it into an image editor (Windows Paint) – Resize the image to 256x256 – Save it as 8-bit Grayscale

slide-3
SLIDE 3

3

Note about BFS

Scan top to bottom, left to right Stop when you hit a black, unfound pixel 1 Now start a BFS using 8 connected neighbors (N, NW, W, SW, S, SE, E, NE) 2

slide-4
SLIDE 4

4

Note about BFS

Row r Row r+1

Note: Due to slight image rendering discrepancies, characters further right might be found first since one of their pixels is in a higher row. In this image, 2 and 3 might be found before 1

slide-5
SLIDE 5

5

Note about BFS

Scan top to bottom, left to right Stop when you hit a black, unfound pixel 1 Now start a BFS using 8 connected neighbors (N, NW, W, SW, S, SE, E, NE) 2

slide-6
SLIDE 6

6

Euler Number

  • Euler number = # of components - # of holes
  • Component is connected black region

– Each character is just 1 component

  • Holes are enclosed white regions

– '8' has 2 holes, '0' has 1, '2' has none

  • Thus, Euler number, E = C-H = 1-H

– E=1 => {1, 2, 3, 5, 7} – E=0 => {0, 4, 6, 9} – E=-1 => {8}

slide-7
SLIDE 7

7

Center of Mass (Centroids)

  • Imagine black pixels represents mass in the image

below

  • Where would the center of mass be?

– Somewhere in the upper right

  • This can be useful for identifying certain characters

('7' = more mass in the upper half, '3' = more mass in the right half, etc.)

Vertical center

  • f mass is on

row 1.1

slide-8
SLIDE 8

8

Vertical Centroid

  • Equation

– isblack(i,j) = 1 if pixel (i,j) is black, 0 otherwise

𝑗,𝑘=0,0 𝐼,𝑋

𝑗 ∗ 𝑗𝑡𝑐𝑚𝑏𝑑𝑙(𝑗, 𝑘) [

𝑗,𝑘=0,0 𝐼,𝑋

𝑗𝑡𝑐𝑚𝑏𝑑𝑙(𝑗, 𝑘)]

– Multiple row index * 1 if the pixel is black and sum

  • ver all pixels

– 0*1 + 0*1 + 0*1 + 0*1 + 0*1 + 1*1 + 2*1 + 3*1 + 4*1 = 10 – Total black pixels = 9 – Vertical centroid = 10/9 = 1.11

1 2 3 4 1 2 3 4

Vertical center

  • f mass is on

row 1.1

slide-9
SLIDE 9

9

Horizontal Centroid

  • Equation

– isblack(i,j) = 1 if pixel (i,j) is black, 0 otherwise

𝑗,𝑘=0,0 𝐼,𝑋

𝑘 ∗ 𝑗𝑡𝑐𝑚𝑏𝑑𝑙(𝑗, 𝑘) [

𝑗,𝑘=0,0 𝐼,𝑋

𝑗𝑡𝑐𝑚𝑏𝑑𝑙(𝑗, 𝑘)]

– Multiple column index * 1 if the pixel is black and sum over all pixels – 0*1 + 1*1 + 2*1 + 3*1 + 4*1 + 4*1 + 4*1 + 4*1 + 4*1 = 26 – Total black pixels = 9 – Vertical centroid = 26/9 = 2.89

1 2 3 4 1 2 3 4

Horizontal center

  • f mass is on

column 2.89

slide-10
SLIDE 10

10

Center of Mass (Centroids)

  • Putting the VC (Vertical centroid) and HC (Horizontal centroid)

together we arrive at a center of mass of (1.1, 2.89)

  • It may be more useful to translate the coordinate system to

have 0,0 be right in the middle which can easily be accomplished by:

– (VC – H/2 , HC – W/2 ) => (1.1-2, 2.89-2) = (-0.9, 0.89) – This tells us the center of mass is in the upper (negative), left (positive) quadrant of the image

Center of Mass

  • 2
  • 1

1 2

  • 2
  • 1

1 2

Center of Mass

slide-11
SLIDE 11

11

Symmetry

  • Another useful characteristic might be vertical

and horizontal symmetry

– Mirror images top to bottom (vertical symmetry)

  • r left to right (horizontal symmetry)

1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

Vertical Symmetry Horizontal Symmetry Both Vertical & Horizontal Symmetry

slide-12
SLIDE 12

12

Computing Vertical Symmetry

  • Scan down the top row and compare pixel values to

the bottom row, then compare second row to second to last row, etc.

– Count how many pixels you compared and how many matched – Likely helpful to normalize to a percentage

1 2 3 4 M1 M2 M3 M4 M5 1 M6 M7 M8 M9 MA 2 3 M6 M7 M8 M9 MA 4 M1 M2 M3 M4 M5 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

Vertical Symmetry Horizontal Symmetry Both Vertical & Horizontal Symmetry

slide-13
SLIDE 13

13

Computing Bit Quads

  • To compute bit quads remember to start at one row

and column above and to the left and continue to

  • ne row and column below and to the right (i.e.

leave a frame of one row/column of white around the black pattern)

1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4

Vertical Symmetry Horizontal Symmetry Both Vertical & Horizontal Symmetry

slide-14
SLIDE 14

14