Woolz Image Processing  Version 1.7.5
WlzMorphologyOps

## Files

file  WlzDilation.c
Functions for dilating objects with spatial domains.

file  WlzDistTransform.c
Distance transform functions which calculate the distance of every pixel/voxel in a foreground object from a reference object.

file  WlzDomainNearby.c
Functions for computing the portion of a domain which is nearby (all pixels/voxels less than a given distance from) given locations.

file  WlzErosion.c
Morphological erosion of domain objects.

file  WlzErosion4.c
Performs 4-connected erosion on domain objects.

file  WlzStdStructElements.c
Standard structuring elements in 2D and 3D.

file  WlzStructDilation.c
Performs dilation using a structuring element.

file  WlzStructErosion.c
Performs erosion using a structuring element.

## Enumerations

enum  _WlzSpecialStructElmType {
WLZ_SPEC_STRUCT_ELM_H4,
WLZ_SPEC_STRUCT_ELM_EX4,
WLZ_SPEC_STRUCT_ELM_A8,
WLZ_SPEC_STRUCT_ELM_H6,
WLZ_SPEC_STRUCT_ELM_H5,
WLZ_SPEC_STRUCT_ELM_H7,
WLZ_SPEC_STRUCT_ELM_A3,
WLZ_SPEC_STRUCT_ELM_E1,
WLZ_SPEC_STRUCT_ELM_E2,
WLZ_SPEC_STRUCT_ELM_V2
}
Special structuring elements for morphological operations. Typedef: WlzSpecialStructElmType. More...

## Functions

WlzObjectWlzDilation (WlzObject *obj, WlzConnectType connectivity, WlzErrorNum *dstErr)
Dilate the given object using the given connectivity type. Since the dilated object is bigger than the original, the size of the valuetable may be smaller than the dilated object. User has to take fully responsibility for using grey value of dilated object. More...

WlzObjectWlzDistanceTransform (WlzObject *forObj, WlzObject *refObj, WlzDistanceType dFn, double dParam, double dMax, WlzErrorNum *dstErr)
Computes the distance of every pixel/voxel in the foreground object from the reference object. More...

WlzObjectWlzDomainNearby3D (WlzObject *refObj, int nPos, WlzDVertex3 *pos, WlzDistanceType dFn, double dMax, WlzErrorNum *dstErr)
This function is just a wrapper for WlzDomainNearby(). More...

WlzObjectWlzDomainNearby (WlzObject *refObj, int nPos, WlzVertexP pos, WlzDistanceType dFn, double dMax, WlzErrorNum *dstErr)
Computes a new domain in which all pixels/voxels are nearby given location(s) and within the reference domain. More...

WlzObjectWlzErosion (WlzObject *obj, WlzConnectType connectivity, WlzErrorNum *dstErr)
Calculates the morphological erosion of a woolz object with a structuring element defined by the connectivity. More...

WlzObjectWlzErosion4 (WlzObject *obj, WlzErrorNum *dstErr)
4-connected erosion of a woolz domain object.2D objects only.This should not really be publicly accessible, but is present for historical reasons. Therefore the prototype does not appear in WlzProto.h. WlzErosion should be used to access 4-connected erosion. More...

WlzObjectWlzMakeSpecialStructElement (WlzSpecialStructElmType eType, int elmIndex, WlzErrorNum *dstErr)
Return a pointer to a specific requested "special" structuring element. These are inherited from the original woolz library with rather cryptic names. See detail for more explanation of the elements and the additional parameters. More...

WlzObjectWlzMakeSinglePixelObject (WlzObjectType oType, int k, int l, int p, WlzErrorNum *dstErr)
Make a single pixel/voxel object at the specified coordinate position. More...

WlzObjectWlzMakeCircleObject (double radius, double x, double y, WlzErrorNum *dstErr)
Generate a discretised circle domain centered at (x,y). More...

Generate a rectangular object centered at (x,y) with half-width radiusX and half-height radius Y. More...

