approx_chain2 ( : : Row, Column, Chain : ArcCenterRow, ArcCenterCol, ArcAngle, ArcBeginRow, ArcBeginCol, LineBeginRow, LineBeginCol, LineEndRow, LineEndCol, Order )

Approximate a closed chain code by arcs and lines.

The chain code of a closed curve is approximated by a sequence of lines and arcs.

The result of the procedure is returned separately as arcs and lines. If one is interested in the sequence of the segments the individual resulting elements can be read successively from the resulting tuples; the sequence can be taken from the return parameter order (0: next element is next line segment, 1: next element is next arc segment).

The operator approx_chain2 behaves similarly as approx_chain1 except that in the case of approx_chain2 the missing parameters are internally allocated as follows: MinWidthCoord = 1.0,MaxWidthCoord = 3.0, ThreshStart = 0.5, ThreshEnd = 0.9, ThreshStep = 0.3, MinWidthSmooth = 1.0, MaxWidthSmooth = 3.0, MinWidthCurve = 2, MaxWidthCurve = 9, Weight1 = 1.0, Weight2 = 1.0, Weight3 = 1.0.


Parameters

Row (input_control)
chain.begin.y -> integer
Row of the chain code starting point.
Default value: 32

Column (input_control)
chain.begin.x -> integer
Column of the chain code starting point.
Default value: 32

Chain (input_control)
chain.code-array -> integer
Chain code.

ArcCenterRow (output_control)
arc.center.y-array -> integer
Row of the center of an arc.

ArcCenterCol (output_control)
arc.center.x-array -> integer
Column of the center of an arc.

ArcAngle (output_control)
arc.angle.rad-array -> real
Angle of an arc.

ArcBeginRow (output_control)
arc.begin.y-array -> integer
Row of the starting point of an arc.

ArcBeginCol (output_control)
arc.begin.x-array -> integer
Column of the starting point of an arc.

LineBeginRow (output_control)
line.begin.y-array -> integer
Row of the starting point of a line segment.

LineBeginCol (output_control)
line.begin.x-array -> integer
Column of the starting point of a line segment.

LineEndRow (output_control)
line.end.y-array -> integer
Row of the ending point of a line segment.

LineEndCol (output_control)
line.end.x-array -> integer
Column of the ending point of a line segment.

Order (output_control)
integer-array -> integer
Sequence of line (value 0) and arc segments (value 1).


Example
/* Kantenbild einlesen */
read_picture(&Image,"tiff",0,0,"fig1_kan",&channels);
/* Rand bestimmen */
hysteresis_threshold__(Image,&RK1,64,255,40,1);
connection(RK1,&Rand);
/* Kettencode holen */
T_fetch_chain(Rand,&Tline,&Tcol,&Chain);
firstline = get_i(Tline,0);
firstcol = get_i(Tcol,0);
/* Approximation durch Linien und Kreisb"ogen */
T_approx_chain2(Tline,Tcol,Chain,
                &Bzl,&Bzc,&Br,&Bwl,&Bwc,&Ll0,&Lc0,&Ll1,&Lc1,&order);
nob = length_tuple(Bzl);
nol = length_tuple(Ll0);
/* draw lines and arcs */
set_line_width(4);
if (nob>0) T_disp_arc(Bzl,Bzc,Br,Bwl,Bwc);
set_line_width(1);
if (nol>0) T_disp_line(Ll0,Lc0,Ll1,Lc1);

Result

The operator approx_chain2 returns the value TRUE if the parameters are correct. Otherwise an exception is raised.


Possible Predecessors

sobel_amp, edges__, fetch_chain, threshold__, hysteresis_threshold__


Possible Successors

set_line_width, disp_arc, disp_line


Alternatives

fetch_polygon, approx_chain1


See also

fetch_chain, smallest_circle, disp_circle, disp_line



Copyright © 1996-1997 MVTec Software GmbH