Main Content

roicolor

Select region of interest (ROI) based on color

Description

example

BW= roicolor(I,low,high)returns an ROI selected as those pixels in imageIthat lie within the range [low high]. The returned value,BW, is a binary image with0s outside the region of interest and1s inside.

BW= roicolor(I,v)returns an ROI selected as those pixels in imageIthat match values in vectorv.

Examples

collapse all

Load an indexed imageXwith colormapmap. The colormap has 128 colors. Display the indexed image.

loadtreesimshow(X,map)

Figure contains an axes object. The axes object contains an object of type image.

Create a binary mask image based on color. The mask istruefor pixels with index in the range [10, 20]. The mask isfalsefor pixels with index outside this range.

BW = roicolor(X,10,20);

Display the binary mask.

imshow(BW)

Figure contains an axes object. The axes object contains an object of type image.

Input Arguments

collapse all

Indexed or grayscale image, specified as anm-by-nnumeric matrix.

Minimum value to include in the ROI, specified as a numeric scalar.

Minimum value to include in the ROI, specified as a numeric scalar.

Set of values to include in the ROI, specified as a numeric vector.

Output Arguments

collapse all

Binary image, returned as anm-by-nlogical matrix.

Data Types:logical

Tips

  • You can use the returned image as a mask for masked filtering usingroifilt2.

  • If you specify a colormap range,[lowhigh], then

    BW = (I >= low) & (I <= high)
  • If you specify a set of colormap values,v, then the mask generated byroicoloris equivalent to:

    BW = ismember(I,v)

版本历史

Introduced before R2006a