Algorithm for solving Sudoku

Here is my sudoku solver in python. It uses simple backtracking algorithm to solve the puzzle. For simplicity no input validations or fancy output is done. It’s the bare minimum code which solves the problem. Algorithm Find all legal values of a given cell For each legal value, Go recursively and try to solve the … Read more

How to get the cells of a sudoku grid with OpenCV?

Here’s a potential solution: Obtain binary image. Convert image to grayscale and adaptive threshold Filter out all numbers and noise to isolate only boxes. We filter using contour area to remove the numbers since we only want each individual cell Fix grid lines. Perform morphological closing with a horizontal and vertical kernel to repair grid … Read more

How to remove convexity defects in a Sudoku square?

I have a solution that works, but you’ll have to translate it to OpenCV yourself. It’s written in Mathematica. The first step is to adjust the brightness in the image, by dividing each pixel with the result of a closing operation: src = ColorConvert[Import[“http://davemark.com/images/sudoku.jpg”], “Grayscale”]; white = Closing[src, DiskMatrix[5]]; srcAdjusted = Image[ImageData[src]/ImageData[white]] The next step … Read more