Documentation Center

  • Trial Software
  • Product Updates

grayslice

Convert grayscale image to indexed image using multilevel thresholding

Syntax

X = grayslice(I, n)

Description

X = grayslice(I, n) thresholds the intensity image I returning an indexed image in X. grayslice uses the threshold values:

X = grayslice(I, v) thresholds the intensity image I using the values of v, where v is a vector of values between 0 and 1, returning an indexed image in X.

You can view the thresholded image using imshow(X,map) with a colormap of appropriate length.

Class Support

The input image I can be of class uint8, uint16, int16, single, or double, and must be nonsparse. Note that the threshold values are always between 0 and 1, even if I is of class uint8 or uint16. In this case, each threshold value is multiplied by 255 or 65535 to determine the actual threshold to use.

The class of the output image X depends on the number of threshold values, as specified by n or length(v). If the number of threshold values is less than 256, then X is of class uint8, and the values in X range from 0 to n or length(v). If the number of threshold values is 256 or greater, X is of class double, and the values in X range from 1 to n+1 or length(v)+1.

Examples

I = imread('snowflakes.png');
X = grayslice(I,16);
imshow(I)
figure, imshow(X,jet(16))

See Also

Was this topic helpful?