deep-sudoku-solver icon indicating copy to clipboard operation
deep-sudoku-solver copied to clipboard

Sensible error when the image does not contain a sudoku.

Open EduardBenet opened this issue 5 years ago • 0 comments

If the image does not contain a sudoku at all, the code:

[solution, outputs] = solver.process(exampleImage);

errors as follows:

Index in position 1 is invalid. Array indices must be positive integers or logical values.

Error in tabular/subsrefBraces (line 35)
    b = b(rowIndices,:); % without using reshape, may not have one

Error in tabular/numArgumentsFromSubscript (line 21)
        x = t.subsrefBraces(s(1));

Error in sudoku.findPrimaryRegion (line 19)
    filledRegion = imerode(regions{end, 3}{1}, ones(3));

Error in sudoku.PuzzleSolver/findPuzzle (line 82)
            mask = sudoku.findPrimaryRegion(thresholdedImage);

Error in sudoku.PuzzleSolver/process (line 62)
            [mask, findSteps] = obj.findPuzzle(im);

It would be great if we could make it error in a more sensible way. So far, in my own repo I added the following in src/sudoku/+sudoku/findPrimaryRegions

if isempty(regions)
     error('A sudoku could not be found on the image')
end

EduardBenet avatar Feb 11 '20 11:02 EduardBenet