Quote:
I was wonder if it would be possible to create a program that could search an image for geometric structures i.e. squares or circles?
|
... as long as the language is turing-complete, yes
In the real world, in depends on what your definition of circles and squares are--how closely must the colors match, how closely must they mismatch their neighbour, how thick may the lines be, etc.
It's rather simple to do:
Code:
for each (x0, y0):
for each (x1, y1):
if spanssquare((x0, y0), (x1, y1)): yield ((x0, y0), (x1, y1))
def spanssquare((x0, y0), (x1, y1)):
for each (xt, yt) in (x0, y0) to (x1, y0):
if not color((xt, yt)) == color((x0, y0)): return False
for each (other line):
the same
return True
But it has the stupid effect of saying that any monochromatic area consists of squares all over the place.
So, the hard part is the definition of what a square is.
hth --Jonas