7

I would like to ask another question related to How to remove convexity defects in a Sudoku square?

I implemented a Sudoku Solver in OpenCV-Python and it work pretty good. But at this time, i made an assumption which will simplify my problem.

Assumption is : Sudoku boundary(square) is the biggest blob in the input image

Eg:

enter image description here

The red block is the detected square. You can see it covers the major part of the image.

The Problem:

Problem is nothing but the assumption. If sudoku square has another square around it, method fails. Or if the image has another bigger blob than the sudoku square, again method fails.

For eg, take this image. (I don't want to upload original image here, it is pretty big, also i want to upload the result anyway)

I tried several following methods to find sudoku square in this image:

1) Find the biggest blob

Then I got the red coloured region. Method Failed.

enter image description here

(Image is resized from original image to reduce size)

2) Find only square regions

You can see a lot of candidates are there, especially KING CROSSWORD which is all way similar to Sudoku. Method again fails

In short, this image has everything, to fail me.

Question:

How to detect a sudoku square in an image, especially in the test image i gave? Is there any better algorithm for this?

UPDATE: After reading some answers and comments, i think i should give an update. Look at the below image:

enter image description here

This image has a question sudoku and previous sudoku's answer. Both are alike. I think searching for sub-blocks or OCR testing won't work here.

Community
  • 1
  • 1
Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
  • A completely different and maybe useless method, but couldn't you push it through an OCR system, and look for a textual hint where to look first, and then go from there? – Nanne May 01 '12 at 08:46
  • I don't think so. Check the update in the question. – Abid Rahman K May 01 '12 at 08:59
  • Well, I did give it as a comment because I wasn't sure :) .. Still, I think you need to use multiple methods. One could be to find the general area of the sudoku by OCR (so you don't get the cartoons), and then find the biggest blob/square? something like that. Just thinking aloud ;) – Nanne May 01 '12 at 10:05
  • To the update: technically both are Sudokus the second has been solved. So no empty blocks. I think you could detect it like this. – bdecaf May 01 '12 at 11:14

1 Answers1

6

Why not check every large square/blob? Only the ones with 1) 9X9 subsquares 2) Numbers in some of the subsquares 3) No blacked out subsquares are sudoku.

mwengler
  • 2,738
  • 1
  • 19
  • 32
  • and 4) Containing some blank squares? – Chris May 02 '12 at 07:50
  • 2
    I think the point @Chris and I sort of support is why not try everything that MIGHT be a sudoku and step through every one until determining it is not a sudoku? You don't need to come up with some magic bullet that picks up the sudoku and only the sudoku from the page. – mwengler May 02 '12 at 17:38