Woolz Image Processing  Version 1.7.5
WlzPolyline

Files

file  WlzPolyDecimate.c
 Functions to decimate polyline and boundary domains The functions remove vertices that are parts of straight lines as defined by a maximum distance. The algorithm starts at vertex 1, walks along the line until at least one vertex between the start and current position is more than max-dist from the straight line between vertex 1 and current. All vertices between position 1 and current-1 are removed and position 1 is incremented (to what was current-1). The process is then repeated.
 
file  WlzPolyEquispace.c
 Builds a new polygon domain with equi-spaced vertices.
 
file  WlzPolyReverse.c
 Functions to reverse the vertex ordering in a polygon domain.
 
file  WlzPolySmooth.c
 Smoothing operations for polylines.
 
file  WlzPolyToObj.c
 Makes a domain object from a polygon.
 
file  WlzPolyUtils.c
 Functions for manipulating polygon domains.
 

Data Structures

struct  _WlzPolygonDomain
 A 2D polyline domain with possible types: WLZ_POLYGON_INT, WLZ_POLYGON_FLOAT or WLZ_POLYGON_DOUBLE. Typedef: WlzPolygonDomain. More...
 
struct  _WlzPolygonDomain3
 A 2D polyline domain with possible types:WLZ_POLYGON_INT, WLZ_POLYGON_FLOAT or WLZ_POLYGON_DOUBLE. Typedef: WlzPolygonDomain. More...
 

Macros

#define MAX_POLYSMOOTH_ITERATIONS   10
 

Enumerations

enum  _WlzPolyFillMode {
  WLZ_SIMPLE_FILL,
  WLZ_EVEN_ODD_FILL,
  WLZ_VERTEX_FILL
}
 Polygon fill modes. Typedef: WlzPolyFillMode. More...
 

Functions

double WlzIVtx2TriangleHeight (WlzIVertex2 *vtxs, int i, int j, int k)
 Calculate the height of a triangle from the last vertex to the line defined by the first two. Uses formula that can be derived from Faux and Pratt p57-65 or see my lab notebook #1, p17. For three vertices \(\mathbf{v_1}, \mathbf{v_2}, \mathbf{v_3},\) we define the vectors \(\mathbf{r} = \mathbf{v_2} - \mathbf{v_1}\), \(\mathbf{s} = \mathbf{v_3} - \mathbf{v_1}\) then the the required height \(h\) is given by:

\[ h = \frac{|\mathbf{r}|^2|\mathbf{s}|^2 - (\mathbf{r}\cdot\mathbf{s})^2} {|\mathbf{r}|^2} \]

. More...

 
WlzPolygonDomainWlzPolyDecimate (WlzPolygonDomain *poly, int wrap, double maxDist, WlzErrorNum *dstErr)
 Decimate a polyline by removing vertices that are within straight line segments as defined by a maximum distance. The algorithm starts at vertex 1, walks along the line until at least one vertex between the start and current position is more than maxDist from the straight line between vertex 1 and current. All vertices between position 1 and current-1 are removed and position 1 is incremented (to what was current-1). The process is then repeated. More...
 
double WlzPolyLength (WlzPolygonDomain *poly, int wrap, WlzErrorNum *dstErr)
 Calculate the length of the input polyline. More...
 
WlzPolygonDomainWlzPolyEquispace (WlzPolygonDomain *poly, int wrap, double spacing, int keepOrigVtxs, WlzErrorNum *dstErr)
 Create a new polygon domain with vertices qually spaced along the original polyline. The wrap value is preserved and if keepOrigVtxs is non-zero then the original vertices will be kept. This results in non-equal spacing but the new line will be faithfull to the old and not "cut-corners". More...
 
WlzPolygonDomainWlzPolyReverse (WlzPolygonDomain *poly, WlzErrorNum *dstErr)
 Reverse the vertex ordering in a polygon domain. More...
 
WlzPolygonDomainWlzPolySmooth (WlzPolygonDomain *poly, int wrap, int iterations, WlzErrorNum *dstErr)
 performs iterative 1-2-1 smoothing on the polyline treating the x & y values independently. The smoothing of an integer polyline is done by converting first to double vertices then cnverting back at the end. More...
 
