Woolz Image Processing
Version 1.8.3
|
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... | |
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. More... | |
double | WlzPolyLength (WlzPolygonDomain *poly, int wrap, WlzErrorNum *dstErr) |
Calculate the length of the input polyline. More... | |
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". More... | |
WlzPolygonDomain * | WlzPolyReverse (WlzPolygonDomain *poly, WlzErrorNum *dstErr) |
Reverse the vertex ordering in a polygon domain. More... | |
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. 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... | |
WlzObject * | WlzPolygonToObj (WlzObject *polygon, WlzPolyFillMode fillMode, WlzErrorNum *dstErr) |
Convert the input polygon to an interval domain. The domain is defined by the fillMode see WlzPolyToObj(). More... | |
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. More... | |
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. 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... | |
#define MAX_POLYSMOOTH_ITERATIONS 10 |
Maximum number of iterations of 1-2-1 smoothing in WlzPolySmooth
Referenced by WlzPolySmooth().
enum _WlzPolyFillMode |
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 |
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} \]
.
vtxs | vertex array |
i | index of first vertex |
j | index of second vertex |
k | index of third vertex |
References _WlzIVertex2::vtX, and _WlzIVertex2::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.
poly | input polygon domain |
wrap | wrap value of the input polyline, the returned line will have wrap=1 if the input wrap >= 1 |
maxDist | distance parameter to test vertex removal |
dstErr | error return |
References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::type, _WlzPolygonDomain::vtx, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_NONE, WLZ_ERR_PARAM_DATA, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, WlzIVtx2TriangleHeight(), and WlzMakePolygonDomain().
Referenced by WlzBoundDecimate().
double WlzPolyLength | ( | WlzPolygonDomain * | poly, |
int | wrap, | ||
WlzErrorNum * | dstErr | ||
) |
Calculate the length of the input polyline.
poly | input polygon domain |
wrap | wrap value of the p[olygon |
dstErr | error return |
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".
poly | input polygon domain |
wrap | wrap value of the input polygon |
spacing | required spacing |
keepOrigVtxs | flag to retain the original vertices, currently ignored |
dstErr | error return |
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.
poly | input polygon domain |
dstErr | error return |
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.
poly | input polygon domain, same type as the input polyline but after passing through WlzPolyEquispace |
wrap | wrap parameter for the input polyline, the new will have the same wrap |
iterations | number of ierations of 1-2-1 smoothing |
dstErr | error return |
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.
vtx | input vertex |
pgdm | input polygon domain |
dstErr | error return |
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.
vtx | input vertex |
pgdm | input polygon domain |
dstErr | error return |
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.
vtx | the input test vertex |
pgdm | input polygon domain |
dstErr | return error |
References WLZ_ERR_NONE, and WlzPolyCrossings().
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.
vtx | the input test vertex |
pgdm | input polygon domain |
dstErr | return error |
References WLZ_ERR_NONE, and WlzPolyCrossingsD().
WlzObject* WlzPolygonToObj | ( | WlzObject * | polygon, |
WlzPolyFillMode | fillMode, | ||
WlzErrorNum * | dstErr | ||
) |
Convert the input polygon to an interval domain. The domain is defined by the fillMode see WlzPolyToObj().
polygon | input polygon object |
fillMode | determines what is "inside" the domain, one of: WLZ_SIMPLE_FILL, WLZ_EVEN_ODD_FILL or WLZ_VERTEX_FILL |
dstErr | return error |
References _WlzValues::core, _WlzObject::domain, _WlzPlaneDomain::domains, _WlzPlaneDomain::kol1, _WlzPlaneDomain::lastkl, _WlzPlaneDomain::lastln, _WlzPlaneDomain::lastpl, _WlzPlaneDomain::line1, _WlzValues::obj, _WlzDomain::p, _WlzPlaneDomain::plane1, _WlzDomain::poly, _WlzObject::type, _WlzPlaneDomain::type, _WlzObject::values, _WlzPlaneDomain::voxel_size, WLZ_2D_POLYGON, WLZ_3D_DOMAINOBJ, WLZ_EMPTY_DOMAIN, WLZ_EMPTY_OBJ, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_DOMAIN_TYPE, WLZ_ERR_NONE, WLZ_ERR_OBJECT_NULL, WLZ_ERR_OBJECT_TYPE, WLZ_PLANEDOMAIN_DOMAIN, WLZ_PLANEDOMAIN_POLYGON, WLZ_TRANS_OBJ, WlzAssignDomain(), WlzFreeObj(), WlzFreePlaneDomain(), WlzMakeEmpty(), WlzMakeMain(), WlzMakePlaneDomain(), and WlzPolyToObj().
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.
pgdm | input polygon domain |
fillMode | determines which pixels are part of the domain one of: WLZ_SIMPLE_FILL, WLZ_EVEN_ODD_FILL or WLZ_VERTEX_FILL |
dstErr | return error |
References AlgSort(), _WlzValues::core, _WlzDomain::core, _WlzObject::domain, _WlzPolygonDomain::nvertices, _WlzDomain::poly, _WlzPolygonDomain::type, _WlzIVertex2::vtX, _WlzPolygonDomain::vtx, _WlzIVertex2::vtY, WLZ_EMPTY_OBJ, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_NONE, WLZ_ERR_OBJECT_TYPE, WLZ_ERR_PARAM_DATA, WLZ_EVEN_ODD_FILL, WLZ_POLYGON_DOUBLE, WLZ_POLYGON_FLOAT, WLZ_POLYGON_INT, WLZ_SIMPLE_FILL, WLZ_VERTEX_FILL, WlzAssignObject(), WlzMakeEmpty(), and WlzPolyTo8Polygon().
Referenced by WlzBoundToObj(), 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.
pgdm | input polygon domain |
wrap | wrap value of the new polygon domain |
dstErr | error return |
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(), and WlzPolyToObj().
WlzErrorNum WlzPolyVertices2I | ( | WlzPolygonDomain * | poly, |
int * | dstArySz, | ||
WlzIVertex2 ** | dstPolyAry | ||
) |
Access to an polygon domain's integer vertices.
poly | Given polygon domain. |
dstArySz | Destination pointer for the number of vertices. |
dstPolyAry | Destination 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.
poly | Given polygon domain. |
dstArySz | Destination pointer for the number of vertices. |
dstPolyAry | Destination pointer for the vertices. |
References _WlzPolygonDomain::nvertices, _WlzPolygonDomain::vtx, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_NONE, and WLZ_ERR_PARAM_NULL.