| Image Processing Toolbox | Search  Help Desk |
| uint8 | Examples See Also |
Convert data to unsigned 8-bit integers
Syntax
B = uint8(A)
Description
B = uint8(A) creates the unsigned 8-bit integer array B from the array A. If A is a uint8 array, B is identical to A.
The elements of a uint8 array can range from 0 to 255. Values outside this range are mapped to 0 or 255. If A is already an unsigned 8-bit integer array, uint8 has no effect.
The fractional part of each value in A is discarded on conversion. This means, for example, that uint8(102.99) is 102, not 103. Therefore, it is often a good idea to round off the values in A before converting to uint8. For example,
B = uint8(round(A))MATLAB supports these operations on
uint8 arrays:
reshape, cat, and permute
all and any functions
find function for uint8 arrays, but the returned array is of class double.
Most of the functions in the Image Processing Toolbox accept uint8 input. See the individual Reference entries for information about uint8 support.
Remarks
uint8 is a MATLAB built-in function.
See Also
double, im2double, im2uint8
Example
a = [1 3 5]; b = uint8(a); whos Name Size Bytes Class a 1x3 24 doublearray b 1x3 3 uint8 array