chess segmentation

22
Chess Segmentation by Statis Grigoropoulos © 2012

Upload: stathis-grigoropoulos

Post on 27-Jun-2015

255 views

Category:

Entertainment & Humor


2 download

DESCRIPTION

Image Processing Algorithm for Chess Segmentation

TRANSCRIPT

Page 1: Chess Segmentation

Chess Segmentation

by Statis Grigoropoulos

© 2012

Page 2: Chess Segmentation

Chess Segmentation

• The Problem• Ways of Approach• Implementation• Results• Suggestions for Improvement• Conclusion

4/13/2012Chess SegmentationPage 2

Page 3: Chess Segmentation

The Problem

• Detect chessboard segmentation in an image

• classify the chess pieces found in the segmented chessboard.

• provide a correct FEN notation for the detected chessboard(s)

© 2012Chess SegmentationPage 3

Page 4: Chess Segmentation

The Algorithm• Step 1: Find internal borders of the

chessboard(s)( i.e detect chessboard)

• Step 2: Spit the squares for each chessboard

• Step 3: Detect the piece inside the square

• Step 4: Produce FEN notation

© 2012Chess SegmentationPage 4

Page 5: Chess Segmentation

Step 1: Find the Borders• Ways of Approach:

-Hough Transform-Norm. Cross Correlation

Template :

© 2012Chess SegmentationPage 5

Page 6: Chess Segmentation

Step 1: Find the Borders

• Hough Transform :MATLAB(single case)

© 2012Chess SegmentationPage 6

Page 7: Chess Segmentation

Page 7

Step 1: Find the Borders

• Hough Transform :MATLAB(real case)

© 2012Chess SegmentationPage 7

Page 8: Chess Segmentation

Page 8

Step 1: Find the Borders• Norm. Cross Correlation :MATLAB

© 2012Chess SegmentationPage 8

Page 9: Chess Segmentation

Step 2: Splitting the Squares• Step 1: Compute the histogram of the

chessboard• Step 2: Detect the dominant values of

the histogram• Step 3: Classify the dominant values

with a confidence interval as the white and

• black square background• Step 4: Iterate on the x and y axis and

catch the interchange of the values

© 2012Chess SegmentationPage 9

Page 10: Chess Segmentation

Step 2: Splitting the Squares

Confidence interval = 10%= 25

© 2012Chess SegmentationPage 10

Page 11: Chess Segmentation

Step 3: Classify Square• Empty Squares-Standard Deviation

A way to measure the distance of values from the mean

Expected low value of standard deviation in empty squares : s.d. < 25(10%)??

-Histogram bins© 2012Chess SegmentationPage 11

Page 12: Chess Segmentation

Step 3: Classify Square

s.d. =~ 20

s.d. =~ 11

s.d. =~ 30(!)

© 2012Chess SegmentationPage 12

Page 13: Chess Segmentation

Step 3: Classify Square• Square containing a Piece

- Rich Feature Space- Simple Mean Classifier The Method:

Shrink-to-fit Compute Characteristics

© 2012Chess SegmentationPage 13

Page 14: Chess Segmentation

Step 3: Classify Square• Square Containing a Piece -The Features:1. Normalized Histogram (dropped)2. Compute the ratio of dark pixels in

square(1)3. Spit the Square in a 3x3 grid4. Compute the relative ratio of dark

pixels in each region(9)

© 2012Chess SegmentationPage 14

Page 15: Chess Segmentation

Step 3: Classify Square• Square Containing a Piece -The Features(cont.):5. Spit the square in a 5x5 grid 6. Compute the Relative Position of the

border of the shape (chess piece) along the lines of the grid, in each direction(20)

7. Compute the relative ratio of dark pixels along each line of the grid(10)

Result : 40-dimensional feature space© 2012Chess SegmentationPage 15

Page 16: Chess Segmentation

Step 3: Classify Square• Square Containing a Piece

Shape Context

© 2012Chess SegmentationPage 16

Page 17: Chess Segmentation

Some Results

Accuracy = 100%

Accuracy 55%

Accuracy 80%

© 2012Chess SegmentationPage 17

Page 18: Chess Segmentation

Towards a complete Program• Minimize assumptions• Implement Step 1• Refine Spitting Squares Method• Extend Feature Space( go Log

Polar?)• Add more training sets• Optimize Code and Algorithms• Test, Test, Test…

© 2012Chess SegmentationPage 18

Page 19: Chess Segmentation

Conclusion• Chess Detection and Segmentation

a very hard problem in a general case

• We managed to solve a small part of it

• Each Step poses challenges

4/13/2012Chess SegmentationPage 19

Page 20: Chess Segmentation

Thank you!

© 2012Chess SegmentationPage 20

Page 21: Chess Segmentation

Questions?

© 2012Chess SegmentationPage 21

Page 22: Chess Segmentation

Classify that! :p

© 2012Chess SegmentationPage 22