boundary

boundary

Synopsis

#define             BOUNDARY_HALF_WAY
enum                BoundaryType;
                    BoundSeg;
BoundSeg *          boundary_find                       (PixelRegion *maskPR,
                                                         BoundaryType type,
                                                         gint x1,
                                                         gint y1,
                                                         gint x2,
                                                         gint y2,
                                                         guchar threshold,
                                                         gint *num_segs);
BoundSeg *          boundary_sort                       (const BoundSeg *segs,
                                                         gint num_segs,
                                                         gint *num_groups);
BoundSeg *          boundary_simplify                   (BoundSeg *sorted_segs,
                                                         gint num_groups,
                                                         gint *num_segs);
void                boundary_offset                     (BoundSeg *segs,
                                                         gint num_segs,
                                                         gint off_x,
                                                         gint off_y);

Description

Details

BOUNDARY_HALF_WAY

#define BOUNDARY_HALF_WAY 127


enum BoundaryType

typedef enum {
  BOUNDARY_WITHIN_BOUNDS,
  BOUNDARY_IGNORE_BOUNDS
} BoundaryType;

BOUNDARY_WITHIN_BOUNDS

BOUNDARY_IGNORE_BOUNDS


BoundSeg

typedef struct {
  gint   x1;
  gint   y1;
  gint   x2;
  gint   y2;
  guint  open    : 1;
  guint  visited : 1;
} BoundSeg;


boundary_find ()

BoundSeg *          boundary_find                       (PixelRegion *maskPR,
                                                         BoundaryType type,
                                                         gint x1,
                                                         gint y1,
                                                         gint x2,
                                                         gint y2,
                                                         guchar threshold,
                                                         gint *num_segs);

This function returns an array of BoundSeg's which describe all outlines along pixel value threahold, optionally within specified bounds instead of the whole region.

The maskPR paramater can be any PixelRegion. If the region has more than 1 bytes/pixel, the last byte of each pixel is used to determine the boundary outline.

maskPR :

any PixelRegion

type :

type of bounds

x1 :

left side of bounds

y1 :

top side of bounds

x2 :

right side of bounds

y2 :

botton side of bounds

threshold :

pixel value of boundary line

num_segs :

number of returned BoundSeg's

Returns :

the boundary array.

boundary_sort ()

BoundSeg *          boundary_sort                       (const BoundSeg *segs,
                                                         gint num_segs,
                                                         gint *num_groups);

This function takes an array of BoundSeg's as returned by boundary_find() and sorts it by contiguous groups. The returned array contains markers consisting of -1 coordinates and is num_groups elements longer than segs.

segs :

unsorted input segs.

num_segs :

number of input segs

num_groups :

number of groups in the sorted segs

Returns :

the sorted segs

boundary_simplify ()

BoundSeg *          boundary_simplify                   (BoundSeg *sorted_segs,
                                                         gint num_groups,
                                                         gint *num_segs);

This function takes an array of BoundSeg's which has been sorted with boundary_sort() and reduces the number of segments while preserving the general shape as close as possible.

sorted_segs :

sorted input segs

num_groups :

number of groups in the sorted segs

num_segs :

number of returned segs.

Returns :

the simplified segs.

boundary_offset ()

void                boundary_offset                     (BoundSeg *segs,
                                                         gint num_segs,
                                                         gint off_x,
                                                         gint off_y);