grayslice
Convert grayscale image to indexed image using multilevel thresholding
Description
converts a grayscale image to an indexed image by using multilevel thresholding. The
function automatically calculates the threshold values based on the number of threshold
values, X = grayslice(I,N)N. To learn more about the threshold calculation, see Algorithms.
returns an indexed image by multilevel thresholding of input image using a specified set of
thresholds.X = grayslice(I,thresholds)
Examples
Input Arguments
Output Arguments
Tips
You can view the thresholded image using
imshow(X,map)with a colormap of appropriate length.
Algorithms
The function performs multilevel thresholding of the input grayscale image and returns an
indexed image as the output. If you specify the number of thresholds N,
then grayslice assigns pixels to N indices according
to these thresholds.
The first index in
Xconsists of the grayscale pixels in the rangeThe k-th index in
Xconsists of the grayscale pixels in the rangeThe last index in
Xconsists of the grayscale pixels in the range .
max_intensity depends on the data type of the input image.
| Image Data Type | max_intensity |
|---|---|
uint8 | 255 |
int16 or uint16 | 65535 |
single or double | 1 |
Note
Before thresholding an image of data type int16, the
grayslice function converts the image to uint16 by
adding 32,768 to each pixel.



