### Method

# Vips Image labelregions

#### Declaration [src]

    int
    vips_labelregions (
      VipsImage* in,
      VipsImage** mask,
      ...
    )

#### Description [src]

Label regions of equal pixels in an image.

Repeatedly scans `in` for regions of 4-connected pixels with the same pixel value. 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 `VIPS_FORMAT_INT` image of the same dimensions as `in`.

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 `vips_labelregions()` to number them all.

Use `vips_hist_find_indexed()` to (for example) find blob coordinates.

Optional arguments

- `segments`: `gint`, output, number of regions found

See also

`vips_hist_find_indexed()`.

This method is not directly available to language bindings.

#### Parameters

`mask`

  Type: `VipsImage`

  Write labelled regions here.

  The data is owned by the caller of the method.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.