| Image Processing Toolbox User's Guide | ![]() |
Convert image to 8-bit unsigned integers
Syntax
Description
im2uint8 takes an image as input and returns an image of class uint8. If the input image is of class uint8, the output image is identical to it. If the input image is not of class uint8, im2uint8 returns the equivalent image of class uint8, rescaling or offsetting the data as necessary.
I2 = im2uint8(I) converts the intensity image I to uint8, rescaling the data if necessary.
RGB2 = im2uint8(RGB) converts the truecolor image RGB to uint8, rescaling the data if necessary.
I = im2uint8(BW) converts the binary image BW to a uint8 intensity image, changing 1-valued elements to 255
X2 = im2uint8(X,'indexed') converts the indexed image X to uint8, offsetting the data if necessary. Note that it is not always possible to convert an indexed image to uint8. If X is of class double, the maximum value of X must be 256 or less; if X is of class uint16, the maximum value of X must be 255 or less.
Class Support
Intensity and truecolor images can be uint8, uint16, double, logical, single, or int16. Indexed images can be uint8, uint16, double, or logical. Binary input images must be logical. The output image is uint8.
Example
See Also
im2double, im2int16, im2single, im2uint16, uint8
| im2uint16 | imabsdiff | ![]() |
© 1994-2005 The MathWorks, Inc.