I was curious how does a computer go about recognizing shapes like a triangle or a rectangle. I couldn't figure it out so I did some research and learnt a technique used decades ago. A computer converts a shape into its outline form and counts how many times the gradient changes. If the gradient changes 3 times, its a triangle, 4 times, a quadrilateral etc. I just happened to have the tools to realize a shape recognition so I built my own - I will now share with you. Firstly there is a color filter that filters-through the shape of interest.
You select the shape's color and only the object is filtered through. (Check out my article on color filter!) Second, you apply a blobing routine to create a solid shape. This compensates for any unfiltered parts of the shape that may have resulted from random lighting or uneven coloring of the shape.

Thirdly, an outlining algorithm is applied to get the outline of the shape. In another article I explain how this is done. Finally you apply a simple gradient counting algorithm to determine how many sides the shape has.
This algorithm scans from top left to bottom right for the first pixel and draws a line through this pixel. That line rotates 360 degrees recording the number of pixels on it in each position. The gradient that had the max number of pixels is recorded and represents the gradient of one side of the shape. All those pixels get deleted and now the process repeats again to determine a new side until there are no longer pixels to investigate. Now you know how many times the gradient changed and hence how many sides the shape has. Here is very nice feature. You can actually see what the computer sees!
That is the computer sees in terms of these lines the computer manuipulates to determine the shape infront of it. And here you see an augmented reality rendition of the shape being identified.
A shape recognizer!

Here the shape recognizer takes a go at a quadrilateral!

Site Links

Fleamarket (en)
Flohmarkt (de)
Recipes (en)
Rezept (de)
Experiments (en)
Experimenten (de)
Home Repair(en)
Heimreparatur (de)
Aufsätze (de)
Java Applets(en)/(de)

Miscellaneous (en)
Sonstiges (de)