ivapylibs / puzzle_solver

1 stars 2 forks source link

Clustering classes #28

Closed pv33 closed 2 years ago

pv33 commented 3 years ago

Start to think through how to design the clustering classes (which are derived from the puzzle.board class). They will define additional virtual layers for the puzzle. These will be stored by the solver and acted upon to create plans, but won't be the actual estimated puzzle board. Describe here before advancing. Or describe in some document.

Uio96 commented 3 years ago

I still have a question about your proposal. Why do we want to derive the clustering classes from board instead of piece? I think it can be better managed at piece level as each piece has its own clustering features.

And my current idea is as follows:

For each puzzle piece, it will save a clustering feature vector (maybe more than 1 for pieces that have segmented edges) on both color and shape.

For the color feature, we can follow https://www.abtosoftware.com/blog/computer-vision-powers-automatic-jigsaw-puzzle-solver

To match the puzzles according to the colour of their borders the program first extracts the four borders from each puzzle piece. Then averages the colour values of several edge pixels along the perpendicular to the border and saves them in a vector of RGB values that are normalized to the uniform length

For the shape feature, we can use some existing metrics like moments or https://pypi.org/project/similaritymeasures/

Then those features will be used to create an action plan, e.g., in puzzle.manager, we associate pieces based on features; in puzzle.builder class, we create corrections based on features.

Uio96 commented 2 years ago

Here are the results: byColor, byShape, byEdgeType