chess segmentation
DESCRIPTION
Image Processing Algorithm for Chess SegmentationTRANSCRIPT
Chess Segmentation
by Statis Grigoropoulos
© 2012
Chess Segmentation
• The Problem• Ways of Approach• Implementation• Results• Suggestions for Improvement• Conclusion
4/13/2012Chess SegmentationPage 2
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
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
Step 1: Find the Borders• Ways of Approach:
-Hough Transform-Norm. Cross Correlation
Template :
© 2012Chess SegmentationPage 5
Step 1: Find the Borders
• Hough Transform :MATLAB(single case)
© 2012Chess SegmentationPage 6
Page 7
Step 1: Find the Borders
• Hough Transform :MATLAB(real case)
© 2012Chess SegmentationPage 7
Page 8
Step 1: Find the Borders• Norm. Cross Correlation :MATLAB
© 2012Chess SegmentationPage 8
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
Step 2: Splitting the Squares
Confidence interval = 10%= 25
© 2012Chess SegmentationPage 10
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
Step 3: Classify Square
s.d. =~ 20
s.d. =~ 11
s.d. =~ 30(!)
© 2012Chess SegmentationPage 12
Step 3: Classify Square• Square containing a Piece
- Rich Feature Space- Simple Mean Classifier The Method:
Shrink-to-fit Compute Characteristics
© 2012Chess SegmentationPage 13
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
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
Step 3: Classify Square• Square Containing a Piece
Shape Context
© 2012Chess SegmentationPage 16
Some Results
Accuracy = 100%
Accuracy 55%
Accuracy 80%
© 2012Chess SegmentationPage 17
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
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
Thank you!
© 2012Chess SegmentationPage 20
Questions?
© 2012Chess SegmentationPage 21
Classify that! :p
© 2012Chess SegmentationPage 22