Thursday, December 13, 2007

Elastic Boogy

All this pattern matching is producing lots of numbers and I don't want to examine long lists of matching scores anymore. I came up with the idea to build a viewer that would show me the similarity of a large number of sources in an attractive way.

Let me show you the result first and afterwards tell you how it was done. I took the same set of graphical icons as before and matched them with each other. I'm afraid the resolution of the uploaded video is worse than I expected, but hopefully your eyes can manage.




The icons are firstly placed in a random way and then start to mingle and cluster with similar icons. Notice for example how the red hearts start clustering almost immediately. Then the two red alarm clocks on the left edge decide they want to meet desperately. Finally a blue ID pass starts moving up from the bottom to get intimate with its best friend. See how they move in groups when they have found their 'best friends'.

I can tell you, for me it is so much more pleasing to see those icons crawl around instead of analysing all the matching scores in Excel!

Nerd-mode on:

The underlying technique is based on a force-directed graph of interconnected nodes. Each node is connected to every other node by a spring with a natural length based on the matching score of the two nodes. Similar nodes therefore have a tendency to stay close.

Apart from this spring attraction force we need a repulsion force to prevent the nodes from overlapping too much. Each node is considered an electrical charged particle with equal charge and therefore every pair of nodes undergoes Coulomb repulsion. There are some parameters to tweak to influence the behaviour such as the stiffness of the spring and the strength of repulsion. The code was actually far more simpler than I expected. The visualisation was done with DirectX 9.

Talk to you later!

No comments: