Solving Sudoku using Image processing Techniques

Hemil Shah
3 min readJun 18, 2020

--

Steps Involved in extracting sudoku grid:

  1. First, we apply Gaussian blur with a kernel size (height, width) of 9 to the image.Then we use adaptive threshold using 11 nearest neighbour pixels.. Also, we will dilate the image to increase the size of gridline.
  2. Find the corners of the largest polygon & Crop and Warp Image
  3. Extracting each digit from the grid
  4. Identify each digits using mnist pretrained model
  5. Made a 9*9 grid of numbers
  6. Solving sudoku grid using backtracking algorithms
  7. Showing solved sudoku grid as image

1.Applying Gaussian Blur to the input image

Input Image

Applying Gaussian Blur with Adaptive Threshold and dilate the image

2.Find the corners of the largest polygon & crop and wrap image

3.Extracting each digit from a grid

Here, blank image represents blank cell in sudoku image.

4.Identifying each digit using pretrained mnist digit classification model

Checking single digit from pretrained mnist model

5.Made a 9*9 grid of numbers

6.Solving sudoku grid using backtracking algorithm

7.Showing solved sudoku grid as image

Github_link: https://github.com/hemil19/Solving-sudoku-grid-from-image

I refer this article for this project: https://medium.com/@aakashjhawar/sudoku-solver-using-opencv-and-dl-part-2-bbe0e6ac87c5

https://www.linkedin.com/posts/robovirmani_computervision-ai-ml-ugcPost-6676142893293535232-XTgb

--

--

Hemil Shah

Aspiring Data Scientist | Student (M. Tech Data Science)