Library for extracting Sudokus from images using scikit-image
Library for extracting Sudokus from images using scikit-image.
Install via pip:
$ pip install sudokuextract
SudokuExtract is a tool for parsing Sudokus from images, this primarily to be able to send it forward to some kind of solver. It applies some image analysis on the input image and then uses a K-Nearest Neighbours classifier to determine which digits that are present in which box.
SudokuExtract can be used as a command line tool:
parse-sudoku -p /path/to/sudoku_image.jpg
which prints the parsed Sudoku in the terminal. In can also be called with an url to an image:
parse-sudoku -u http://www.domain.com/sudoku.jpg
It can also be used as a regular Python package:
In : from sudokuextract.extract import extract_sudoku, load_image, predictions_to_suduko_string In : img = load_image('/path/to/sudoku_image.jpg') In : predictions, sudoku_box_images, whole_sudoku_image = extract_sudoku(img) In : print(predictions_to_suduko_string(predictions)) 800603001 057401630 000000000 006109800 400000007 001805400 000000000 072504310 900302004
There are possibilities of using a classifier of your own creation when predicting digits; see the documentation for more details.
Run tests with pytest:
$ py.test tests.py
This library includes classifiers trained with data from the MNIST dataset (This data is also included in SudokuExtract).
The current parsing strategy for the sudokuextract package is inspired by this blog entry:
- Changed the main function of sudokuextract.extract to print and not return anything.
- Replace ndi.binary_fill_holes with a binary_erosion and increased number of blobs to test to 2.
- New classifiers.
- New data with additional data of 1:s.
- Disabled the Corners parsing solution again.
- Warping image now creates a much smaller image to prevent memory issues.
- This also increased speed with a factor of at least 4.
- apply_gaussian now applies a Gaussian on entire image first.
- Testing can now use a tar-file of images that can be downloaded from the web.
- Also removed lambda functions in favour of functools.partial.
- Restricted scikit-image version to < 0.12.
- New classifiers with both SudokuExtract and MNIST data.
- New data.
- MNIST data stored separately from SudokuExtract data.
- Number of Nearest Neighbours increased to 10 due to larger training data.
- Several small bugfixes for new features added in v0.8.0.
- New classifiers with MNIST data.
- New multi-attempt approach to Sudoku parsing.
- Using DLXSudoku to attempt classification of correct parsing of Sudoku.
- Removed a lot of deprecated code.
- Two different extraction methods:
- Local thresholding
- Adaptive thresholding for entire image
- Refactored extensively and updated classifiers.
- Patch for tests in Python 3.
- Simplified blob extraction.
- Added adaptive block_size for to_binary_adaptive.
- Added tests that fetch Sudokus from Xanadoku.
- Removed hard dependency on scikit-learn.
- Included an own K-Nearest-Neighbors classifier as default.
- Initial release on PyPI
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size sudokuextract-0.8.6-py2.py3-none-any.whl (12.2 MB)||File type Wheel||Python version 3.4||Upload date||Hashes View|
|Filename, size sudokuextract-0.8.6.tar.gz (12.2 MB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for sudokuextract-0.8.6-py2.py3-none-any.whl