machinevisiontoolbox.Image.labels_MSER

Image.labels_MSER(**kwargs)

Blob labelling using MSER

Parameters:

kwargs – arguments passed to MSER_create

Returns:

label image, number of regions

Return type:

Image, int

Compute labels of connected components in the input greyscale image. Regions are sets of contiguous pixels that form stable regions across a range of threshold values.

The method returns the label image and the number of labels N, so labels lie in the range [0, N-1].The value in the label image in an integer indicating which region the corresponding input pixel belongs to. The background has label 0.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Squares(2, 15)
>>> img.print()
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>>> labels, N = img.labels_MSER()
>>> N
0
>>> labels.print()
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
References:
  • Linear time maximally stable extremal regions, David Nistér and Henrik Stewénius, In Computer Vision–ECCV 2008, pages 183–196. Springer, 2008.

  • Robotics, Vision & Control for Python, Section 12.1.2.2, P. Corke, Springer 2023.

Seealso:

labels_binary labels_graphseg blobs opencv.MSER_create