Distance transform

Distance transform — Distance transform and related morphological operations

Functions

Types and Values

Includes

#include <libgwyddion/gwyddion.h>

Description

Functions

gwy_distance_transform_type_get_enum()

const GwyEnum *
gwy_distance_transform_type_get_enum (void);

Returns GwyEnum for GwyDistanceTransformType enum type.

Returns

NULL-terminated GwyEnum which must not be modified nor freed.


gwy_nield_distance_transform()

void
gwy_nield_distance_transform (GwyNield *nield,
                              GwyField *distances,
                              GwyDistanceTransformType dtype,
                              gboolean from_border);

gwy_nield_shrink()

void
gwy_nield_shrink (GwyNield *nield,
                  gdouble amount,
                  GwyDistanceTransformType dtype,
                  gboolean from_border);

Erodes a number field containing mask by specified amount using a distance measure.

Non-zero pixels in nield will be replaced with zeros if they are not farther than amount from the grain boundary as defined by dtype .

Parameters

nield

A number field with zeros in empty space and nonzeros in grains.

 

amount

How much the grains should be reduced, in pixels. It is inclusive, i.e. pixels that are amount far from the border will be removed.

 

dtype

Type of simple distance to use.

 

from_border

TRUE to consider image edges to be grain boundaries. FALSE to reduce grains touching field boundaries only along the boundaries.

 

gwy_nield_grow()

void
gwy_nield_grow (GwyNield *nield,
                gdouble amount,
                GwyDistanceTransformType dtype,
                gboolean prevent_merging);

Dilates a number field containing mask by specified amount using a distance measure.

Non-positive pixels in field will be replaced with ones if they are not farther than amount from the grain boundary as defined by dtype .

Parameters

nield

A number field with zeros in empty space and nonzeros in grains.

 

amount

How much the grains should be expanded, in pixels. It is inclusive, i.e. exterior pixels that are amount far from the border will be filled.

 

dtype

Type of simple distance to use.

 

prevent_merging

TRUE to prevent grain merging, i.e. the growth stops where two grains would merge. FALSE to simply expand the grains, without regard to grain connectivity.

 

gwy_nield_thin()

void
gwy_nield_thin (GwyNield *nield);

Performs thinning of a data field containing mask.

The result of thinning is a ‘skeleton’ mask consisting of single-pixel thin lines.

Parameters

field

A data field with zeros in empty space and nonzeros in grains.

 

Types and Values

enum GwyDistanceTransformType

Type of distance transform.

Members

GWY_DISTANCE_TRANSFORM_CITYBLOCK

City-block distance (sum of horizontal and vertical distances).

 

GWY_DISTANCE_TRANSFORM_CONN4

Four-connectivity distance; another name for city-block distance.

 

GWY_DISTANCE_TRANSFORM_CHESS

Chessboard distance (maximum of horizontal and vertical distance).

 

GWY_DISTANCE_TRANSFORM_CONN8

Eight-connectivity distance; another name for chessboard distance.

 

GWY_DISTANCE_TRANSFORM_OCTAGONAL48

Octagonal distance beginning from city-block.

 

GWY_DISTANCE_TRANSFORM_OCTAGONAL84

Octagonal distance beginning from chess.

 

GWY_DISTANCE_TRANSFORM_OCTAGONAL

Average octagonal distance, i.e. the mean of the 48 and 84 distances.

 

GWY_DISTANCE_TRANSFORM_EUCLIDEAN

True Euclidean distance.