Convert grayscale image to indexed image using multilevel thresholding
X = grayslice(I, n)
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.
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.