WlzObjectWlzMakeSphereObject (WlzObjectType oType, double radius, double x, double y, double z, WlzErrorNum *dstErr)
Make a spherical domain object. More...

WlzObjectWlzMakeCuboidObject (WlzObjectType oType, double radiusX, double radiusY, double radiusZ, double x, double y, double z, WlzErrorNum *dstErr)
Generate a cuboid object centered at (x,y,z). More...

WlzObjectWlzMakeQuadrilateral (double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, WlzErrorNum *dstErr)
Generate 2D interval domain object corresponding to the arbitrarily oriented quadrilateral with the given ordered vertex coordinates. The ordering is such that the vertices allow the rectangle to be drawn by line segments conecting v[i] to v[(i + 1)%4], with i $$\in$$ [0-3]. More...

WlzObjectWlzMakeStdStructElement (WlzObjectType oType, WlzDistanceType dType, double radius, WlzErrorNum *dstErr)
Makes a standard structure element - basicaly a sphere but with the appropriate connectivity or distance metric. More...

WlzObjectWlzStructDilation (WlzObject *obj, WlzObject *structElm, WlzErrorNum *dstErr)
Dilate an object with respect to the given structuring element. This is defined as the domain obtained as the union of the SE placed at every pixel of the input domain. More...

WlzObjectWlzStructErosion (WlzObject *obj, WlzObject *structElm, WlzErrorNum *dstErr)
Performs erosion using a structuring element. More...

## Enumeration Type Documentation

Special structuring elements for morphological operations. Typedef: WlzSpecialStructElmType.

Enumerator
WLZ_SPEC_STRUCT_ELM_H4
WLZ_SPEC_STRUCT_ELM_EX4
WLZ_SPEC_STRUCT_ELM_A8
WLZ_SPEC_STRUCT_ELM_H6
WLZ_SPEC_STRUCT_ELM_H5
WLZ_SPEC_STRUCT_ELM_H7
WLZ_SPEC_STRUCT_ELM_A3
WLZ_SPEC_STRUCT_ELM_E1
WLZ_SPEC_STRUCT_ELM_E2
WLZ_SPEC_STRUCT_ELM_V2

## Function Documentation

 WlzObject* WlzDilation ( WlzObject * obj, WlzConnectType connectivity, WlzErrorNum * dstErr )

Dilate the given object using the given connectivity type. Since the dilated object is bigger than the original, the size of the valuetable may be smaller than the dilated object. User has to take fully responsibility for using grey value of dilated object.

Returns
Dilated object.
Parameters
 obj Given object. connectivity Required type of conectivity. dstErr Destination error pointer, may be NULL.
 WlzObject* WlzDistanceTransform ( WlzObject * forObj, WlzObject * refObj, WlzDistanceType dFn, double dParam, double dMax, WlzErrorNum * dstErr )

Computes the distance of every pixel/voxel in the foreground object from the reference object.

Returns
Distance object which shares the given foreground object's domain and has integer distance values, null on error.

A distance transform maps all position within a forground domain to their distances from a reference domain. The distance transforms implemented within this function use efficient morphological primitives.

Given two domains, $$\Omega_r$$ the reference domain and $$\Omega_f$$ the domain specifying the region of interest, a domain with a thin shell $$\Omega_i$$ is iteratively expanded from it's initial domain corresponding to the reference domain $$\Omega_r$$. At each iteration $$\Omega_i$$ is dilated and clipped by it's intersection with $$\Omega_f$$ until $$\Omega_i$$ becomes the null domain $$\emptyset$$. At each iteration the current distance is recorded in a value table which covers the domain $$\Omega_f$$.

An octagonal distance scheme may be used in which the distance metric is alternated between 4 and 8 connected for 2D and 6 and 26 connectivities in 3D. See: G. Borgefors. "Distance Transformations in Arbitrary Dimensions" CVGIP 27:321-345, 1984.

    An approximate Euclidean distance transform may be computed
