Say I have a 2 color graphic file. The background is white. The foreground is black and has lines and arcs drawn on the white background.

The lines and arcs may overlap, but I want to "extract" only lines and arcs. Actually, the image approximates lines and arcs; they may not be perfectly straight lines or constant radii arcs.

1) Say the image contains only 1 line. How do I get (extract) the endpoints of such a line? I consider knowing xStart, yStart, xEnd, yEnd as "extracting" the line from the image.

2) Say the image contains multiple non-overlapping lines as in #1. For let's say 1 to n lines; how do I get xStart(1), yStart(1), xEnd(1), yEnd(1); through xStart(n), yStart(n), xEnd(n), yEnd(n).

3) Same as #2 but with overlapping lines.

4) What if the lines aren't exactly straight? Perhaps a polyline or several arcs can represent this approximated line.

5) How about arcs?

I guess my real issue is that the lines can be at any angle and I'm blocked by thinking I can only process lines at 45 degree intervals to my present pixel location. For instance, consider the pixel at position 5:

123
456
789

The neigboring pixels are oriented at multiples of 45 degrees with respect to position 5. But how would I track a line that is at any angle and begins at position 5?

Thanks.