?he 'SEELINES'- % -'LIB "SEELINES"'
?fo 'Aaron Sloman''April 11 1977'
.mh
A LIBRARY PROGRAM TO ANALYSE PICTURES
= ======= ======= == ======= ========
.hm
The PICTURES demo outlines a project involving programs which examine turtle
pictures to find lines, junctions, and other familiar structures.
Most of it is concerned with line finding. If you would like to get a
taste of the sort of thing a program can do, you should try the
following.
.pg
.pg
Load the picture analysing package. The command for this is:
 	: LIB "SEELINES";
.pg
This will load the turtle package if you have not already done so.
It also loads the
FDATABASE
package, which speeds up the database functions.
.pg
Now draw a simple turtle picture.
Don't make it very big and complex, or the
SEELINES
program will take a long time. E.g. a picture containing up to
ten lines, each made of between four and ten consecutive
dots should not take too long.
But first try a simple picture, e.g. a square with a diagonal.
.pg
Initially the database is empty, as you can check by typing
 	: DATABASE ==>

Now you can trace some of the analysing functions, for instance
 	: TRACE FINDLINES FINDALLLINES FINDJUNCTIONS MARKALLLINES
 	:	SCAN;

Next run the analysis procedure thus:
 	: SEELINES();

You'll get quite a lot of printing, the exact amount depending on how
many points are in your picture. At the end, type:
 	: DATABASE ==>

to see what the program has learned about your picture.
.pg
Notice that it gives each row, column, left-sloping diagonal
and right-sloping diagonal a number. Can you work out how?
For each such row column or diagonal containing points it makes a
list of all the points.
The rows columns and diagonals containing no "acceptable" lines are
removed.
.pg
The minimum length of "acceptable" lines is controlled by the variable
MINLINELENGTH
which is initially set to 3. A line of length 3 contains four dots.
So any row, column or diagonal not containing at least one set of
four consecutive dots will be eliminated from the database.
If you reduce
MINILINELENGTH
e.g. to 2, then you'll find that the program records some short
"unintended" lines, near junctions where three lines meet.
.pg
The program uses lists of collinear points to find lines consisting of
four or more consecutive dots.  A line of three or two dots will be ignored,
unless
MINLINELENGTH
is reset.
.pg
Each line is represented by a list containinging the word "LINE",
a word indicating the orientation, and the two ends of the line.
For every point which is either an end or a junction the program stores a
list starting with the word "END" or a
word specifying the type of junction, e.g.
"ELL", "CROSS", "TEE", "ARROW",
etc., then the point,
then a list of the relevant lines.
.pg
At present, the program
does not notice if two diagonal lines go through each
other without a point in common, like a black and a white diagonal
on a chess board.
After reading the PICTURES demo, you may like to try 
designing a better program.
.pg
You could use SEELINES
to do a preliminary analysis of some pictures, and write your own
programs to use the results to recognise squares, triangles, or
other familiar shapes.
.pg
Before each run
SEELINES
empties the database. So if you wish to store the results of a
run in a file, use
STOREDATA
(see the demo on it).
Alternatively you can assign
CONTEXT
to some other variable, to save the database. Assigning it back
to
CONTEXT
later will make it accessible again.
.pg
Try to work out what the program is doing, from the tracing and from
the effect on the database. You can get still more printout by
tracing some or all of the following functions:
.in +5
.ll -5
ADDTOLIST ROWOF COLUMNOF RIGHTDIAGOF LEFTDIAGOF NEXTTO CANDIDATELINE
RECORDPOINT
FINDSENDSOFLINES
.sp
.sp
.ul
Note:
At present the program can distinguish the following sorts of junctions:
ELL, CROSS, TEE,
ARROW,
FORK,
PSI,
and KAY.
junctions,
by typing:
 	: LIB"JUNCTIONS";
.br
.ll +5