by: Scaling the given foreground and reference objects using
the given approximation scale parameter, dilating the
reference domain using a sphere with a radius having the same
value as the scale parameter and then finaly sampling the
scaled distances.

Parameters
 forObj Foreground object. refObj Reference object. dFn Distance function which must be appropriate to the dimension of the foreground and reference objects. dParam Parameter required for distance function. Currently only WLZ_APX_EUCLIDEAN_DISTANCE requires a parameter. In this case the parameter is the approximation scale. dMax Maximum distance before itteration stops, <= 0 implies an infinite maximum distance. dstErr Destination error pointer, may be NULL.

Referenced by WlzDomainNearby(), WlzInteriority(), WlzOffsetDist(), and WlzRegConCalcRCC().

 WlzObject* WlzDomainNearby3D ( WlzObject * refObj, int nPos, WlzDVertex3 * pos, WlzDistanceType dFn, double dMax, WlzErrorNum * dstErr )

This function is just a wrapper for WlzDomainNearby().

Returns
A new domain in which all pixels/voxels are nearby the given location(s). The object returned will either be of the same type as the reference object or an empty object if (all) the given location(s) are outside of the reference object's domain. On error a NULL pointer will be returned.
Parameters
 refObj Reference object which must be of type WLZ_EMPTY_OBJ or WLZ_3D_DOMAINOBJ. nPos Number of locations. pos 3D locations. dFn The connectivity to use when establishing distance. This must be one of: WLZ_OCTAGONAL_DISTANCE WLZ_4_DISTANCE WLZ_6_DISTANCE WLZ_8_DISTANCE WLZ_18_DISTANCE WLZ_26_DISTANCE Distances must be appropriate for the given object type although all are acceptable for an empty object. dMax Maximum distance for a pixel/voxel to be considered nearby. dstErr Destination error pointer, may be NULL.

References _WlzVertexP::d3, and WlzDomainNearby().

 WlzObject* WlzDomainNearby ( WlzObject * refObj, int nPos, WlzVertexP pos, WlzDistanceType dFn, double dMax, WlzErrorNum * dstErr )

Computes a new domain in which all pixels/voxels are nearby given location(s) and within the reference domain.

Returns
A new domain in which all pixels/voxels are nearby the given location(s). The object returned will either be of the same type as the reference object or an empty object if (all) the given location(s) are outside of the reference object's domain. On error a NULL pointer will be returned.
Parameters
 refObj Reference object which must be of type WLZ_EMPTY_OBJ, WLZ_2D_DOMAINOBJ or WLZ_3D_DOMAINOBJ. nPos Number of locations. pos Locations which are either of type WlzDVertex2 if the given object is of type WLZ_2D_DOMAINOBJ or WlzDVertex3 if the given object is of type WLZ_3D_DOMAINOBJ. dFn The connectivity to use when establishing distance. This must be one of: WLZ_OCTAGONAL_DISTANCE WLZ_4_DISTANCE WLZ_6_DISTANCE WLZ_8_DISTANCE WLZ_18_DISTANCE WLZ_26_DISTANCE Distances must be appropriate for the given object type although all are acceptable for an empty object. dMax Maximum distance for a pixel/voxel to be considered nearby. dstErr Destination error pointer, may be NULL.

Referenced by WlzDomainNearby3D().

 WlzObject* WlzErosion ( WlzObject * obj, WlzConnectType connectivity, WlzErrorNum * dstErr )

Calculates the morphological erosion of a woolz object with a structuring element defined by the connectivity.

Returns
Eroded object or without values or NULL on error.
Parameters
 obj Object to be eroded, must be a 2D or 3D domain object (including a WlzTransObj). connectivity Type of connectivity. dstErr Destination error pointer, may be NULL.
 WlzObject* WlzErosion4 ( WlzObject * obj, WlzErrorNum * dstErr )

