morphology

morphology — morphological operators, rank filters and related image analysis

Stability Level

Stable, unless otherwise indicated

Synopsis


#include <vips/vips.h>

int                 im_dilate                           (IMAGE *in,
                                                         IMAGE *out,
                                                         INTMASK *m);
int                 im_erode                            (IMAGE *in,
                                                         IMAGE *out,
                                                         INTMASK *m);
int                 im_rank                             (IMAGE *in,
                                                         IMAGE *out,
                                                         int xsize,
                                                         int ysize,
                                                         int order);
int                 im_rank_image                       (IMAGE **in,
                                                         IMAGE *out,
                                                         int n,
                                                         int index);
int                 im_maxvalue                         (IMAGE **in,
                                                         IMAGE *out,
                                                         int n);
int                 im_cntlines                         (IMAGE *im,
                                                         double *nolines,
                                                         int flag);
int                 im_zerox                            (IMAGE *in,
                                                         IMAGE *out,
                                                         int flag);
int                 im_profile                          (IMAGE *in,
                                                         IMAGE *out,
                                                         int dir);
int                 im_label_regions                    (IMAGE *test,
                                                         IMAGE *mask,
                                                         int *segments);

Description

Erode, dilate, rank, count lines, number regions, etc.

Details

im_dilate ()

int                 im_dilate                           (IMAGE *in,
                                                         IMAGE *out,
                                                         INTMASK *m);

im_erode ()

int                 im_erode                            (IMAGE *in,
                                                         IMAGE *out,
                                                         INTMASK *m);

im_rank ()

int                 im_rank                             (IMAGE *in,
                                                         IMAGE *out,
                                                         int xsize,
                                                         int ysize,
                                                         int order);

im_rank_image ()

int                 im_rank_image                       (IMAGE **in,
                                                         IMAGE *out,
                                                         int n,
                                                         int index);

im_maxvalue ()

int                 im_maxvalue                         (IMAGE **in,
                                                         IMAGE *out,
                                                         int n);

im_cntlines ()

int                 im_cntlines                         (IMAGE *im,
                                                         double *nolines,
                                                         int flag);

im_zerox ()

int                 im_zerox                            (IMAGE *in,
                                                         IMAGE *out,
                                                         int flag);

im_profile ()

int                 im_profile                          (IMAGE *in,
                                                         IMAGE *out,
                                                         int dir);

im_label_regions ()

int                 im_label_regions                    (IMAGE *test,
                                                         IMAGE *mask,
                                                         int *segments);

The test image is repeatedly scanned and regions of 4-connected pixels with the same pixel value found. Every time a region is discovered, those pixels are marked in mask with a unique serial number. Once all pixels have been labelled, the operation returns, setting segments to the number of discrete regions which were detected.

mask is always a 1-band IM_BANDFMT_UINT image of the same dimensions as test.

This operation is useful for, for example, blob counting. You can use the morphological operators to detect and isolate a series of objects, then use im_label_regions() to number them all.

Use im_histindexed() to (for example) find blob coordinates.

See also: im_histindexed()

test :

image to test

mask :

write labelled regions here

segments :

return number of regions here

Returns :

0 on success, -1 on error.

See Also

boolean