Skip to content

Sensible error when the image does not contain a sudoku. #1

@EduardBenet

Description

@EduardBenet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions