Main Content

binmask2sigroi

Convert binary mask to matrix of ROI limits

Since R2020b

Description

roilims = binmask2sigroi(mask) converts mask, a binary mask of signal region-of-interest (ROI) samples, to a matrix of ROI limits, roilims.

example

Examples

collapse all

Consider a logical sequence that is true for samples belonging to four possible regions of interest of a signal. Convert the sequence to a two-column matrix of ROI limits.

mask = logical([0 0 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 ...
                0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0]);

roilims = binmask2sigroi(mask)
roilims = 4×2

     3     6
    11    13
    19    27
    31    32

Input Arguments

collapse all

Binary mask, specified as a logical vector. You can also specify mask as a numeric vector. In that case, any nonzero element of the vector is converted to logical 1 (true) and zeros are converted to logical 0 (false).

Example: logical([0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 1 1 0]) specifies a binary mask containing four regions of interest.

Example: [0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 1 1 0] specifies a binary mask containing four regions of interest.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Region-of-interest limits, returned as a two-column matrix of positive integers. The ith row of roilims contains nondecreasing indices corresponding to the beginning and end samples of the ith region of interest.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2020b