Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8809191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:48:35+00:00 2026-06-14T02:48:35+00:00

I’m writing an Android app to extract a Sudoku puzzle from a picture. For

  • 0

I’m writing an Android app to extract a Sudoku puzzle from a picture. For each cell in the 9×9 Sudoku grid, I need to determine whether it contains one of the digits 1 through 9 or is blank. Here are the broad strokes of my algorithm:

  • Adaptive threshold the puzzle
  • Dilate to reduce the number of contours to consider
  • Find the contours of the puzzle and warp it to a square
  • Divide the square into 81 equal cells; look for cells with at least 20% white pixels
  • Find the white blob closest to the centre of these cells and get its bounding rectangle
  • Use character recognition (k-nearest neighbours/Tesseract/etc.) on the portion of the image inside the bounding rectangle

Although I can remove the thick outer border of the Sudoku puzzle using a simple floodfill, the inner gridlines are not contiguous, even after dilation, and cannot be removed so easily. For illustration, here is a sample Sudoku after removing the outer grid lines:

enter image description here

Problem: Sometimes, there are enough gridlines in a cell that more than 20% of its pixels are white, so I misdetect that cell as having a number in it. Here is an example of such a cell:

enter image description here

I’ve considered unwarping the image to reduce the visibility of the inner gridlines. I could use a Hough Transform or the method described in this post to find the gridlines as a prelude to unwarping. However, I don’t see any other significant benefits to unwarping, and it should be both safer and easier to just remove the gridlines entirely.

Alternatively, I could modify my pre-processing so that the inner gridlines remain intact. Currently my pre-processing is:

    Imgproc.GaussianBlur(mat, mat, new Size(11,11), 0);
    Imgproc.adaptiveThreshold(mat, matBW, 255, 
        Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY_INV, 5, 2);
    Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_CROSS, new Size(3, 3));
    Imgproc.dilate(matBW, matBW, kernel);

The Gaussian Blur is necessary to reduce noise before thresholding. The dilation is to make sure the outer gridlines are connected, but is not enough to reconnect the inner lines.

How can I consistently remove the inner gridlines, without affecting the rest of the image?

Many thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:48:37+00:00Added an answer on June 14, 2026 at 2:48 am

    If you don’t want to make a proper unwarp, it’s probably worthwhile to use smaller cells for the digit_present test.

    Let’s say the top left cell has coordinates (x1,y1,x2,y1)==(0,0,10,10). You could define a new cell as (x1+k,y1+k,x2-k,y2-k), k=min(x2-x1,y2-y1)/4

    Another strategy that may work is to use erode before the test, depending on the thickness of the grid lines vs the digits’.

    At last, you could feed all the cells to your classifier, and use its confidence indexes, if any; if the classifier confidence is too low, it’s probably not a digit.

    If all these approaches fails, in order to do a fill you’ll have to obtain the warping of the grid lines anyway, so you might as well do the unwarping

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app with both english and french support. The app requests
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.