Masks and segmentation

A mask defines the segmentation of an image into two or more regions, encoding the interpretation of the content of that image. Combinations and multi-level masks can be used to define all regions of interest in an image.


Types of masks
Mask type # regions Edges Overlaps Data type
Bit/Binary 2 hard no bit/char
Fuzzy 2 soft yes float
Bit-level bits hard yes char/short/int
Multi-level 2^bits hard no char/short/int


Bit/binary mask

Bit or binary mask data consist of only two numbers, usually 0 and 1.

Ph6 P1 mask

bmask -v 7 -threshold 1.3

Fuzzy mask

A fuzzy mask is the same as a bit or binary mask, but with the edges smoothed in some way. The following example uses an averaging filter kernel to smooth the edges.

Phi6 P1 fuzzy mask

bfilter -verb 7 -dat f -kernel Avg5.krn

Bit-level mask

A bit-level mask encodes each region as a bit in an integer number. Regions can therefore overlap and any voxel may belong to multiple regions, with equal weight for each region.


Multi-level mask

A multi-level mask encodes each region as a unique integer. Voxels are therefore assigned to regions and overlapping is not allowed. The following mask was generated using the watershed algorithm (also called flooding), and then colorized to show the different regions.

Phi6 multi-level maskPhi6 multi-level mask colored

bflood -v 7 -thresh 1,0.05 -fill phi6_mask.tiff

bcolour -v 7 -color 1,241 phi6_mask.tiff phi6_mask_col.tiff

Multi-level masks can be added to each other:

baddmask -v 7 -type level -output new_mask.pif mask1.tif mask2.pif

Segmentation with an algorithm such as flooding typically produces many small regions. These can be added to larger regions or deleted if they are disconnected. The user has to decided what is considered a small region, and how large the interface between regions should be to consider merging:

bmultimask -v 7 -interface 70,10 multi_mask.tif new_mask.tif