4-connected erosion of a woolz domain object.2D objects only.This should not really be publicly accessible, but is present for historical reasons. Therefore the prototype does not appear in WlzProto.h. WlzErosion should be used to access 4-connected erosion.

Returns
Eroded object.
Parameters
 obj Input object. dstErr Error return.
Source:
WlzErosion4.c

Referenced by WlzErosion().

 WlzObject* WlzMakeSpecialStructElement ( WlzSpecialStructElmType eType, int elmIndex, WlzErrorNum * dstErr )

Return a pointer to a specific requested "special" structuring element. These are inherited from the original woolz library with rather cryptic names. See detail for more explanation of the elements and the additional parameters.

Returns
Structuring element object pointer.
Special element types:
WLZ_SPEC_STRUCT_ELM_H4 2D SE, origin - centre:
 0 1 0 1 1 1 0 1 0

WLZ_SPEC_STRUCT_ELM_EX4 2D SE, origin - centre:
 1 1 1 0 1 0 1 1 1

WLZ_SPEC_STRUCT_ELM_A8 2D SE, origin - centre:
 1 1 1 1 1 1 1 1 1

WLZ_SPEC_STRUCT_ELM_H6 elmIndex = 0,1,2 2D SE, origin - centre:
 0 1 1 1 1 1 1 1 0
 1 1 0 1 1 1 0 1 1
 1 1 1 1 1 1 0 1 0

WLZ_SPEC_STRUCT_ELM_H6 elmIndex = 3,4,5 2D SE, origin - centre:
 1 1 0 1 1 1 1 1 0
 0 1 0 1 1 1 1 1 1
 0 1 1 1 1 1 0 1 1

WLZ_SPEC_STRUCT_ELM_H5 elmIndex = 0,1,2,3 2D SE, origin - centre:
 0 1 0 1 1 1 1 1 0
 0 1 0 1 1 1 0 1 1
 0 1 1 1 1 1 0 1 0
 1 1 0 1 1 1 0 1 0
WLZ_SPEC_STRUCT_ELM_H7 elmIndex = 0,1,2,3 2D SE, origin - centre:
 1 1 1 1 1 1 0 1 1
 1 1 1 1 1 1 1 1 0
 1 1 0 1 1 1 1 1 1
 0 1 1 1 1 1 1 1 1
WLZ_SPEC_STRUCT_ELM_A3 elmIndex = 0,1,2,3 2D SE, origin - centre:
 0 0 0 1 1 1 0 1 0
 0 1 0 0 1 1 0 1 0
 0 1 0 1 1 1 0 0 0
 0 1 0 1 1 0 0 1 0
WLZ_SPEC_STRUCT_ELM_E1 2D SE, origin - left:/td>
 1 1
WLZ_SPEC_STRUCT_ELM_E2 2D SE, origin - centre:
 1 1 1
WLZ_SPEC_STRUCT_ELM_V2 2D SE, origin - centre:
 1 1 1
Parameters
 eType Enumerated type of the requested special element. elmIndex Additional parameter for a particular element if required (see details). dstErr Destination error pointer, may be NULL.
 WlzObject* WlzMakeSinglePixelObject ( WlzObjectType oType, int k, int l, int p, WlzErrorNum * dstErr )

Make a single pixel/voxel object at the specified coordinate position.

Returns
Single pixel object with coordinates (k,l,p).
Parameters
 oType Object type - WLZ_2D_DOMAINOBJ or WLZ_3D_DOMAINOBJ. k Column (x) coordinate. l Line (y) coordinate. p Plane (z) coordinate. dstErr Destination error pointer, may be NULL.

References _WlzValues::core, WLZ_ERR_NONE, WlzFreeDomain(), and WlzMakeMain().

 WlzObject* WlzMakeCircleObject ( double radius, double x, double y, WlzErrorNum * dstErr )

Generate a discretised circle domain centered at (x,y).

