Centerline.mesa
Copyright Ó 1984, 1985, 1992 by Xerox Corporation. All rights reserved.
Maureen Stone October 17, 1984 4:31:08 pm PDT
Doug Wyatt, September 5, 1985 2:42:31 pm PDT
Centerline: CEDAR DEFINITIONS =
BEGIN
This provides an alternative method for getting a sampled curve from an image, appropriate if the image consists of a line drawing. The basic idea is to first blur the image so that the backround just reaches the center of lines of the desired width, and then to trace out the 'valley' thus defined.
Handle: TYPE = REF Rec;
Rec:
TYPE =
RECORD [
width: REAL, --expected line width
t: REAL, --threshold at which we are definitely outside of the line
maxV: INT, --maximum pixel value
startX, startY, endX, endY: INT, --window on image
get: PROC[client: REF, x,y: INT] RETURNS[INT], --called to get pixels
newPoint:
PROC[client:
REF, x,y:
REAL]
RETURNS[abort: BOOLEAN ¬ FALSE],--return points on curve to client
client: REF, --returned to client in procs above
data: REF --private data for the outline procedures
];
CurveTrace: PUBLIC PROC[h: Handle, x1,y1,x2,y2: REAL];
Traces a curve. The expected line width is h.w. The trace will start at (x1,y1), and will end somewhere. One possible end condition is that the trace comes close to (x2,y2) or (x1,y1), another is that the sampled value exceeds the threshold h.t. The trace starts out in the approximate direction of (x2,y2)
InvalidID: SIGNAL;
GetOutline:
PROC [data:
REF, newPoint:
PROC[x,y:
REAL], id:
INT];
data should be handle.data. The id is the outline number [0..nOutlines]. Call this procedure in a loop to get all the outlines.
END.