int WlzPolyCrossings (WlzIVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
 Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes integer vertices and that the vertex is not on the polyline. More...
 
int WlzPolyCrossingsD (WlzDVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
 Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes double vertices and that the vertex is not on the polyline. More...
 
int WlzInsidePolyEO (WlzIVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
 Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline. More...
 
int WlzInsidePolyEOD (WlzDVertex2 vtx, WlzPolygonDomain *pgdm, WlzErrorNum *dstErr)
 Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline. More...
 
WlzObjectWlzPolygonToObj (WlzObject *polygon, WlzPolyFillMode fillMode, WlzErrorNum *dstErr)
 Convert the input polygon to an interval domain. The domain is defined by the fillMode see WlzPolyToObj(). More...
 
WlzObjectWlzPolyToObj (WlzPolygonDomain *pgdm, WlzPolyFillMode fillMode, WlzErrorNum *dstErr)
 Convert the input polygon to an interval domain. The domain is defined by the fillMode: WLZ_SIMPLE_FILL - all pixels with winding number non-zero; WLZ_EVEN_ODD_FILL - all pixels with odd winding number; WLZ_VERTEX_FILL - all pixels through which the polyline passes. More...
 
WlzObjectWlzPolyTo8Polygon (WlzPolygonDomain *pgdm, int wrap, WlzErrorNum *dstErr)
 Returns the 8-connected, integer vertex polyline corresponding to the input polygon. The wrap value (number of overlapping vertices of the polygon ends) is included in case this is called to create an 8-connected boundary fro which the wrap needs to be preserved. WLZ_POLYGON_FLOAT and WLZ_POLYGON_DOUBLE polylines are converted to integer vertices using WlzValueCopyFVertexToIVertex and WlzValueCopyDVertexToIVertex respectively. More...
 
WlzErrorNum WlzPolyVertices2I (WlzPolygonDomain *poly, int *dstArySz, WlzIVertex2 **dstPolyAry)
 Access to an polygon domain's integer vertices. More...
 
WlzErrorNum WlzPolyVertices2D (WlzPolygonDomain *poly, int *dstArySz, WlzDVertex2 **dstPolyAry)
 Access to an polygon domain's double precision vertices. More...
 

Detailed Description

Macro Definition Documentation

#define MAX_POLYSMOOTH_ITERATIONS   10

Maximum number of iterations of 1-2-1 smoothing in WlzPolySmooth

Referenced by WlzPolySmooth().

Enumeration Type Documentation

Polygon fill modes. Typedef: WlzPolyFillMode.

Enumerator
WLZ_SIMPLE_FILL 

Fill all pixels with winding number > 0

WLZ_EVEN_ODD_FILL 

Fill all pixels with odd winding number

WLZ_VERTEX_FILL 

Fill all pixels lying under the polyline

Function Documentation

double WlzIVtx2TriangleHeight ( WlzIVertex2 vtxs,
int  i,
int  j,
int  k 
)

Calculate the height of a triangle from the last vertex to the line defined by the first two. Uses formula that can be derived from Faux and Pratt p57-65 or see my lab notebook #1, p17. For three vertices \(\mathbf{v_1}, \mathbf{v_2}, \mathbf{v_3},\) we define the vectors \(\mathbf{r} = \mathbf{v_2} - \mathbf{v_1}\), \(\mathbf{s} = \mathbf{v_3} - \mathbf{v_1}\) then the the required height \(h\) is given by:

\[ h = \frac{|\mathbf{r}|^2|\mathbf{s}|^2 - (\mathbf{r}\cdot\mathbf{s})^2} {|\mathbf{r}|^2} \]

.

Returns
height of the triangle to vertex k from baseline defined by vertices i, j
Parameters
vtxsvertex array
iindex of first vertex
jindex of second vertex
kindex of third vertex
Source:
WlzPolyDecimate.c

References _WlzIVertex2::vtX, _WlzFVertex2::vtX, _WlzDVertex2::vtX, _WlzIVertex2::vtY, _WlzFVertex2::vtY, and _WlzDVertex2::vtY.

Referenced by WlzPolyDecimate().

WlzPolygonDomain* WlzPolyDecimate ( WlzPolygonDomain poly,
int  wrap,
double  maxDist,
WlzErrorNum dstErr 
)

Decimate a polyline by removing vertices that are within straight line segments as defined by a maximum distance. The algorithm starts at vertex 1, walks along the line until at least one vertex between the start and current position is more than maxDist from the straight line between vertex 1 and current. All vertices between position 1 and current-1 are removed and position 1 is incremented (to what was current-1). The process is then repeated.

Returns
decimated polygon domain, NULL on error
Parameters
polyinput polygon domain
wrapwrap value of the input polyline, the returned line will have wrap=1 if the input wrap >= 1
maxDistdistance parameter to test vertex removal
dstErrerror return
Source:
WlzPolyDecimate.c

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzPolygonDomain::vtx, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_DOMAIN_TYPE, WLZ_ERR_NONE, WLZ_ERR_PARAM_DATA, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, WlzIVtx2TriangleHeight(), and WlzMakePolygonDomain().

Referenced by WlzBoundDecimate(), and WlzMeshTransformVerify().

double WlzPolyLength ( WlzPolygonDomain poly,
int  wrap,
WlzErrorNum dstErr 
)

Calculate the length of the input polyline.

Returns
length of the input polygon domain
Parameters
polyinput polygon domain
wrapwrap value of the p[olygon
dstErrerror return
Source:
WlzPolyEquispace.c

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzIVertex2::vtX, _WlzFVertex2::vtX, _WlzDVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, _WlzFVertex2::vtY, _WlzDVertex2::vtY, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_NONE, WLZ_ERR_PARAM_DATA, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, and WLZ_POLYGON_INT.

Referenced by WlzPolyEquispace().

WlzPolygonDomain* WlzPolyEquispace ( WlzPolygonDomain poly,
int  wrap,
double  spacing,
int  keepOrigVtxs,
WlzErrorNum dstErr 
)

Create a new polygon domain with vertices qually spaced along the original polyline. The wrap value is preserved and if keepOrigVtxs is non-zero then the original vertices will be kept. This results in non-equal spacing but the new line will be faithfull to the old and not "cut-corners".

Returns
new polygon domain with equally spaced vertices and the given wrap value
Parameters
polyinput polygon domain
wrapwrap value of the input polygon
spacingrequired spacing
keepOrigVtxsflag to retain the original vertices, currently ignored
dstErrerror return
Source:
WlzPolyEquispace.c

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzIVertex2::vtX, _WlzFVertex2::vtX, _WlzDVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, _WlzFVertex2::vtY, _WlzDVertex2::vtY, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_NONE, WLZ_ERR_PARAM_DATA, WLZ_NINT, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, WlzMakePolygonDomain(), and WlzPolyLength().

Referenced by WlzCMeshCompSurfMapToDomain(), and WlzPolySmooth().

WlzPolygonDomain* WlzPolyReverse ( WlzPolygonDomain poly,
WlzErrorNum dstErr 
)

Reverse the vertex ordering in a polygon domain.

Returns
New polygon domain with vertices reversed
Parameters
polyinput polygon domain
dstErrerror return
Source:
WlzPolyReverse.c

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzIVertex2::vtX, _WlzFVertex2::vtX, _WlzDVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, _WlzFVertex2::vtY, _WlzDVertex2::vtY, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, and WlzMakePolygonDomain().

WlzPolygonDomain* WlzPolySmooth ( WlzPolygonDomain poly,
int  wrap,
int  iterations,
WlzErrorNum dstErr 
)

performs iterative 1-2-1 smoothing on the polyline treating the x & y values independently. The smoothing of an integer polyline is done by converting first to double vertices then cnverting back at the end.

Returns
smoothed polygon domain, NULL on error
Parameters
polyinput polygon domain, same type as the input polyline but after passing through WlzPolyEquispace
wrapwrap parameter for the input polyline, the new will have the same wrap
iterationsnumber of ierations of 1-2-1 smoothing
dstErrerror return
Source:
WlzPolySmooth.c

References MAX_POLYSMOOTH_ITERATIONS, _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzFVertex2::vtX, _WlzDVertex2::vtX, _WlzPolygonDomain::vtx, _WlzFVertex2::vtY, _WlzDVertex2::vtY, WLZ_ERR_DOMAIN_TYPE, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_ERR_PARAM_DATA, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, WlzConvertPolyType(), WlzFreePolyDmn(), and WlzPolyEquispace().

Referenced by WlzBoundSmooth().

int WlzPolyCrossings ( WlzIVertex2  vtx,
WlzPolygonDomain pgdm,
WlzErrorNum dstErr 
)

Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes integer vertices and that the vertex is not on the polyline.

Returns
Winding number of the polyline with respect to the vertex
Parameters
vtxinput vertex
pgdminput polygon domain
dstErrerror return
Source:
WlzPolyToObj.c

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzIVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, _WlzFVertex2::vtY, _WlzDVertex2::vtY, WLZ_ERR_NONE, WLZ_ERR_POLYGON_TYPE, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, and WLZ_POLYGON_INT.

Referenced by WlzInsidePolyEO().

int WlzPolyCrossingsD ( WlzDVertex2  vtx,
WlzPolygonDomain pgdm,
WlzErrorNum dstErr 
)

Procedure to calculate winding number of the polygon with respect to the vertex. The algorithm is from "Comp Geom in C" by O'Rourke chap 7. It assumes double vertices and that the vertex is not on the polyline.

Returns
Winding number of the polyline with respect to the vertex
Parameters
vtxinput vertex
pgdminput polygon domain
dstErrerror return
Source:
WlzPolyToObj.c

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzDVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, _WlzFVertex2::vtY, _WlzDVertex2::vtY, WLZ_ERR_NONE, WLZ_ERR_POLYGON_TYPE, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, and WLZ_POLYGON_INT.

Referenced by WlzInsidePolyEOD().

int WlzInsidePolyEO ( WlzIVertex2  vtx,
WlzPolygonDomain pgdm,
WlzErrorNum dstErr 
)

Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline.

Returns
1 if the vertex is "inside" the polyline, 0 otherwise
Parameters
vtxthe input test vertex
pgdminput polygon domain
dstErrreturn error
Source:
WlzPolyToObj.c

References WLZ_ERR_NONE, and WlzPolyCrossings().

Referenced by WlzPolyToObj().

int WlzInsidePolyEOD ( WlzDVertex2  vtx,
WlzPolygonDomain pgdm,
WlzErrorNum dstErr 
)

Procedure to calculate if a vertex is inside the polygon using the even-odd rule. Algorithm from "Comp Geom in C" by O'Rourke chap 7 Assumes integer vertices and that the vertex is not on the polyline.

Returns
1 if the vertex is "inside" the polyline, 0 otherwise
Parameters
vtxthe input test vertex
pgdminput polygon domain
dstErrreturn error
Source:
WlzPolyToObj.c

References _WlzIVertex2::vtX, WLZ_ERR_NONE, and WlzPolyCrossingsD().

WlzObject* WlzPolygonToObj ( WlzObject polygon,
WlzPolyFillMode  fillMode,
WlzErrorNum dstErr 
)
WlzObject* WlzPolyToObj ( WlzPolygonDomain pgdm,
WlzPolyFillMode  fillMode,
WlzErrorNum dstErr 
)

Convert the input polygon to an interval domain. The domain is defined by the fillMode: WLZ_SIMPLE_FILL - all pixels with winding number non-zero; WLZ_EVEN_ODD_FILL - all pixels with odd winding number; WLZ_VERTEX_FILL - all pixels through which the polyline passes.

Returns
Woolz 2D domain object corresponding to the input polygon domain
Parameters
pgdminput polygon domain
fillModedetermines which pixels are part of the domain one of: WLZ_SIMPLE_FILL, WLZ_EVEN_ODD_FILL or WLZ_VERTEX_FILL
dstErrreturn error
Source:
WlzPolyToObj.c

References AlcFree(), AlcFreeStackPush(), AlcMalloc(), AlgSort(), _WlzValues::core, _WlzDomain::core, _WlzObject::domain, _WlzIntervalDomain::freeptr, _WlzDomain::i, _WlzInterval::ileft, _WlzIntervalDomain::intvlines, _WlzIntervalLine::intvs, _WlzInterval::iright, _WlzIntervalDomain::kol1, _WlzIntervalDomain::line1, _WlzPolygonDomain::nvertices, _WlzDomain::poly, _WlzIntervalDomain::type, _WlzPolygonDomain::type, _WlzIVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, WLZ_2D_DOMAINOBJ, WLZ_4_CONNECTED, WLZ_EMPTY_OBJ, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_MEM_ALLOC, WLZ_ERR_NONE, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_PARAM_DATA, WLZ_EVEN_ODD_FILL, WLZ_INTERVALDOMAIN_INTVL, WLZ_INTERVALDOMAIN_RECT, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, WLZ_SIMPLE_FILL, WLZ_VERTEX_FILL, WlzAssignObject(), WlzDiffDomain(), WlzFreeDomain(), WlzFreeObj(), WlzInsidePolyEO(), WlzLabel(), WlzMakeEmpty(), WlzMakeInterval(), WlzMakeIntervalDomain(), WlzMakeMain(), WlzPolyTo8Polygon(), and WlzUnionN().

Referenced by WlzBoundToObj(), WlzGreyMask(), WlzGreyTemplate(), WlzMeshFromObjBox(), and WlzPolygonToObj().

WlzObject* WlzPolyTo8Polygon ( WlzPolygonDomain pgdm,
int  wrap,
WlzErrorNum dstErr 
)

Returns the 8-connected, integer vertex polyline corresponding to the input polygon. The wrap value (number of overlapping vertices of the polygon ends) is included in case this is called to create an 8-connected boundary fro which the wrap needs to be preserved. WLZ_POLYGON_FLOAT and WLZ_POLYGON_DOUBLE polylines are converted to integer vertices using WlzValueCopyFVertexToIVertex and WlzValueCopyDVertexToIVertex respectively.

Returns
8-connected polygon object
Parameters
pgdminput polygon domain
wrapwrap value of the new polygon domain
dstErrerror return
Source:
WlzPolyToObj.c

References AlcFree(), AlcMalloc(), _WlzValues::core, _WlzDomain::core, _WlzPolygonDomain::nvertices, _WlzDomain::poly, _WlzPolygonDomain::type, _WlzIVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, WLZ_2D_POLYGON, WLZ_EMPTY_OBJ, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_MEM_ALLOC, WLZ_ERR_NONE, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_PARAM_DATA, WLZ_NINT, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, WlzMakeEmpty(), WlzMakeMain(), WlzMakePolygonDomain(), WlzValueCopyDVertexToIVertex(), and WlzValueCopyFVertexToIVertex().

Referenced by WlzBoundTo8Bound(), WlzCMeshTransformManyObjAsIdx(), WlzMeshTransformVerify(), and WlzPolyToObj().

WlzErrorNum WlzPolyVertices2I ( WlzPolygonDomain poly,
int *  dstArySz,
WlzIVertex2 **  dstPolyAry 
)

Access to an polygon domain's integer vertices.

Returns
Woolz error code.
Parameters
polyGiven polygon domain.
dstArySzDestination pointer for the number of vertices.
dstPolyAryDestination pointer for the vertices.

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::vtx, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_NONE, and WLZ_ERR_PARAM_NULL.

WlzErrorNum WlzPolyVertices2D ( WlzPolygonDomain poly,
int *  dstArySz,
WlzDVertex2 **  dstPolyAry 
)

Access to an polygon domain's double precision vertices.

Returns
Woolz error code.
Parameters
polyGiven polygon domain.
dstArySzDestination pointer for the number of vertices.
dstPolyAryDestination pointer for the vertices.

References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::vtx, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_NONE, and WLZ_ERR_PARAM_NULL.