Returns
Object with circular domain.
Parameters
 radius Circle radius. x Column/x coordinate of the circle centre. y Row/y coordinate of the circle centre. dstErr Destination error pointer, may be NULL.

Referenced by WlzCMeshFromObj2D(), WlzDrawDomainObj(), WlzMakeSphereObject(), and WlzMeshFromObjBox().

 WlzObject* WlzMakeRectangleObject ( double radiusX, double radiusY, double x, double y, WlzErrorNum * dstErr )

Generate a rectangular object centered at (x,y) with half-width radiusX and half-height radius Y.

Returns
Rectangular object
Parameters
 radiusX Column half-width of rectangle radiusY Line (y) half-width of rectangle x Column (x) rectangle centre. y Line (y) rectangle centre. dstErr Destination error pointer, may be NULL.
 WlzObject* WlzMakeSphereObject ( WlzObjectType oType, double radius, double x, double y, double z, WlzErrorNum * dstErr )

Make a spherical domain object.

Returns
Sphere object
Parameters
 oType Object type - make a circle if 2D. radius Sphere radius x Column (x) centre. y Line (y) centre. z Plane (x) centre. dstErr Destination error pointer, may be NULL.
 WlzObject* WlzMakeCuboidObject ( WlzObjectType oType, double radiusX, double radiusY, double radiusZ, double x, double y, double z, WlzErrorNum * dstErr )

Generate a cuboid object centered at (x,y,z).

Returns
Cuboid domain object
Parameters
 oType Object type use WlzMakerectangleObject() if 2D. radiusX Cuboid half-width (x) radiusY Cuboid half-height (y). radiusZ Cuboid half-depth (z). x Column (x) centre. y Line (y) centre. z Plane (z) centre. dstErr Destination error pointer, may be NULL.

Referenced by WlzCMeshFromObj3D(), WlzMakeTiledValuesObj3D(), and WlzPointsFromDomObj().

 WlzObject* WlzMakeQuadrilateral ( double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3, WlzErrorNum * dstErr )

Generate 2D interval domain object corresponding to the arbitrarily oriented quadrilateral with the given ordered vertex coordinates. The ordering is such that the vertices allow the rectangle to be drawn by line segments conecting v[i] to v[(i + 1)%4], with i $$\in$$ [0-3].

Returns
Parameters
 x0 Column coordinate of the first vertex. y0 Row coordinate of the first vertex. x1 Column coordinate of the second vertex. y1 Row coordinate of the second vertex. x2 Column coordinate of the third vertex. y2 Row coordinate of the third vertex. x3 Column coordinate of the forth vertex. y3 Row coordinate of the forth vertex. dstErr Destination error pointer, may be NULL.

Referenced by WlzDrawDomainObj().

 WlzObject* WlzMakeStdStructElement ( WlzObjectType oType, WlzDistanceType dType, double radius, WlzErrorNum * dstErr )

Makes a standard structure element - basicaly a sphere but with the appropriate connectivity or distance metric.

Returns
Parameters
 oType Object type - WLZ_2D_DOMAINOBJ or WLZ_3D_DOMAINOBJ. dType Distance metric. radius Sphere radius. dstErr Destination error pointer, may be NULL.
 WlzObject* WlzStructDilation ( WlzObject * obj, WlzObject * structElm, WlzErrorNum * dstErr )

Dilate an object with respect to the given structuring element. This is defined as the domain obtained as the union of the SE placed at every pixel of the input domain.

Returns
Dilated domain object.
Parameters
 obj Input object to be dilated structElm Structuring element. dstErr Error return.
Source:
WlzStructDilation.c
 WlzObject* WlzStructErosion ( WlzObject * obj, WlzObject * structElm, WlzErrorNum * dstErr )

Performs erosion using a structuring element.

Returns
New object or NULL on error.
Parameters
 obj Given object to be eroded. structElm Structuring element. dstErr Destination error pointer, may be NULL.

Referenced by WlzContourRBFBndObj3D(), and WlzPointsFromDomObj().