Image Processing Toolbox | ![]() ![]() |
Convert data to unsigned 16-bit integers
Syntax
I = uint16(X)
Description
I = uint16(X)
converts the vector X
into an unsigned 16-bit integer. X
can be any numeric object (such as a double
). The elements of a uint16
range from 0 to 65535. Values outside this range are mapped to 0 or 65535. If X
is already an unsigned 16-bit integer array, uint16
has no effect.
The uint16
class is primarily meant to be used to store integer values. Hence most operations that manipulate arrays without changing their elements are defined, for example, the functions reshape
and size
, the relational operators, subscripted assignment, and subscripted reference. While most MATLAB arithmetic operations cannot be performed on uint16
data, the following operations are supported: sum
, conv2
, convn
, fft2
, and fftn
. In these cases the output will always be double
. If you attempt to perform an unsupported operation you will receive an error such as Function '+' not defined for variables of class 'uint16'
.
You can define your own methods for uint16
(as you can for any object) by placing the appropriately named method in an @uint16
directory within a directory on your path.
Other operations and functions supported for uint16
data include:
cat
, permute
, all,
and any
Most functions in the Image Processing Toolbox accept uint16
input. See the individual reference entries for information about uint16
support.
Class Support
The input image can be of class uint8
or double
.
Remarks
uint16
is a MATLAB built-in function.
Example
a = [1 3 5]; b = uint16(a); whos Name Size Bytes Class a 1x3 24 double array b 1x3 6 uint16 array
See Also
double
, uint8
, uint32
, int8
, int16
, int32
![]() | uint8 | warp | ![]() |